• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
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 namespace Dotfield {
25 class DotfieldComponentManager final : public CORE_NS::BaseManager<DotfieldComponent, IDotfieldComponentManager> {
26     BEGIN_PROPERTY(DotfieldComponent, ComponentMetadata)
27 #include "dotfield/ecs/components/dotfield_component.h"
28     END_PROPERTY();
29     const BASE_NS::array_view<const CORE_NS::Property> componentMetaData_ { ComponentMetadata,
30         BASE_NS::countof(ComponentMetadata) };
31 
32 public:
DotfieldComponentManager(CORE_NS::IEcs & ecs)33     explicit DotfieldComponentManager(CORE_NS::IEcs& ecs)
34         : BaseManager<DotfieldComponent, IDotfieldComponentManager>(ecs, CORE_NS::GetName<DotfieldComponent>())
35     {}
36 
37     ~DotfieldComponentManager() = default;
38 
PropertyCount() const39     size_t PropertyCount() const override
40     {
41         return componentMetaData_.size();
42     }
43 
MetaData(size_t index) const44     const CORE_NS::Property* MetaData(size_t index) const override
45     {
46         if (index < componentMetaData_.size()) {
47             return &componentMetaData_[index];
48         }
49         return nullptr;
50     }
51 
MetaData() const52     BASE_NS::array_view<const CORE_NS::Property> MetaData() const override
53     {
54         return componentMetaData_;
55     }
56 };
57 
IDotfieldComponentManagerInstance(CORE_NS::IEcs & ecs)58 CORE_NS::IComponentManager* IDotfieldComponentManagerInstance(CORE_NS::IEcs& ecs)
59 {
60     return new DotfieldComponentManager(ecs);
61 }
62 
IDotfieldComponentManagerDestroy(CORE_NS::IComponentManager * instance)63 void IDotfieldComponentManagerDestroy(CORE_NS::IComponentManager* instance)
64 {
65     delete static_cast<DotfieldComponentManager*>(instance);
66 }
67 } // namespace Dotfield
68