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/planar_reflection_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 CORE_BEGIN_NAMESPACE()
26 using CORE3D_NS::PlanarReflectionComponent;
27
28 // Extend propertysystem with the enums
29 ENUM_TYPE_METADATA(
30 PlanarReflectionComponent::FlagBits, ENUM_VALUE(ACTIVE_RENDER_BIT, "Active Render"), ENUM_VALUE(MSAA_BIT, "MSAA"))
31 CORE_END_NAMESPACE()
32
33 CORE3D_BEGIN_NAMESPACE()
34 using BASE_NS::array_view;
35 using BASE_NS::countof;
36
37 using CORE_NS::BaseManager;
38 using CORE_NS::IComponentManager;
39 using CORE_NS::IEcs;
40 using CORE_NS::Property;
41 using CORE_NS::PropertyFlags;
42
43 class PlanarReflectionComponentManager final
44 : public BaseManager<PlanarReflectionComponent, IPlanarReflectionComponentManager> {
45 BEGIN_PROPERTY(PlanarReflectionComponent, componentMetaData_)
46 #include <3d/ecs/components/planar_reflection_component.h>
47 END_PROPERTY();
48
49 public:
PlanarReflectionComponentManager(IEcs & ecs)50 explicit PlanarReflectionComponentManager(IEcs& ecs)
51 : BaseManager<PlanarReflectionComponent, IPlanarReflectionComponentManager>(
52 ecs, CORE_NS::GetName<PlanarReflectionComponent>())
53 {}
54
55 // ECS uninitialize has destroyed (Destroy()) all the components within the manager
56 ~PlanarReflectionComponentManager() = default;
57
PropertyCount() const58 size_t PropertyCount() const override
59 {
60 return BASE_NS::countof(componentMetaData_);
61 }
62
MetaData(size_t index) const63 const Property* MetaData(size_t index) const override
64 {
65 if (index < BASE_NS::countof(componentMetaData_)) {
66 return &componentMetaData_[index];
67 }
68 return nullptr;
69 }
70
MetaData() const71 array_view<const Property> MetaData() const override
72 {
73 return componentMetaData_;
74 }
75 };
76
IPlanarReflectionComponentManagerInstance(IEcs & ecs)77 IComponentManager* IPlanarReflectionComponentManagerInstance(IEcs& ecs)
78 {
79 return new PlanarReflectionComponentManager(ecs);
80 }
81
IPlanarReflectionComponentManagerDestroy(IComponentManager * instance)82 void IPlanarReflectionComponentManagerDestroy(IComponentManager* instance)
83 {
84 delete static_cast<PlanarReflectionComponentManager*>(instance);
85 }
86 CORE3D_END_NAMESPACE()
87