e18b78920e8324dfa478d11fb6b9b252dda58279
[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/internal/event/common/type-registry-impl.h>
24 #include <dali/internal/event/common/property-index-ranges.h>
25
26 namespace Dali
27 {
28
29 TypeRegistry::TypeRegistry()
30 {
31 }
32
33 TypeRegistry::~TypeRegistry()
34 {
35 }
36
37 TypeRegistry TypeRegistry::Get()
38 {
39   return TypeRegistry(Internal::TypeRegistry::Get());
40 }
41
42 Dali::TypeInfo TypeRegistry::GetTypeInfo( const std::string &uniqueTypeName )
43 {
44   return GetImplementation(*this).GetTypeInfo( uniqueTypeName );
45 }
46
47 Dali::TypeInfo TypeRegistry::GetTypeInfo( const std::type_info& registerType )
48 {
49   return GetImplementation(*this).GetTypeInfo( registerType );
50 }
51
52 TypeRegistry::NameContainer TypeRegistry::GetTypeNames() const
53 {
54   return GetImplementation(*this).GetTypeNames();
55 }
56
57 TypeRegistry::TypeRegistry(Internal::TypeRegistry* internal)
58 : BaseHandle(internal)
59 {
60 }
61
62 TypeRegistration::TypeRegistration( const std::type_info& registerType, const std::type_info& baseType,
63                                     TypeInfo::CreateFunction f )
64   : mReference(Internal::TypeRegistry::Get())
65 {
66   Internal::TypeRegistry *impl = Internal::TypeRegistry::Get();
67
68   if( impl->Register( registerType, baseType, f, false ) )
69   {
70     mName = impl->RegistrationName( registerType );
71   }
72 }
73
74 TypeRegistration::TypeRegistration( const std::type_info& registerType, const std::type_info& baseType,
75                                     TypeInfo::CreateFunction f, bool callCreateOnInit )
76   : mReference(Internal::TypeRegistry::Get())
77 {
78   Internal::TypeRegistry *impl = Internal::TypeRegistry::Get();
79
80   if( impl->Register( registerType, baseType, f, callCreateOnInit ) )
81   {
82     mName = impl->RegistrationName( registerType );
83   }
84 }
85
86 TypeRegistration::TypeRegistration( const std::string& name, const std::type_info& baseType,
87                                     TypeInfo::CreateFunction f )
88   : mReference(Internal::TypeRegistry::Get())
89 {
90   Internal::TypeRegistry *impl = Internal::TypeRegistry::Get();
91
92   if( impl->Register( name, baseType, f, false ) )
93   {
94     mName = name;
95   }
96 }
97
98
99 const std::string TypeRegistration::RegisteredName() const
100 {
101   return mName;
102 }
103
104 SignalConnectorType::SignalConnectorType( TypeRegistration& typeRegistration, const std::string& name, TypeInfo::SignalConnectorFunctionV2 func )
105 {
106   Internal::TypeRegistry::Get()->RegisterSignal( typeRegistration, name, func );
107 }
108
109 TypeAction::TypeAction( TypeRegistration &registered, const std::string &name, TypeInfo::ActionFunction f)
110 {
111   Internal::TypeRegistry::Get()->RegisterAction( registered, name, f );
112 }
113
114 PropertyRegistration::PropertyRegistration( TypeRegistration& registered, const std::string& name, Property::Index index, Property::Type type, TypeInfo::SetPropertyFunction setFunc, TypeInfo::GetPropertyFunction getFunc )
115 {
116   DALI_ASSERT_ALWAYS( ( index >= START_INDEX ) && ( index <= MAX_INDEX ) );
117
118   Internal::TypeRegistry::Get()->RegisterProperty( registered, name, index, type, setFunc, getFunc );
119 }
120
121 } // namespace Dali