• 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 #include <base/math/matrix.h>
16 #include <base/math/quaternion.h>
17 #include <base/math/vector.h>
18 #include <base/util/color.h>
19 
20 #include <meta/base/ids.h>
21 #include <meta/base/meta_types.h>
22 #include <meta/base/namespace.h>
23 #include <meta/base/time_span.h>
24 #include <meta/base/type_traits.h>
25 #include <meta/ext/any_builder.h>
26 #include <meta/interface/animation/intf_animation.h>
27 #include <meta/interface/animation/intf_animation_controller.h>
28 #include <meta/interface/curves/intf_curve_1d.h>
29 #include <meta/interface/detail/any.h>
30 #include <meta/interface/intf_attach.h>
31 #include <meta/interface/intf_object_registry.h>
32 #include <meta/interface/intf_startable.h>
33 #include <meta/interface/loaders/intf_content_loader.h>
34 
35 META_BEGIN_NAMESPACE()
36 
37 // clang-format off
38 using BasicTypes = TypeList<
39     float,
40     double,
41     bool,
42     uint8_t,
43     uint16_t,
44     uint32_t,
45     uint64_t,
46     int8_t,
47     int16_t,
48     int32_t,
49     int64_t,
50     TypeId,
51     ObjectId,
52     InstanceId,
53     BASE_NS::Uid,
54     BASE_NS::string,
55     BASE_NS::Math::Vec2,
56     BASE_NS::Math::UVec2,
57     BASE_NS::Math::IVec2,
58     BASE_NS::Math::Vec3,
59     BASE_NS::Math::UVec3,
60     BASE_NS::Math::IVec3,
61     BASE_NS::Math::Vec4,
62     BASE_NS::Math::UVec4,
63     BASE_NS::Math::IVec4,
64     BASE_NS::Math::Quat,
65     BASE_NS::Math::Mat3X3,
66     BASE_NS::Math::Mat4X4,
67     BASE_NS::Color,
68     TimeSpan
69     >;
70 using ObjectTypes = TypeList<
71     SharedPtrIInterface,
72     SharedPtrConstIInterface,
73     WeakPtrIInterface,
74     WeakPtrConstIInterface,
75     IObject::Ptr,
76     IObject::ConstPtr,
77     IObject::WeakPtr,
78     IObject::ConstWeakPtr,
79     IAny::Ptr,
80     IAny::ConstPtr,
81     IAny::WeakPtr,
82     IAny::ConstWeakPtr,
83     IValue::Ptr,
84     IValue::ConstPtr,
85     IValue::WeakPtr,
86     IValue::ConstWeakPtr,
87     IContentLoader::Ptr,
88     IProperty::Ptr,
89     IProperty::ConstPtr,
90     IProperty::WeakPtr,
91     IProperty::ConstWeakPtr,
92     IAnimation::Ptr,
93     IAnimation::ConstPtr,
94     IAnimation::WeakPtr,
95     IAnimation::ConstWeakPtr,
96     IAnimationController::WeakPtr,
97     ICurve1D::Ptr,
98     IAttach::Ptr,
99     IAttach::ConstPtr,
100     IAttach::WeakPtr,
101     IAttach::ConstWeakPtr,
102     IFunction::Ptr,
103     IFunction::ConstPtr,
104     IFunction::WeakPtr,
105     IFunction::ConstWeakPtr
106     >;
107 // clang-format on
108 
109 namespace Internal {
110 
111 template<typename... List>
RegisterTypes(IPropertyRegister & pr,TypeList<List...>)112 static void RegisterTypes(IPropertyRegister& pr, TypeList<List...>)
113 {
114     (pr.RegisterAny(CreateShared<DefaultAnyBuilder<Any<List>>>()), ...);
115     (pr.RegisterAny(CreateShared<DefaultAnyBuilder<ArrayAny<List>>>()), ...);
116 }
117 
118 template<typename... List>
UnregisterTypes(IPropertyRegister & pr,TypeList<List...>)119 static void UnregisterTypes(IPropertyRegister& pr, TypeList<List...>)
120 {
121     (pr.UnregisterAny(ArrayAny<List>::StaticGetClassId()), ...);
122     (pr.UnregisterAny(Any<List>::StaticGetClassId()), ...);
123 }
124 
RegisterAnys(IObjectRegistry & registry)125 void RegisterAnys(IObjectRegistry& registry)
126 {
127     auto& pr = registry.GetPropertyRegister();
128     RegisterTypes(pr, BasicTypes {});
129     RegisterTypes(pr, ObjectTypes {});
130 
131     RegisterTypeForBuiltinAny<StartableState>();
132     RegisterTypeForBuiltinAny<StartBehavior>();
133 }
134 
UnRegisterAnys(IObjectRegistry & registry)135 void UnRegisterAnys(IObjectRegistry& registry)
136 {
137     auto& pr = registry.GetPropertyRegister();
138     UnregisterTypes(pr, ObjectTypes {});
139     UnregisterTypes(pr, BasicTypes {});
140 
141     UnregisterTypeForBuiltinAny<StartableState>();
142     UnregisterTypeForBuiltinAny<StartBehavior>();
143 }
144 
145 } // namespace Internal
146 META_END_NAMESPACE()
147