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 * Register an event-thread only property with a type
103 * @param [in] registered TypeRegistration object used to register the type
104 * @param [in] name Property name
105 * @param [in] index Property index
106 * @param [in] type Property type
107 * @param [in] setFunc The function to set the property (Can be NULL).
108 * @param [in] getFunc The function to get the value of a property.
109 * @return true if registered
111 bool RegisterProperty( TypeRegistration& registered, const std::string& name, Property::Index index, Property::Type type, Dali::TypeInfo::SetPropertyFunction setFunc, Dali::TypeInfo::GetPropertyFunction getFunc );
114 * @copydoc Dali::Internal::TypeInfo::DoActionTo
115 * Walks all base types until it finds a doer.
117 bool DoActionTo( BaseObject * const object, const std::string &actionName, const std::vector<Property::Value> &properties);
120 * @copydoc Dali::BaseHandle::ConnectSignal()
122 bool ConnectSignal( BaseObject* object, ConnectionTrackerInterface* connectionTracker, const std::string& signalName, FunctorDelegate* functor );
125 * Return the type info for a given BaseObject pointer
126 * @param [in] pBaseObject Pointer to a BaseObject
127 * @return TypeInfo for the BaseObject.
129 Dali::TypeInfo GetTypeInfo(const Dali::BaseObject * const pBaseObject);
132 * Calls any type creation functions that have been flagged as initialization functions
134 void CallInitFunctions(void) const;
139 * Return the name derived from type_info used to register the type
140 * @param [in] registerType Type info for the type to be registered
141 * @return registered name
143 static std::string RegistrationName( const std::type_info& registerType );
147 * Map from type name to TypeInfo
149 typedef std::map<std::string, Dali::TypeInfo> RegistryMap;
150 RegistryMap mRegistryLut;
152 typedef std::vector<Dali::TypeInfo::CreateFunction> InitFunctions;
153 InitFunctions mInitFunctions;
160 * @brief Undefined Copy Constructor
162 TypeRegistry(TypeRegistry &);
165 * @brief Undefined Assignment Operator
167 TypeRegistry& operator=(const TypeRegistry &);
171 } // namespace Internal
173 // Helpers for public-api forwarding methods
175 inline Internal::TypeRegistry& GetImplementation(Dali::TypeRegistry& typeRegistry)
177 DALI_ASSERT_ALWAYS(typeRegistry);
179 BaseObject& handle = typeRegistry.GetBaseObject();
181 return static_cast<Internal::TypeRegistry&>(handle);
184 inline const Internal::TypeRegistry& GetImplementation(const Dali::TypeRegistry& typeRegistry)
186 DALI_ASSERT_ALWAYS(typeRegistry);
188 const BaseObject& handle = typeRegistry.GetBaseObject();
190 return static_cast<const Internal::TypeRegistry&>(handle);
195 #endif // __DALI_INTERNAL_TYPE_REGISTRY_H__