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/weather_component.h>
17 #include <core/property_tools/core_metadata.inl>
18
19 #include "ComponentTools/base_manager.h"
20 #include "ComponentTools/base_manager.inl"
21
22 #define IMPLEMENT_MANAGER
23 #include <core/property_tools/property_macros.h>
24
25 CORE_BEGIN_NAMESPACE()
26 using CORE3D_NS::WeatherComponent;
27
28 DECLARE_PROPERTY_TYPE(WeatherComponent::CloudRenderingType);
29
30 ENUM_TYPE_METADATA(WeatherComponent::CloudRenderingType, ENUM_VALUE(FULL, "Full Resolution"),
31 ENUM_VALUE(DOWNSCALED, "Downscaled Resolution"), ENUM_VALUE(REPROJECTED, "Reprojected"))
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 using CORE_NS::PropertyFlags;
43
44 class WeatherComponentManager final : public BaseManager<WeatherComponent, IWeatherComponentManager> {
45 BEGIN_PROPERTY(WeatherComponent, componentMetaData_)
46 #include <3d/ecs/components/weather_component.h>
47 END_PROPERTY();
48
49 public:
WeatherComponentManager(IEcs & ecs)50 explicit WeatherComponentManager(IEcs& ecs)
51 : BaseManager<WeatherComponent, IWeatherComponentManager>(ecs, CORE_NS::GetName<WeatherComponent>())
52 {}
53
54 ~WeatherComponentManager() = default;
55
PropertyCount() const56 size_t PropertyCount() const override
57 {
58 return BASE_NS::countof(componentMetaData_);
59 }
60
MetaData(size_t index) const61 const Property* MetaData(size_t index) const override
62 {
63 if (index < BASE_NS::countof(componentMetaData_)) {
64 return &componentMetaData_[index];
65 }
66 return nullptr;
67 }
68
MetaData() const69 array_view<const Property> MetaData() const override
70 {
71 return componentMetaData_;
72 }
73 };
74
IWeatherComponentManagerInstance(CORE_NS::IEcs & ecs)75 IComponentManager* IWeatherComponentManagerInstance(CORE_NS::IEcs& ecs)
76 {
77 return new WeatherComponentManager(ecs);
78 }
79
IWeatherComponentManagerDestroy(IComponentManager * instance)80 void IWeatherComponentManagerDestroy(IComponentManager* instance)
81 {
82 delete static_cast<WeatherComponentManager*>(instance);
83 }
84 CORE3D_END_NAMESPACE()
85