[SRUK] Initial copy from Tizen 2.2 version
[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
25 namespace Dali
26 {
27
28 TypeRegistry::TypeRegistry()
29 {
30 }
31
32 TypeRegistry::~TypeRegistry()
33 {
34 }
35
36 TypeRegistry TypeRegistry::Get()
37 {
38   return TypeRegistry(Internal::TypeRegistry::Get());
39 }
40
41 Dali::TypeInfo TypeRegistry::GetTypeInfo( const std::string &uniqueTypeName )
42 {
43   return GetImplementation(*this).GetTypeInfo( uniqueTypeName );
44 }
45
46 Dali::TypeInfo TypeRegistry::GetTypeInfo( const std::type_info& registerType )
47 {
48   return GetImplementation(*this).GetTypeInfo( registerType );
49 }
50
51 TypeRegistry::NameContainer TypeRegistry::GetTypeNames() const
52 {
53   return GetImplementation(*this).GetTypeNames();
54 }
55
56 TypeRegistry::TypeRegistry(Internal::TypeRegistry* internal)
57 : BaseHandle(internal)
58 {
59 }
60
61 TypeRegistration::TypeRegistration( const std::type_info& registerType, const std::type_info& baseType,
62                                     TypeInfo::CreateFunction f )
63   : mReference(Internal::TypeRegistry::Get())
64 {
65   Internal::TypeRegistry *impl = Internal::TypeRegistry::Get();
66
67   if( impl->Register( registerType, baseType, f, false ) )
68   {
69     mName = impl->RegistrationName( registerType );
70   }
71 }
72
73 TypeRegistration::TypeRegistration( const std::type_info& registerType, const std::type_info& baseType,
74                                     TypeInfo::CreateFunction f, bool callCreateOnInit )
75   : mReference(Internal::TypeRegistry::Get())
76 {
77   Internal::TypeRegistry *impl = Internal::TypeRegistry::Get();
78
79   if( impl->Register( registerType, baseType, f, callCreateOnInit ) )
80   {
81     mName = impl->RegistrationName( registerType );
82   }
83 }
84
85 TypeRegistration::TypeRegistration( const std::string& name, const std::type_info& baseType,
86                                     TypeInfo::CreateFunction f )
87   : mReference(Internal::TypeRegistry::Get())
88 {
89   Internal::TypeRegistry *impl = Internal::TypeRegistry::Get();
90
91   if( impl->Register( name, baseType, f, false ) )
92   {
93     mName = name;
94   }
95 }
96
97
98 const std::string TypeRegistration::RegisteredName() const
99 {
100   return mName;
101 }
102
103 SignalConnectorType::SignalConnectorType( TypeRegistration& typeRegistration, const std::string& name, TypeInfo::SignalConnectorFunctionV2 func )
104 {
105   Internal::TypeRegistry::Get()->RegisterSignal( typeRegistration, name, func );
106 }
107
108 TypeAction::TypeAction( TypeRegistration &registered, const std::string &name, TypeInfo::ActionFunction f)
109 {
110   Internal::TypeRegistry::Get()->RegisterAction( registered, name, f );
111 }
112
113 } // namespace Dali