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/reflection_probe_component.h>
17 #include <base/containers/array_view.h>
18 #include <base/containers/type_traits.h>
19 #include <core/property/property_types.h>
20
21 #include "ComponentTools/base_manager.h"
22 #include "ComponentTools/base_manager.inl"
23
24 #define IMPLEMENT_MANAGER
25 #include <core/property_tools/property_macros.h>
26
27 CORE_BEGIN_NAMESPACE()
28 using BASE_NS::array_view;
29 using BASE_NS::countof;
30
31 using CORE3D_NS::ReflectionProbeComponent;
32 CORE_END_NAMESPACE()
33
34 CORE3D_BEGIN_NAMESPACE()
35 using BASE_NS::array_view;
36 using BASE_NS::countof;
37
38 using CORE_NS::BaseManager;
39 using CORE_NS::IComponentManager;
40 using CORE_NS::IEcs;
41 using CORE_NS::Property;
42
43 class ReflectionProbeComponentManager final
44 : public BaseManager<ReflectionProbeComponent, IReflectionProbeComponentManager> {
45 BEGIN_PROPERTY(ReflectionProbeComponent, properties_)
46 #include <3d/ecs/components/reflection_probe_component.h>
47 END_PROPERTY();
48
49 public:
ReflectionProbeComponentManager(IEcs & ecs)50 explicit ReflectionProbeComponentManager(IEcs& ecs)
51 : BaseManager<ReflectionProbeComponent, IReflectionProbeComponentManager>(
52 ecs, CORE_NS::GetName<ReflectionProbeComponent>(), 0U)
53 {}
54
55 ~ReflectionProbeComponentManager() = default;
56
PropertyCount() const57 size_t PropertyCount() const override
58 {
59 return BASE_NS::countof(properties_);
60 }
61
MetaData(size_t index) const62 const Property* MetaData(size_t index) const override
63 {
64 if (index < BASE_NS::countof(properties_)) {
65 return &properties_[index];
66 }
67 return nullptr;
68 }
69
MetaData() const70 array_view<const Property> MetaData() const override
71 {
72 return properties_;
73 }
74 };
75
IReflectionProbeComponentManagerInstance(IEcs & ecs)76 IComponentManager* IReflectionProbeComponentManagerInstance(IEcs& ecs)
77 {
78 return new ReflectionProbeComponentManager(ecs);
79 }
80
IReflectionProbeComponentManagerDestroy(IComponentManager * instance)81 void IReflectionProbeComponentManagerDestroy(IComponentManager* instance)
82 {
83 delete static_cast<ReflectionProbeComponentManager*>(instance);
84 }
85 CORE3D_END_NAMESPACE()
86