1 /* 2 * Copyright (c) 2021 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef RENDER_SERVICE_CLIENT_CORE_ANIMATION_RS_PROPERTY_ACCESSORS_H 17 #define RENDER_SERVICE_CLIENT_CORE_ANIMATION_RS_PROPERTY_ACCESSORS_H 18 19 #include <unordered_map> 20 21 #include "animation/rs_animatable_property.h" 22 #include "common/rs_macros.h" 23 #include "property/rs_properties.h" 24 25 namespace OHOS { 26 namespace Rosen { 27 class RS_EXPORT RSBasePropertyAccessors { 28 public: RSBasePropertyAccessors()29 RSBasePropertyAccessors() {} ~RSBasePropertyAccessors()30 virtual ~RSBasePropertyAccessors() {} 31 32 static const std::shared_ptr<RSBasePropertyAccessors> GetAccessor(RSAnimatableProperty property); 33 34 private: 35 const static std::unordered_map<RSAnimatableProperty, std::shared_ptr<RSBasePropertyAccessors>> 36 PROPERTY_ACCESSOR_LUT; 37 }; 38 39 template<typename T> 40 class RS_EXPORT RSPropertyAccessors : public RSBasePropertyAccessors { 41 typedef void (RSProperties::*SetProperty)(T value); 42 typedef T (RSProperties::*GetProperty)() const; 43 44 public: RSPropertyAccessors(SetProperty setter,GetProperty getter)45 explicit RSPropertyAccessors(SetProperty setter, GetProperty getter) : setter_(setter), getter_(getter) {}; 46 ~RSPropertyAccessors() override = default; 47 48 const SetProperty setter_; 49 const GetProperty getter_; 50 }; 51 } // namespace Rosen 52 } // namespace OHOS 53 54 #endif // RENDER_SERVICE_CLIENT_CORE_ANIMATION_RS_PROPERTY_ACCESSORS_H 55