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 "dotfield/ecs/components/dotfield_component.h"
17 #include "ComponentTools/base_manager.h"
18 #include "ComponentTools/base_manager.inl"
19
20 #define IMPLEMENT_MANAGER
21 #include "PropertyTools/property_macros.h"
22
23 namespace Dotfield {
24 class DotfieldComponentManager final : public CORE_NS::BaseManager<DotfieldComponent, IDotfieldComponentManager> {
25 BEGIN_PROPERTY(DotfieldComponent, ComponentMetadata)
26 #include "dotfield/ecs/components/dotfield_component.h"
27 END_PROPERTY();
28 const BASE_NS::array_view<const CORE_NS::Property> componentMetaData_{ ComponentMetadata,
29 BASE_NS::countof(ComponentMetadata) };
30
31 public:
DotfieldComponentManager(CORE_NS::IEcs& ecs)32 DotfieldComponentManager(CORE_NS::IEcs& ecs)
33 : BaseManager<DotfieldComponent, IDotfieldComponentManager>(ecs, CORE_NS::GetName<DotfieldComponent>())
34 {}
35
36 ~DotfieldComponentManager() = default;
37
38 size_t PropertyCount() const override
39 {
40 return componentMetaData_.size();
41 }
42
43 const CORE_NS::Property* MetaData(size_t index) const override
44 {
45 if (index < componentMetaData_.size()) {
46 return &componentMetaData_[index];
47 }
48 return nullptr;
49 }
50
51 BASE_NS::array_view<const CORE_NS::Property> MetaData() const override
52 {
53 return componentMetaData_;
54 }
55 };
56
IDotfieldComponentManagerInstance(CORE_NS::IEcs& ecs)57 CORE_NS::IComponentManager* IDotfieldComponentManagerInstance(CORE_NS::IEcs& ecs)
58 {
59 return new DotfieldComponentManager(ecs);
60 }
61
IDotfieldComponentManagerDestroy(CORE_NS::IComponentManager* instance)62 void IDotfieldComponentManagerDestroy(CORE_NS::IComponentManager* instance)
63 {
64 delete static_cast<DotfieldComponentManager*>(instance);
65 }
66 } // namespace Dotfield
67