1 #ifndef __DALI_TYPE_INFO_H__
2 #define __DALI_TYPE_INFO_H__
5 * Copyright (c) 2018 Samsung Electronics Co., Ltd.
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
23 #include <dali/public-api/object/base-handle.h>
24 #include <dali/public-api/common/vector-wrapper.h>
29 * @addtogroup dali_core_object
33 class ConnectionTrackerInterface;
34 class FunctorDelegate;
36 namespace Internal DALI_INTERNAL
42 * @brief TypeInfo class for instantiation of registered types and introspection of
43 * their actions and signals.
45 * See TypeRegistry for methods of type registration and TypeInfo retrieval.
48 class DALI_IMPORT_API TypeInfo : public BaseHandle
51 typedef BaseHandle (*CreateFunction)(); ///< Function signature for creating an instance of the associated object type. @SINCE_1_0.0
53 typedef bool (*ActionFunction)(BaseObject*, const std::string&, const Property::Map&); ///< Function signature for creating scriptable actions @SINCE_1_0.0
56 * @brief Connects a callback function with the object's signals.
59 * @param[in] object The object providing the signal
60 * @param[in] tracker Used to disconnect the signal
61 * @param[in] signalName The signal to connect to
62 * @param[in] functor A newly allocated FunctorDelegate
63 * @return True if the signal was connected
64 * @post If a signal was connected, ownership of functor was passed to CallbackBase. Otherwise the caller is responsible for deleting the unused functor.
66 typedef bool (*SignalConnectorFunction)(BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor);
69 * @brief Callback to set an event-thread only property.
72 * @param[in] object The object whose property should be set
73 * @param[in] index The index of the property being set
74 * @param[in] value The new value of the property for the object specified
75 * @see PropertyRegistration.
77 typedef void (*SetPropertyFunction)( BaseObject* object, Property::Index index, const Property::Value& value );
80 * @brief Callback to get the value of an event-thread only property.
83 * @param[in] object The object whose property value is required
84 * @param[in] index The index of the property required
85 * @return The current value of the property for the object specified
86 * @see PropertyRegistration.
88 typedef Property::Value (*GetPropertyFunction)( BaseObject* object, Property::Index index );
91 * @brief Allows the creation of an empty TypeInfo handle.
99 * This is non-virtual since derived Handle types must not contain data or virtual methods.
105 * @brief This copy constructor is required for (smart) pointer semantics.
108 * @param[in] handle A reference to the copied handle
110 TypeInfo(const TypeInfo& handle);
113 * @brief This assignment operator is required for (smart) pointer semantics.
116 * @param[in] rhs A reference to the copied handle
117 * @return A reference to this
119 TypeInfo& operator=(const TypeInfo& rhs);
122 * @brief Retrieves the type name for this type.
125 * @return String name
127 const std::string& GetName() const;
130 * @brief Retrieves the base type name for this type.
133 * @return String of base name
135 const std::string& GetBaseName() const;
138 * @brief Creates an object from this type.
141 * @return The BaseHandle for the newly created object
143 BaseHandle CreateInstance() const;
146 * @brief Retrieves the creator function for this type.
149 * @return The creator function
151 CreateFunction GetCreator() const;
154 * @brief Retrieves the number of actions for this type.
159 size_t GetActionCount() const;
162 * @brief Retrieves the action name for the index.
165 * @param[in] index Index to lookup
166 * @return Action name or empty string where index is invalid
168 std::string GetActionName(size_t index);
171 * @brief Retrieves the number of signals for this type.
176 size_t GetSignalCount() const;
179 * @brief Retrieves the signal name for the index.
182 * @param[in] index Index to lookup
183 * @return Signal name or empty string where index is invalid
185 std::string GetSignalName(size_t index);
188 * @brief Retrieves the number of event side type registered properties for this type.
190 * This count does not include all properties.
194 size_t GetPropertyCount() const;
199 * @brief Retrieves all the property indices for this type.
202 * @param[out] indices Container of property indices
203 * @note The container will be cleared
205 void GetPropertyIndices( Property::IndexContainer& indices ) const;
208 * @brief Retrieves all the child property indices for this type.
211 * @param[out] indices Container of property indices
212 * @note The container will be cleared
214 void GetChildPropertyIndices( Property::IndexContainer& indices ) const;
217 * @brief Given a property index, retrieve the property name associated with it.
220 * @param[in] index The property index
221 * @return The name of the property at the given index
222 * @exception DaliException If index is not valid.
225 const std::string& GetPropertyName( Property::Index index ) const;
229 * @brief Given a child property name, retrieve the property index associated with it,
232 * @param[in] name The name of the property at the given index,
233 * @return The property index or Property::INVALID_INDEX
235 Property::Index GetChildPropertyIndex( const std::string& name ) const;
238 * @brief Given a child property index, retrieve the property name associated with it.
241 * @param[in] index The property index
242 * @return The name of the property at the given index, or empty string if it does not exist
244 const std::string& GetChildPropertyName( Property::Index index ) const;
247 * @brief Given a child property index, retrieve the property name associated with it.
250 * @param[in] index The property index
251 * @return The name of the property at the given index, or empty string if it does not exist
253 Property::Type GetChildPropertyType( Property::Index index ) const;
257 public: // Not intended for application developers
261 * @brief This constructor is used by Dali Get() method.
264 * @param[in] typeInfo A pointer to a Dali resource
266 explicit DALI_INTERNAL TypeInfo(Internal::TypeInfo* typeInfo);
276 #endif // __DALI_TYPE_INFO_H__