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