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_output_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 CORE_BEGIN_NAMESPACE()
25 using BASE_NS::vector;
26 DECLARE_PROPERTY_TYPE(vector<uint8_t>);
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
38 class AnimationOutputComponentManager final
39 : public BaseManager<AnimationOutputComponent, IAnimationOutputComponentManager> {
40 BEGIN_PROPERTY(AnimationOutputComponent, ComponentMetadata)
41 #include <3d/ecs/components/animation_output_component.h>
42 END_PROPERTY();
43 const array_view<const Property> ComponentMetaData { ComponentMetadata, countof(ComponentMetadata) };
44
45 public:
AnimationOutputComponentManager(IEcs & ecs)46 explicit AnimationOutputComponentManager(IEcs& ecs)
47 : BaseManager<AnimationOutputComponent, IAnimationOutputComponentManager>(
48 ecs, CORE_NS::GetName<AnimationOutputComponent>())
49 {}
50
51 ~AnimationOutputComponentManager() = default;
52
PropertyCount() const53 size_t PropertyCount() const override
54 {
55 return ComponentMetaData.size();
56 }
57
MetaData(size_t index) const58 const Property* MetaData(size_t index) const override
59 {
60 if (index < ComponentMetaData.size()) {
61 return &ComponentMetaData[index];
62 }
63 return nullptr;
64 }
65
MetaData() const66 array_view<const Property> MetaData() const override
67 {
68 return ComponentMetaData;
69 }
70 };
71
IAnimationOutputComponentManagerInstance(IEcs & ecs)72 IComponentManager* IAnimationOutputComponentManagerInstance(IEcs& ecs)
73 {
74 return new AnimationOutputComponentManager(ecs);
75 }
76
IAnimationOutputComponentManagerDestroy(IComponentManager * instance)77 void IAnimationOutputComponentManagerDestroy(IComponentManager* instance)
78 {
79 delete static_cast<AnimationOutputComponentManager*>(instance);
80 }
81 CORE3D_END_NAMESPACE()
82