Clean up the code to build successfully on macOS
[platform/core/uifw/dali-core.git] / dali / public-api / object / type-registry.cpp
1 /*
2  * Copyright (c) 2020 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 // CLASS HEADER
19 #include <dali/public-api/object/type-registry.h>
20
21 // EXTERNAL INCLUDES
22
23 // INTERNAL INCLUDES
24 #include <dali/internal/event/common/type-registry-impl.h>
25 #include <dali/internal/event/object/default-property-metadata.h>
26 #include <dali/public-api/object/property-index-ranges.h>
27
28 namespace Dali
29 {
30 TypeRegistry::TypeRegistry()
31 {
32 }
33
34 TypeRegistry::~TypeRegistry()
35 {
36 }
37
38 TypeRegistry::TypeRegistry(const TypeRegistry& copy) = default;
39
40 TypeRegistry& TypeRegistry::operator=(const TypeRegistry& rhs) = default;
41
42 TypeRegistry::TypeRegistry(TypeRegistry&& rhs) = default;
43
44 TypeRegistry& TypeRegistry::operator=(TypeRegistry&& rhs) = default;
45
46 TypeRegistry TypeRegistry::Get()
47 {
48   return TypeRegistry(Internal::TypeRegistry::Get());
49 }
50
51 Dali::TypeInfo TypeRegistry::GetTypeInfo(const std::string& uniqueTypeName)
52 {
53   return Dali::TypeInfo(GetImplementation(*this).GetTypeInfo(uniqueTypeName).Get());
54 }
55
56 Dali::TypeInfo TypeRegistry::GetTypeInfo(const std::type_info& registerType)
57 {
58   return Dali::TypeInfo(GetImplementation(*this).GetTypeInfo(registerType).Get());
59 }
60
61 size_t TypeRegistry::GetTypeNameCount() const
62 {
63   return GetImplementation(*this).GetTypeNameCount();
64 }
65
66 std::string TypeRegistry::GetTypeName(size_t index) const
67 {
68   return GetImplementation(*this).GetTypeName(static_cast<uint32_t>(index));
69 }
70
71 TypeRegistry::TypeRegistry(Internal::TypeRegistry* internal)
72 : BaseHandle(internal)
73 {
74 }
75
76 TypeRegistration::TypeRegistration(const std::type_info& registerType, const std::type_info& baseType, TypeInfo::CreateFunction f)
77 : mReference(Internal::TypeRegistry::Get())
78 {
79   Internal::TypeRegistry* impl = Internal::TypeRegistry::Get();
80
81   mName = impl->Register(registerType, baseType, f, false);
82 }
83
84 TypeRegistration::TypeRegistration(const std::type_info& registerType, const std::type_info& baseType, TypeInfo::CreateFunction f, bool callCreateOnInit)
85 : mReference(Internal::TypeRegistry::Get())
86 {
87   Internal::TypeRegistry* impl = Internal::TypeRegistry::Get();
88
89   mName = impl->Register(registerType, baseType, f, callCreateOnInit);
90 }
91
92 TypeRegistration::TypeRegistration(const std::type_info& registerType, const std::type_info& baseType, TypeInfo::CreateFunction f, const DefaultPropertyMetadata& defaultProperties)
93 {
94   Internal::TypeRegistry* impl = Internal::TypeRegistry::Get();
95
96   mName = impl->Register(registerType, baseType, f, false, defaultProperties.propertyTable, defaultProperties.propertyCount);
97 }
98
99 TypeRegistration::TypeRegistration(std::string name, const std::type_info& baseType, TypeInfo::CreateFunction f)
100 : mReference(Internal::TypeRegistry::Get())
101 {
102   Internal::TypeRegistry* impl = Internal::TypeRegistry::Get();
103
104   mName = impl->Register(std::move(name), baseType, f, false);
105 }
106
107 const std::string& TypeRegistration::RegisteredName() const
108 {
109   return mName;
110 }
111
112 SignalConnectorType::SignalConnectorType(TypeRegistration& typeRegistration, std::string name, TypeInfo::SignalConnectorFunction func)
113 {
114   Internal::TypeRegistry::Get()->RegisterSignal(typeRegistration, std::move(name), func);
115 }
116
117 TypeAction::TypeAction(TypeRegistration& registered, std::string name, TypeInfo::ActionFunction f)
118 {
119   Internal::TypeRegistry::Get()->RegisterAction(registered, std::move(name), f);
120 }
121
122 PropertyRegistration::PropertyRegistration(TypeRegistration& registered, std::string name, Property::Index index, Property::Type type, TypeInfo::SetPropertyFunction setFunc, TypeInfo::GetPropertyFunction getFunc)
123 {
124   DALI_ASSERT_ALWAYS((index >= PROPERTY_REGISTRATION_START_INDEX) && (index <= PROPERTY_REGISTRATION_MAX_INDEX));
125
126   Internal::TypeRegistry::Get()->RegisterProperty(registered, std::move(name), index, type, setFunc, getFunc);
127 }
128
129 AnimatablePropertyRegistration::AnimatablePropertyRegistration(TypeRegistration& registered, std::string name, Property::Index index, Property::Type type)
130 {
131   DALI_ASSERT_ALWAYS((index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX) && (index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX));
132
133   Internal::TypeRegistry::Get()->RegisterAnimatableProperty(registered, std::move(name), index, type);
134 }
135
136 AnimatablePropertyRegistration::AnimatablePropertyRegistration(TypeRegistration& registered, std::string name, Property::Index index, const Property::Value& value)
137 {
138   DALI_ASSERT_ALWAYS((index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX) && (index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX));
139
140   Internal::TypeRegistry::Get()->RegisterAnimatableProperty(registered, std::move(name), index, value);
141 }
142
143 AnimatablePropertyComponentRegistration::AnimatablePropertyComponentRegistration(TypeRegistration& registered, std::string name, Property::Index index, Property::Index baseIndex, uint32_t componentIndex)
144 {
145   DALI_ASSERT_ALWAYS((index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX) && (index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX));
146
147   Internal::TypeRegistry::Get()->RegisterAnimatablePropertyComponent(registered, std::move(name), index, baseIndex, componentIndex);
148 }
149
150 ChildPropertyRegistration::ChildPropertyRegistration(TypeRegistration& registered, std::string name, Property::Index index, Property::Type type)
151 {
152   DALI_ASSERT_ALWAYS((index >= CHILD_PROPERTY_REGISTRATION_START_INDEX) && (index <= CHILD_PROPERTY_REGISTRATION_MAX_INDEX));
153
154   Internal::TypeRegistry::Get()->RegisterChildProperty(registered, std::move(name), index, type);
155 }
156
157 ChildPropertyRegistration::ChildPropertyRegistration(std::string registered, std::string name, Property::Index index, Property::Type type)
158 {
159   DALI_ASSERT_ALWAYS((index >= CHILD_PROPERTY_REGISTRATION_START_INDEX) && (index <= CHILD_PROPERTY_REGISTRATION_MAX_INDEX));
160
161   Internal::TypeRegistry::Get()->RegisterChildProperty(std::move(registered), std::move(name), index, type);
162 }
163
164 } // namespace Dali