Dali 3D User Interface Engine
type-registry-impl.h
Go to the documentation of this file.
1 #ifndef __DALI_INTERNAL_TYPE_REGISTRY_H__
2 #define __DALI_INTERNAL_TYPE_REGISTRY_H__
3 
4 /*
5  * Copyright (c) 2015 Samsung Electronics Co., Ltd.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  */
20 
21 // INTERNAL INCLUDES
27 
28 namespace Dali
29 {
30 
31 namespace Internal
32 {
33 
35 class TypeRegistry;
36 
37 /*
38 * @copydoc Dali::TypeRegistry
39 */
41 {
42 public:
46  static TypeRegistry *Get();
47 
48  /*
49  * @copydoc Dali::TypeRegistry::GetTypeInfo
50  */
51  Dali::TypeInfo GetTypeInfo( const std::string &uniqueTypeName );
52 
53  /*
54  * @copydoc Dali::TypeRegistry::GetTypeInfo
55  */
56  Dali::TypeInfo GetTypeInfo( const std::type_info& registerType );
57 
58  /*
59  * @copydoc Dali::TypeRegistry::GetTypeNameCount
60  */
61  size_t GetTypeNameCount() const;
62 
63  /*
64  * @copydoc Dali::TypeRegistry::GetTypeName
65  */
66  std::string GetTypeName(size_t index) const;
67 
68  /*
69  * Register a creation function under a unique name.
70  * @param [in] theTypeInfo Type info for the type to be registered
71  * @param [in] baseTypeInfo Type info for its base class
72  * @param [in] createInstance Instance creation function
73  * @param [in] callCreateOnInit If true call createInstance on dali initialisation
74  * @return true if the name could be registered.
75  */
76  bool Register( const std::type_info& theTypeInfo, const std::type_info& baseTypeInfo,
77  Dali::TypeInfo::CreateFunction createInstance, bool callCreateOnInit );
78 
79  /*
80  * Register a creation function under a unique name.
81  * @param [in] name The name type to be registered (must be unique)
82  * @param [in] baseTypeInfo Type info for its base class
83  * @param [in] createInstance Instance creation function
84  * @param [in] callCreateOnInit If true call createInstance on dali initialisation
85  * @return true if the name could be registered.
86  */
87  bool Register( const std::string& name, const std::type_info& baseTypeInfo,
88  Dali::TypeInfo::CreateFunction createInstance, bool callCreateOnInit );
89 
90  /*
91  * Register a signal connector function to a type
92  * @param [in] typeRegistration TypeRegistration object used to register the type
93  * @param [in] name Signal name
94  * @param [in] func Signal connector function
95  */
97 
98  /*
99  * Register an action function to a type
100  * @param [in] registered TypeRegistration object used to register the type
101  * @param [in] name Action name
102  * @param [in] f Action function
103  * @return true if registered
104  */
105  bool RegisterAction( TypeRegistration &registered, const std::string &name, Dali::TypeInfo::ActionFunction f);
106 
117  bool RegisterProperty( TypeRegistration& registered, const std::string& name, Property::Index index, Property::Type type, Dali::TypeInfo::SetPropertyFunction setFunc, Dali::TypeInfo::GetPropertyFunction getFunc );
118 
127  bool RegisterAnimatableProperty( TypeRegistration& registered, const std::string& name, Property::Index index, Property::Type type );
128 
137  bool RegisterAnimatableProperty( TypeRegistration& registered, const std::string& name, Property::Index index, const Property::Value& defaultValue );
138 
148  bool RegisterAnimatablePropertyComponent( TypeRegistration& registered, const std::string& name, Property::Index index, Property::Index baseIndex, unsigned int componentIndex );
149 
150  /*
151  * @copydoc Dali::Internal::TypeInfo::DoActionTo
152  * Walks all base types until it finds a doer.
153  */
154  bool DoActionTo( BaseObject * const object, const std::string &actionName, const Property::Map& properties);
155 
159  bool ConnectSignal( BaseObject* object, ConnectionTrackerInterface* connectionTracker, const std::string& signalName, FunctorDelegate* functor );
160 
161  /*
162  * Return the type info for a given BaseObject pointer
163  * @param [in] pBaseObject Pointer to a BaseObject
164  * @return TypeInfo for the BaseObject.
165  */
166  Dali::TypeInfo GetTypeInfo(const Dali::BaseObject * const pBaseObject);
167 
168  /*
169  * Calls any type creation functions that have been flagged as initialization functions
170  */
171  void CallInitFunctions(void) const;
172 
173 public:
174 
175  /*
176  * Return the name derived from type_info used to register the type
177  * @param [in] registerType Type info for the type to be registered
178  * @return registered name
179  */
180  static std::string RegistrationName( const std::type_info& registerType );
181 
182 private:
183  /*
184  * Map from type name to TypeInfo
185  */
186  typedef std::map<std::string, Dali::TypeInfo> RegistryMap;
188 
189  typedef std::vector<Dali::TypeInfo::CreateFunction> InitFunctions;
191 
192 private:
193  TypeRegistry();
194  ~TypeRegistry();
195 
200 
205 };
206 
207 
208 } // namespace Internal
209 
210 // Helpers for public-api forwarding methods
211 
213 {
214  DALI_ASSERT_ALWAYS(typeRegistry);
215 
216  BaseObject& handle = typeRegistry.GetBaseObject();
217 
218  return static_cast<Internal::TypeRegistry&>(handle);
219 }
220 
222 {
223  DALI_ASSERT_ALWAYS(typeRegistry);
224 
225  const BaseObject& handle = typeRegistry.GetBaseObject();
226 
227  return static_cast<const Internal::TypeRegistry&>(handle);
228 }
229 
230 } // namespace Dali
231 
232 #endif // __DALI_INTERNAL_TYPE_REGISTRY_H__
Dali Docs Home
Read more about Dali