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/animation_input_component.h>
17
18 #include "ComponentTools/base_manager.h"
19 #include "ComponentTools/base_manager.inl"
20
21 #define IMPLEMENT_MANAGER
22 #include "PropertyTools/property_macros.h"
23
24 CORE3D_BEGIN_NAMESPACE()
25 using BASE_NS::array_view;
26 using BASE_NS::countof;
27
28 using CORE_NS::BaseManager;
29 using CORE_NS::IComponentManager;
30 using CORE_NS::IEcs;
31 using CORE_NS::Property;
32
33 class AnimationInputComponentManager final
34 : public BaseManager<AnimationInputComponent, IAnimationInputComponentManager> {
35 BEGIN_PROPERTY(AnimationInputComponent, ComponentMetadata)
36 #include <3d/ecs/components/animation_input_component.h>
37 END_PROPERTY();
38 const array_view<const Property> ComponentMetaData { ComponentMetadata, countof(ComponentMetadata) };
39
40 public:
AnimationInputComponentManager(IEcs & ecs)41 explicit AnimationInputComponentManager(IEcs& ecs)
42 : BaseManager<AnimationInputComponent, IAnimationInputComponentManager>(
43 ecs, CORE_NS::GetName<AnimationInputComponent>())
44 {}
45
46 ~AnimationInputComponentManager() = default;
47
PropertyCount() const48 size_t PropertyCount() const override
49 {
50 return ComponentMetaData.size();
51 }
52
MetaData(size_t index) const53 const Property* MetaData(size_t index) const override
54 {
55 if (index < ComponentMetaData.size()) {
56 return &ComponentMetaData[index];
57 }
58 return nullptr;
59 }
60
MetaData() const61 array_view<const Property> MetaData() const override
62 {
63 return ComponentMetaData;
64 }
65 };
66
IAnimationInputComponentManagerInstance(IEcs & ecs)67 IComponentManager* IAnimationInputComponentManagerInstance(IEcs& ecs)
68 {
69 return new AnimationInputComponentManager(ecs);
70 }
71
IAnimationInputComponentManagerDestroy(IComponentManager * instance)72 void IAnimationInputComponentManagerDestroy(IComponentManager* instance)
73 {
74 delete static_cast<AnimationInputComponentManager*>(instance);
75 }
76 CORE3D_END_NAMESPACE()
77