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() = default;
32 TypeRegistry::~TypeRegistry() = default;
34 TypeRegistry::TypeRegistry(const TypeRegistry& copy) = default;
36 TypeRegistry& TypeRegistry::operator=(const TypeRegistry& rhs) = default;
38 TypeRegistry::TypeRegistry(TypeRegistry&& rhs) = default;
40 TypeRegistry& TypeRegistry::operator=(TypeRegistry&& rhs) = default;
42 TypeRegistry TypeRegistry::Get()
44 return TypeRegistry(Internal::TypeRegistry::Get());
47 Dali::TypeInfo TypeRegistry::GetTypeInfo(const std::string& uniqueTypeName)
49 return Dali::TypeInfo(GetImplementation(*this).GetTypeInfo(uniqueTypeName).Get());
52 Dali::TypeInfo TypeRegistry::GetTypeInfo(const std::type_info& registerType)
54 return Dali::TypeInfo(GetImplementation(*this).GetTypeInfo(registerType).Get());
57 size_t TypeRegistry::GetTypeNameCount() const
59 return GetImplementation(*this).GetTypeNameCount();
62 std::string TypeRegistry::GetTypeName(size_t index) const
64 return GetImplementation(*this).GetTypeName(static_cast<uint32_t>(index));
67 TypeRegistry::TypeRegistry(Internal::TypeRegistry* internal)
68 : BaseHandle(internal)
72 TypeRegistration::TypeRegistration(const std::type_info& registerType, const std::type_info& baseType, TypeInfo::CreateFunction f)
73 : mReference(Internal::TypeRegistry::Get())
75 Internal::TypeRegistry* impl = Internal::TypeRegistry::Get();
77 mName = impl->Register(registerType, baseType, f, false);
80 TypeRegistration::TypeRegistration(const std::type_info& registerType, const std::type_info& baseType, TypeInfo::CreateFunction f, bool callCreateOnInit)
81 : mReference(Internal::TypeRegistry::Get())
83 Internal::TypeRegistry* impl = Internal::TypeRegistry::Get();
85 mName = impl->Register(registerType, baseType, f, callCreateOnInit);
88 TypeRegistration::TypeRegistration(const std::type_info& registerType, const std::type_info& baseType, TypeInfo::CreateFunction f, const DefaultPropertyMetadata& defaultProperties)
90 Internal::TypeRegistry* impl = Internal::TypeRegistry::Get();
92 mName = impl->Register(registerType, baseType, f, false, defaultProperties.propertyTable, defaultProperties.propertyCount);
95 TypeRegistration::TypeRegistration(std::string name, const std::type_info& baseType, TypeInfo::CreateFunction f)
96 : mReference(Internal::TypeRegistry::Get())
98 Internal::TypeRegistry* impl = Internal::TypeRegistry::Get();
100 mName = impl->Register(std::move(name), baseType, f, false);
103 const std::string& TypeRegistration::RegisteredName() const
108 SignalConnectorType::SignalConnectorType(TypeRegistration& typeRegistration, std::string name, TypeInfo::SignalConnectorFunction func)
110 Internal::TypeRegistry::Get()->RegisterSignal(typeRegistration, std::move(name), func);
113 TypeAction::TypeAction(TypeRegistration& registered, std::string name, TypeInfo::ActionFunction f)
115 Internal::TypeRegistry::Get()->RegisterAction(registered, std::move(name), f);
118 PropertyRegistration::PropertyRegistration(TypeRegistration& registered, std::string name, Property::Index index, Property::Type type, TypeInfo::SetPropertyFunction setFunc, TypeInfo::GetPropertyFunction getFunc)
120 DALI_ASSERT_ALWAYS((index >= PROPERTY_REGISTRATION_START_INDEX) && (index <= PROPERTY_REGISTRATION_MAX_INDEX));
122 Internal::TypeRegistry::Get()->RegisterProperty(registered, std::move(name), index, type, setFunc, getFunc);
125 AnimatablePropertyRegistration::AnimatablePropertyRegistration(TypeRegistration& registered, std::string name, Property::Index index, Property::Type type)
127 DALI_ASSERT_ALWAYS((index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX) && (index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX));
129 Internal::TypeRegistry::Get()->RegisterAnimatableProperty(registered, std::move(name), index, type);
132 AnimatablePropertyRegistration::AnimatablePropertyRegistration(TypeRegistration& registered, std::string name, Property::Index index, const Property::Value& value)
134 DALI_ASSERT_ALWAYS((index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX) && (index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX));
136 Internal::TypeRegistry::Get()->RegisterAnimatableProperty(registered, std::move(name), index, value);
139 AnimatablePropertyComponentRegistration::AnimatablePropertyComponentRegistration(TypeRegistration& registered, std::string name, Property::Index index, Property::Index baseIndex, uint32_t componentIndex)
141 DALI_ASSERT_ALWAYS((index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX) && (index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX));
143 Internal::TypeRegistry::Get()->RegisterAnimatablePropertyComponent(registered, std::move(name), index, baseIndex, componentIndex);
146 ChildPropertyRegistration::ChildPropertyRegistration(TypeRegistration& registered, std::string name, Property::Index index, Property::Type type)
148 DALI_ASSERT_ALWAYS((index >= CHILD_PROPERTY_REGISTRATION_START_INDEX) && (index <= CHILD_PROPERTY_REGISTRATION_MAX_INDEX));
150 Internal::TypeRegistry::Get()->RegisterChildProperty(registered, std::move(name), index, type);
153 ChildPropertyRegistration::ChildPropertyRegistration(std::string registered, std::string name, Property::Index index, Property::Type type)
155 DALI_ASSERT_ALWAYS((index >= CHILD_PROPERTY_REGISTRATION_START_INDEX) && (index <= CHILD_PROPERTY_REGISTRATION_MAX_INDEX));
157 Internal::TypeRegistry::Get()->RegisterChildProperty(registered, std::move(name), index, type);