• 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 <3d/ecs/components/layer_component.h>
17 
18 #include "ComponentTools/base_manager.h"
19 #include "ComponentTools/base_manager.inl"
20 #include "ecs/components/layer_flag_bits_metadata.h"
21 
22 #define IMPLEMENT_MANAGER
23 #include <core/property_tools/property_macros.h>
24 
25 CORE3D_BEGIN_NAMESPACE()
26 using BASE_NS::array_view;
27 using BASE_NS::countof;
28 using CORE_NS::BaseManager;
29 using CORE_NS::IComponentManager;
30 using CORE_NS::IEcs;
31 using CORE_NS::Property;
32 
33 class LayerComponentManager final : public BaseManager<LayerComponent, ILayerComponentManager> {
34     BEGIN_PROPERTY(LayerComponent, componentMetaData_)
35 #include <3d/ecs/components/layer_component.h>
36     END_PROPERTY();
37 
38 public:
LayerComponentManager(IEcs & ecs)39     explicit LayerComponentManager(IEcs& ecs)
40         : BaseManager<LayerComponent, ILayerComponentManager>(ecs, CORE_NS::GetName<LayerComponent>())
41     {}
42     ~LayerComponentManager() = default;
PropertyCount() const43     size_t PropertyCount() const override
44     {
45         return BASE_NS::countof(componentMetaData_);
46     }
47 
MetaData(size_t index) const48     const Property* MetaData(size_t index) const override
49     {
50         if (index < BASE_NS::countof(componentMetaData_)) {
51             return &componentMetaData_[index];
52         }
53         return nullptr;
54     }
55 
MetaData() const56     array_view<const Property> MetaData() const override
57     {
58         return componentMetaData_;
59     }
60 };
61 
ILayerComponentManagerInstance(IEcs & ecs)62 IComponentManager* ILayerComponentManagerInstance(IEcs& ecs)
63 {
64     return new LayerComponentManager(ecs);
65 }
66 
ILayerComponentManagerDestroy(IComponentManager * instance)67 void ILayerComponentManagerDestroy(IComponentManager* instance)
68 {
69     delete static_cast<LayerComponentManager*>(instance);
70 }
71 CORE3D_END_NAMESPACE()
72