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