1 #ifndef __DALI_INTERNAL_TYPE_REGISTRY_H__
2 #define __DALI_INTERNAL_TYPE_REGISTRY_H__
5 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
7 // Licensed under the Flora License, Version 1.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
11 // http://floralicense.org/license/
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.
21 #include <dali/public-api/common/map-wrapper.h>
22 #include <dali/public-api/object/type-registry.h>
23 #include <dali/public-api/object/base-handle.h>
24 #include <dali/public-api/object/base-object.h>
25 #include <dali/internal/event/common/type-info-impl.h>
33 ////////////////////////////////////////////////////////////////////////////////
37 * @copydoc Dali::TypeRegistry
39 class TypeRegistry : public Dali::BaseObject
43 * Get the TypeRegistry
45 static TypeRegistry *Get();
48 * @copydoc Dali::TypeRegistry::GetTypeInfo
50 Dali::TypeInfo GetTypeInfo( const std::string &uniqueTypeName );
53 * @copydoc Dali::TypeRegistry::GetTypeInfo
55 Dali::TypeInfo GetTypeInfo( const std::type_info& registerType );
58 * @copydoc Dali::TypeRegistry::GetTypeNames
60 Dali::TypeRegistry::NameContainer GetTypeNames() const;
63 * Register a creation function under a unique name.
64 * @param [in] theTypeInfo Type info for the type to be registered
65 * @param [in] baseTypeInfo Type info for its base class
66 * @param [in] createInstance Instance creation function
67 * @param [in] callCreateOnInit If true call createInstance on dali initialisation
68 * @return true if the name could be registered.
70 bool Register( const std::type_info& theTypeInfo, const std::type_info& baseTypeInfo,
71 Dali::TypeInfo::CreateFunction createInstance, bool callCreateOnInit );
74 * Register a creation function under a unique name.
75 * @param [in] name The name type to be registered (must be unique)
76 * @param [in] baseTypeInfo Type info for its base class
77 * @param [in] createInstance Instance creation function
78 * @param [in] callCreateOnInit If true call createInstance on dali initialisation
79 * @return true if the name could be registered.
81 bool Register( const std::string& name, const std::type_info& baseTypeInfo,
82 Dali::TypeInfo::CreateFunction createInstance, bool callCreateOnInit );
85 * Register a signal connector function to a type
86 * @param [in] typeRegistration TypeRegistration object used to register the type
87 * @param [in] name Signal name
88 * @param [in] func Signal connector function
90 void RegisterSignal( TypeRegistration& typeRegistration, const std::string& name, Dali::TypeInfo::SignalConnectorFunctionV2 func );
93 * Register an action function to a type
94 * @param [in] registered TypeRegistration object used to register the type
95 * @param [in] name Action name
96 * @param [in] f Action function
97 * @return true if registered
99 bool RegisterAction( TypeRegistration ®istered, const std::string &name, Dali::TypeInfo::ActionFunction f);
102 * @copydoc Dali::Internal::TypeInfo::DoActionTo
103 * Walks all base types until it finds a doer.
105 bool DoActionTo( BaseObject * const object, const std::string &actionName, const std::vector<Property::Value> &properties);
108 * @copydoc Dali::BaseHandle::ConnectSignal()
110 bool ConnectSignal( BaseObject* object, ConnectionTrackerInterface* connectionTracker, const std::string& signalName, FunctorDelegate* functor );
113 * Return the type info for a given BaseObject pointer
114 * @param [in] pBaseObject Pointer to a BaseObject
115 * @return TypeInfo for the BaseObject.
117 Dali::TypeInfo GetTypeInfo(Dali::BaseObject * const pBaseObject);
120 * Calls any type creation functions that have been flagged as initialization functions
122 void CallInitFunctions(void) const;
127 * Return the name derived from type_info used to register the type
128 * @param [in] registerType Type info for the type to be registered
129 * @return registered name
131 static std::string RegistrationName( const std::type_info& registerType );
135 * Map from type name to TypeInfo
137 typedef std::map<std::string, Dali::TypeInfo> RegistryMap;
138 RegistryMap mRegistryLut;
140 typedef std::vector<Dali::TypeInfo::CreateFunction> InitFunctions;
141 InitFunctions mInitFunctions;
147 TypeRegistry(TypeRegistry &);
148 TypeRegistry &operator()(const TypeRegistry &);
152 } // namespace Internal
154 // Helpers for public-api forwarding methods
156 inline Internal::TypeRegistry& GetImplementation(Dali::TypeRegistry& typeRegistry)
158 DALI_ASSERT_ALWAYS(typeRegistry);
160 BaseObject& handle = typeRegistry.GetBaseObject();
162 return static_cast<Internal::TypeRegistry&>(handle);
165 inline const Internal::TypeRegistry& GetImplementation(const Dali::TypeRegistry& typeRegistry)
167 DALI_ASSERT_ALWAYS(typeRegistry);
169 const BaseObject& handle = typeRegistry.GetBaseObject();
171 return static_cast<const Internal::TypeRegistry&>(handle);
176 #endif // __DALI_INTERNAL_TYPE_REGISTRY_H__