• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2024 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/morph_component.h>
17 
18 #include "ComponentTools/base_manager.h"
19 #include "ComponentTools/base_manager.inl"
20 
21 #define IMPLEMENT_MANAGER
22 #include <core/property_tools/property_macros.h>
23 
24 CORE_BEGIN_NAMESPACE()
25 DECLARE_PROPERTY_TYPE(BASE_NS::vector<BASE_NS::string>);
26 CORE_END_NAMESPACE()
27 
28 CORE3D_BEGIN_NAMESPACE()
29 using BASE_NS::array_view;
30 using BASE_NS::countof;
31 
32 using CORE_NS::BaseManager;
33 using CORE_NS::IComponentManager;
34 using CORE_NS::IEcs;
35 using CORE_NS::Property;
36 using CORE_NS::PropertyFlags;
37 
38 class MorphComponentManager final : public BaseManager<MorphComponent, IMorphComponentManager> {
39     BEGIN_PROPERTY(MorphComponent, componentMetaData_)
40 #include <3d/ecs/components/morph_component.h>
41     END_PROPERTY();
42 
43 public:
MorphComponentManager(IEcs & ecs)44     explicit MorphComponentManager(IEcs& ecs)
45         : BaseManager<MorphComponent, IMorphComponentManager>(ecs, CORE_NS::GetName<MorphComponent>(), 0U)
46     {}
47 
48     ~MorphComponentManager() = default;
49 
PropertyCount() const50     size_t PropertyCount() const override
51     {
52         return BASE_NS::countof(componentMetaData_);
53     }
54 
MetaData(size_t index) const55     const Property* MetaData(size_t index) const override
56     {
57         if (index < BASE_NS::countof(componentMetaData_)) {
58             return &componentMetaData_[index];
59         }
60         return nullptr;
61     }
62 
MetaData() const63     array_view<const Property> MetaData() const override
64     {
65         return componentMetaData_;
66     }
67 };
68 
IMorphComponentManagerInstance(IEcs & ecs)69 IComponentManager* IMorphComponentManagerInstance(IEcs& ecs)
70 {
71     return new MorphComponentManager(ecs);
72 }
IMorphComponentManagerDestroy(IComponentManager * instance)73 void IMorphComponentManagerDestroy(IComponentManager* instance)
74 {
75     delete static_cast<MorphComponentManager*>(instance);
76 }
77 
78 CORE3D_END_NAMESPACE()