2 * Copyright (c) 2020 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 #include <dali/public-api/object/type-registry.h>
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>
30 TypeRegistry::TypeRegistry()
34 TypeRegistry::~TypeRegistry()
38 TypeRegistry::TypeRegistry(const TypeRegistry& copy) = default;
40 TypeRegistry& TypeRegistry::operator=(const TypeRegistry& rhs) = default;
42 TypeRegistry::TypeRegistry(TypeRegistry&& rhs) = default;
44 TypeRegistry& TypeRegistry::operator=(TypeRegistry&& rhs) = default;
46 TypeRegistry TypeRegistry::Get()
48 return TypeRegistry(Internal::TypeRegistry::Get());
51 Dali::TypeInfo TypeRegistry::GetTypeInfo(const std::string& uniqueTypeName)
53 return Dali::TypeInfo(GetImplementation(*this).GetTypeInfo(uniqueTypeName).Get());
56 Dali::TypeInfo TypeRegistry::GetTypeInfo(const std::type_info& registerType)
58 return Dali::TypeInfo(GetImplementation(*this).GetTypeInfo(registerType).Get());
61 size_t TypeRegistry::GetTypeNameCount() const
63 return GetImplementation(*this).GetTypeNameCount();
66 std::string TypeRegistry::GetTypeName(size_t index) const
68 return GetImplementation(*this).GetTypeName(static_cast<uint32_t>(index));
71 TypeRegistry::TypeRegistry(Internal::TypeRegistry* internal)
72 : BaseHandle(internal)
76 TypeRegistration::TypeRegistration(const std::type_info& registerType, const std::type_info& baseType, TypeInfo::CreateFunction f)
77 : mReference(Internal::TypeRegistry::Get())
79 Internal::TypeRegistry* impl = Internal::TypeRegistry::Get();
81 mName = impl->Register(registerType, baseType, f, false);
84 TypeRegistration::TypeRegistration(const std::type_info& registerType, const std::type_info& baseType, TypeInfo::CreateFunction f, bool callCreateOnInit)
85 : mReference(Internal::TypeRegistry::Get())
87 Internal::TypeRegistry* impl = Internal::TypeRegistry::Get();
89 mName = impl->Register(registerType, baseType, f, callCreateOnInit);
92 TypeRegistration::TypeRegistration(const std::type_info& registerType, const std::type_info& baseType, TypeInfo::CreateFunction f, const DefaultPropertyMetadata& defaultProperties)
94 Internal::TypeRegistry* impl = Internal::TypeRegistry::Get();
96 mName = impl->Register(registerType, baseType, f, false, defaultProperties.propertyTable, defaultProperties.propertyCount);
99 TypeRegistration::TypeRegistration(std::string name, const std::type_info& baseType, TypeInfo::CreateFunction f)
100 : mReference(Internal::TypeRegistry::Get())
102 Internal::TypeRegistry* impl = Internal::TypeRegistry::Get();
104 mName = impl->Register(std::move(name), baseType, f, false);
107 const std::string& TypeRegistration::RegisteredName() const
112 SignalConnectorType::SignalConnectorType(TypeRegistration& typeRegistration, std::string name, TypeInfo::SignalConnectorFunction func)
114 Internal::TypeRegistry::Get()->RegisterSignal(typeRegistration, std::move(name), func);
117 TypeAction::TypeAction(TypeRegistration& registered, std::string name, TypeInfo::ActionFunction f)
119 Internal::TypeRegistry::Get()->RegisterAction(registered, std::move(name), f);
122 PropertyRegistration::PropertyRegistration(TypeRegistration& registered, std::string name, Property::Index index, Property::Type type, TypeInfo::SetPropertyFunction setFunc, TypeInfo::GetPropertyFunction getFunc)
124 DALI_ASSERT_ALWAYS((index >= PROPERTY_REGISTRATION_START_INDEX) && (index <= PROPERTY_REGISTRATION_MAX_INDEX));
126 Internal::TypeRegistry::Get()->RegisterProperty(registered, std::move(name), index, type, setFunc, getFunc);
129 AnimatablePropertyRegistration::AnimatablePropertyRegistration(TypeRegistration& registered, std::string name, Property::Index index, Property::Type type)
131 DALI_ASSERT_ALWAYS((index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX) && (index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX));
133 Internal::TypeRegistry::Get()->RegisterAnimatableProperty(registered, std::move(name), index, type);
136 AnimatablePropertyRegistration::AnimatablePropertyRegistration(TypeRegistration& registered, std::string name, Property::Index index, const Property::Value& value)
138 DALI_ASSERT_ALWAYS((index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX) && (index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX));
140 Internal::TypeRegistry::Get()->RegisterAnimatableProperty(registered, std::move(name), index, value);
143 AnimatablePropertyComponentRegistration::AnimatablePropertyComponentRegistration(TypeRegistration& registered, std::string name, Property::Index index, Property::Index baseIndex, uint32_t componentIndex)
145 DALI_ASSERT_ALWAYS((index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX) && (index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX));
147 Internal::TypeRegistry::Get()->RegisterAnimatablePropertyComponent(registered, std::move(name), index, baseIndex, componentIndex);
150 ChildPropertyRegistration::ChildPropertyRegistration(TypeRegistration& registered, std::string name, Property::Index index, Property::Type type)
152 DALI_ASSERT_ALWAYS((index >= CHILD_PROPERTY_REGISTRATION_START_INDEX) && (index <= CHILD_PROPERTY_REGISTRATION_MAX_INDEX));
154 Internal::TypeRegistry::Get()->RegisterChildProperty(registered, std::move(name), index, type);
157 ChildPropertyRegistration::ChildPropertyRegistration(std::string registered, std::string name, Property::Index index, Property::Type type)
159 DALI_ASSERT_ALWAYS((index >= CHILD_PROPERTY_REGISTRATION_START_INDEX) && (index <= CHILD_PROPERTY_REGISTRATION_MAX_INDEX));
161 Internal::TypeRegistry::Get()->RegisterChildProperty(std::move(registered), std::move(name), index, type);