Revert "License conversion from Flora to Apache 2.0"
[platform/core/uifw/dali-core.git] / dali / public-api / object / type-registry.cpp
1 //
2 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
3 //
4 // Licensed under the Flora License, Version 1.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://floralicense.org/license/
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 // CLASS HEADER
18 #include <dali/public-api/object/type-registry.h>
19
20 // EXTERNAL INCLUDES
21
22 // INTERNAL INCLUDES
23 #include <dali/public-api/object/property-index.h>
24 #include <dali/internal/event/common/type-registry-impl.h>
25 #include <dali/internal/event/common/property-index-ranges.h>
26
27 namespace Dali
28 {
29
30 TypeRegistry::TypeRegistry()
31 {
32 }
33
34 TypeRegistry::~TypeRegistry()
35 {
36 }
37
38 TypeRegistry TypeRegistry::Get()
39 {
40   return TypeRegistry(Internal::TypeRegistry::Get());
41 }
42
43 Dali::TypeInfo TypeRegistry::GetTypeInfo( const std::string &uniqueTypeName )
44 {
45   return GetImplementation(*this).GetTypeInfo( uniqueTypeName );
46 }
47
48 Dali::TypeInfo TypeRegistry::GetTypeInfo( const std::type_info& registerType )
49 {
50   return GetImplementation(*this).GetTypeInfo( registerType );
51 }
52
53 TypeRegistry::NameContainer TypeRegistry::GetTypeNames() const
54 {
55   return GetImplementation(*this).GetTypeNames();
56 }
57
58 TypeRegistry::TypeRegistry(Internal::TypeRegistry* internal)
59 : BaseHandle(internal)
60 {
61 }
62
63 TypeRegistration::TypeRegistration( const std::type_info& registerType, const std::type_info& baseType,
64                                     TypeInfo::CreateFunction f )
65   : mReference(Internal::TypeRegistry::Get())
66 {
67   Internal::TypeRegistry *impl = Internal::TypeRegistry::Get();
68
69   if( impl->Register( registerType, baseType, f, false ) )
70   {
71     mName = impl->RegistrationName( registerType );
72   }
73 }
74
75 TypeRegistration::TypeRegistration( const std::type_info& registerType, const std::type_info& baseType,
76                                     TypeInfo::CreateFunction f, bool callCreateOnInit )
77   : mReference(Internal::TypeRegistry::Get())
78 {
79   Internal::TypeRegistry *impl = Internal::TypeRegistry::Get();
80
81   if( impl->Register( registerType, baseType, f, callCreateOnInit ) )
82   {
83     mName = impl->RegistrationName( registerType );
84   }
85 }
86
87 TypeRegistration::TypeRegistration( const std::string& name, const std::type_info& baseType,
88                                     TypeInfo::CreateFunction f )
89   : mReference(Internal::TypeRegistry::Get())
90 {
91   Internal::TypeRegistry *impl = Internal::TypeRegistry::Get();
92
93   if( impl->Register( name, baseType, f, false ) )
94   {
95     mName = name;
96   }
97 }
98
99
100 const std::string TypeRegistration::RegisteredName() const
101 {
102   return mName;
103 }
104
105 SignalConnectorType::SignalConnectorType( TypeRegistration& typeRegistration, const std::string& name, TypeInfo::SignalConnectorFunctionV2 func )
106 {
107   Internal::TypeRegistry::Get()->RegisterSignal( typeRegistration, name, func );
108 }
109
110 TypeAction::TypeAction( TypeRegistration &registered, const std::string &name, TypeInfo::ActionFunction f)
111 {
112   Internal::TypeRegistry::Get()->RegisterAction( registered, name, f );
113 }
114
115 PropertyRegistration::PropertyRegistration( TypeRegistration& registered, const std::string& name, Property::Index index, Property::Type type, TypeInfo::SetPropertyFunction setFunc, TypeInfo::GetPropertyFunction getFunc )
116 {
117   DALI_ASSERT_ALWAYS( ( index >= PROPERTY_REGISTRATION_START_INDEX ) && ( index <= PROPERTY_REGISTRATION_MAX_INDEX ) );
118
119   Internal::TypeRegistry::Get()->RegisterProperty( registered, name, index, type, setFunc, getFunc );
120 }
121
122 } // namespace Dali