[dali_1.0.32] Merge branch 'tizen'
[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 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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
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
18 // CLASS HEADER
19 #include <dali/public-api/object/type-registry.h>
20
21 // EXTERNAL INCLUDES
22
23 // INTERNAL INCLUDES
24 #include <dali/public-api/object/property-index-ranges.h>
25 #include <dali/internal/event/common/type-registry-impl.h>
26
27 namespace Dali
28 {
29
30 TypeRegistry::TypeRegistry()
31 {
32 }
33
34 TypeRegistry::~TypeRegistry()
35 {
36 }
37
38 TypeRegistry::TypeRegistry(const TypeRegistry& copy)
39 : BaseHandle(copy)
40 {
41 }
42
43 TypeRegistry& TypeRegistry::operator=(const TypeRegistry& rhs)
44 {
45   BaseHandle::operator=(rhs);
46   return *this;
47 }
48
49 TypeRegistry TypeRegistry::Get()
50 {
51   return TypeRegistry(Internal::TypeRegistry::Get());
52 }
53
54 Dali::TypeInfo TypeRegistry::GetTypeInfo( const std::string &uniqueTypeName )
55 {
56   return GetImplementation(*this).GetTypeInfo( uniqueTypeName );
57 }
58
59 Dali::TypeInfo TypeRegistry::GetTypeInfo( const std::type_info& registerType )
60 {
61   return GetImplementation(*this).GetTypeInfo( registerType );
62 }
63
64 TypeRegistry::NameContainer TypeRegistry::GetTypeNames() const
65 {
66   return GetImplementation(*this).GetTypeNames();
67 }
68
69 TypeRegistry::TypeRegistry(Internal::TypeRegistry* internal)
70 : BaseHandle(internal)
71 {
72 }
73
74 TypeRegistration::TypeRegistration( const std::type_info& registerType, const std::type_info& baseType,
75                                     TypeInfo::CreateFunction f )
76   : mReference(Internal::TypeRegistry::Get())
77 {
78   Internal::TypeRegistry *impl = Internal::TypeRegistry::Get();
79
80   if( impl->Register( registerType, baseType, f, false ) )
81   {
82     mName = impl->RegistrationName( registerType );
83   }
84 }
85
86 TypeRegistration::TypeRegistration( const std::type_info& registerType, const std::type_info& baseType,
87                                     TypeInfo::CreateFunction f, bool callCreateOnInit )
88   : mReference(Internal::TypeRegistry::Get())
89 {
90   Internal::TypeRegistry *impl = Internal::TypeRegistry::Get();
91
92   if( impl->Register( registerType, baseType, f, callCreateOnInit ) )
93   {
94     mName = impl->RegistrationName( registerType );
95   }
96 }
97
98 TypeRegistration::TypeRegistration( const std::string& name, const std::type_info& baseType,
99                                     TypeInfo::CreateFunction f )
100   : mReference(Internal::TypeRegistry::Get())
101 {
102   Internal::TypeRegistry *impl = Internal::TypeRegistry::Get();
103
104   if( impl->Register( name, baseType, f, false ) )
105   {
106     mName = name;
107   }
108 }
109
110
111 const std::string TypeRegistration::RegisteredName() const
112 {
113   return mName;
114 }
115
116 SignalConnectorType::SignalConnectorType( TypeRegistration& typeRegistration, const std::string& name, TypeInfo::SignalConnectorFunction func )
117 {
118   Internal::TypeRegistry::Get()->RegisterSignal( typeRegistration, name, func );
119 }
120
121 TypeAction::TypeAction( TypeRegistration &registered, const std::string &name, TypeInfo::ActionFunction f)
122 {
123   Internal::TypeRegistry::Get()->RegisterAction( registered, name, f );
124 }
125
126 PropertyRegistration::PropertyRegistration( TypeRegistration& registered, const std::string& name, Property::Index index, Property::Type type, TypeInfo::SetPropertyFunction setFunc, TypeInfo::GetPropertyFunction getFunc )
127 {
128   DALI_ASSERT_ALWAYS( ( index >= PROPERTY_REGISTRATION_START_INDEX ) && ( index <= PROPERTY_REGISTRATION_MAX_INDEX ) );
129
130   Internal::TypeRegistry::Get()->RegisterProperty( registered, name, index, type, setFunc, getFunc );
131 }
132
133 } // namespace Dali