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/animation_track_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 using CORE3D_NS::AnimationTrackComponent;
26 DECLARE_PROPERTY_TYPE(AnimationTrackComponent::Interpolation);
27
28 ENUM_TYPE_METADATA(AnimationTrackComponent::Interpolation, ENUM_VALUE(STEP, "Step"), ENUM_VALUE(LINEAR, "Linear"),
29 ENUM_VALUE(SPLINE, "Spline"))
30 CORE_END_NAMESPACE()
31
32 CORE3D_BEGIN_NAMESPACE()
33 using BASE_NS::array_view;
34 using BASE_NS::countof;
35
36 using CORE_NS::BaseManager;
37 using CORE_NS::IComponentManager;
38 using CORE_NS::IEcs;
39 using CORE_NS::Property;
40
41 class AnimationTrackComponentManager final
42 : public BaseManager<AnimationTrackComponent, IAnimationTrackComponentManager> {
43 BEGIN_PROPERTY(AnimationTrackComponent, componentMetaData_)
44 #include <3d/ecs/components/animation_track_component.h>
45 END_PROPERTY();
46
47 public:
AnimationTrackComponentManager(IEcs & ecs)48 explicit AnimationTrackComponentManager(IEcs& ecs)
49 : BaseManager<AnimationTrackComponent, IAnimationTrackComponentManager>(
50 ecs, CORE_NS::GetName<AnimationTrackComponent>(), 0U)
51 {}
52
53 ~AnimationTrackComponentManager() = default;
54
PropertyCount() const55 size_t PropertyCount() const override
56 {
57 return BASE_NS::countof(componentMetaData_);
58 }
59
MetaData(size_t index) const60 const Property* MetaData(size_t index) const override
61 {
62 if (index < BASE_NS::countof(componentMetaData_)) {
63 return &componentMetaData_[index];
64 }
65 return nullptr;
66 }
67
MetaData() const68 array_view<const Property> MetaData() const override
69 {
70 return componentMetaData_;
71 }
72 };
73
IAnimationTrackComponentManagerInstance(IEcs & ecs)74 IComponentManager* IAnimationTrackComponentManagerInstance(IEcs& ecs)
75 {
76 return new AnimationTrackComponentManager(ecs);
77 }
78
IAnimationTrackComponentManagerDestroy(IComponentManager * instance)79 void IAnimationTrackComponentManagerDestroy(IComponentManager* instance)
80 {
81 delete static_cast<AnimationTrackComponentManager*>(instance);
82 }
83 CORE3D_END_NAMESPACE()
84