1 /* 2 * Copyright (c) 2022 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 #include <3d/ecs/components/water_ripple_component.h> 17 #include <core/property_tools/core_metadata.inl> 18 19 #include "ComponentTools/base_manager.h" 20 #include "ComponentTools/base_manager.inl" 21 22 #define IMPLEMENT_MANAGER 23 #include <core/property_tools/property_macros.h> 24 25 CORE_BEGIN_NAMESPACE() 26 using CORE3D_NS::WaterRippleComponent; 27 CORE_END_NAMESPACE() 28 29 CORE3D_BEGIN_NAMESPACE() 30 using BASE_NS::array_view; 31 using BASE_NS::countof; 32 33 using CORE_NS::BaseManager; 34 using CORE_NS::IComponentManager; 35 using CORE_NS::IEcs; 36 using CORE_NS::Property; 37 using CORE_NS::PropertyFlags; 38 39 class RippleComponentManager final : public BaseManager<WaterRippleComponent, IWaterRippleComponentManager> { 40 BEGIN_PROPERTY(WaterRippleComponent, componentMetaData_) 41 #include <3d/ecs/components/water_ripple_component.h> 42 END_PROPERTY(); 43 44 public: RippleComponentManager(IEcs & ecs)45 explicit RippleComponentManager(IEcs& ecs) 46 : BaseManager<WaterRippleComponent, IWaterRippleComponentManager>(ecs, CORE_NS::GetName<WaterRippleComponent>()) 47 {} 48 49 ~RippleComponentManager() = default; 50 PropertyCount() const51 size_t PropertyCount() const override 52 { 53 return BASE_NS::countof(componentMetaData_); 54 } 55 MetaData(size_t index) const56 const Property* MetaData(size_t index) const override 57 { 58 if (index < BASE_NS::countof(componentMetaData_)) { 59 return &componentMetaData_[index]; 60 } 61 return nullptr; 62 } 63 MetaData() const64 array_view<const Property> MetaData() const override 65 { 66 return componentMetaData_; 67 } 68 }; 69 IWaterRippleComponentManagerInstance(CORE_NS::IEcs & ecs)70IComponentManager* IWaterRippleComponentManagerInstance(CORE_NS::IEcs& ecs) 71 { 72 return new RippleComponentManager(ecs); 73 } 74 IWaterRippleComponentManagerDestroy(IComponentManager * instance)75void IWaterRippleComponentManagerDestroy(IComponentManager* instance) 76 { 77 delete static_cast<RippleComponentManager*>(instance); 78 } 79 CORE3D_END_NAMESPACE() 80