1 #ifndef DALI_TYPE_INFO_H
2 #define DALI_TYPE_INFO_H
5 * Copyright (c) 2019 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.
22 #include <cstdint> // uint32_t
25 #include <dali/public-api/object/base-handle.h>
26 #include <dali/public-api/common/vector-wrapper.h>
31 * @addtogroup dali_core_object
35 class ConnectionTrackerInterface;
36 class FunctorDelegate;
38 namespace Internal DALI_INTERNAL
44 * @brief TypeInfo class for instantiation of registered types and introspection of
45 * their actions and signals.
47 * See TypeRegistry for methods of type registration and TypeInfo retrieval.
50 class DALI_CORE_API TypeInfo : public BaseHandle
54 using CreateFunction = BaseHandle (*)(); ///< Function signature for creating an instance of the associated object type. @SINCE_1_0.0
56 using ActionFunction = bool (*)(BaseObject*, const std::string&, const Property::Map&); ///< Function signature for creating scriptable actions @SINCE_1_0.0
59 * @brief Connects a callback function with the object's signals.
62 * @param[in] object The object providing the signal
63 * @param[in] tracker Used to disconnect the signal
64 * @param[in] signalName The signal to connect to
65 * @param[in] functor A newly allocated FunctorDelegate
66 * @return True if the signal was connected
67 * @post If a signal was connected, ownership of functor was passed to CallbackBase. Otherwise the caller is responsible for deleting the unused functor.
69 using SignalConnectorFunction = bool (*)(BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor);
72 * @brief Callback to set an event-thread only property.
75 * @param[in] object The object whose property should be set
76 * @param[in] index The index of the property being set
77 * @param[in] value The new value of the property for the object specified
78 * @see PropertyRegistration.
80 using SetPropertyFunction = void (*)( BaseObject* object, Property::Index index, const Property::Value& value );
83 * @brief Callback to get the value of an event-thread only property.
86 * @param[in] object The object whose property value is required
87 * @param[in] index The index of the property required
88 * @return The current value of the property for the object specified
89 * @see PropertyRegistration.
91 using GetPropertyFunction = Property::Value (*)( BaseObject* object, Property::Index index );
94 * @brief Allows the creation of an empty TypeInfo handle.
102 * This is non-virtual since derived Handle types must not contain data or virtual methods.
108 * @brief This copy constructor is required for (smart) pointer semantics.
111 * @param[in] handle A reference to the copied handle
113 TypeInfo(const TypeInfo& handle);
116 * @brief This assignment operator is required for (smart) pointer semantics.
119 * @param[in] rhs A reference to the copied handle
120 * @return A reference to this
122 TypeInfo& operator=(const TypeInfo& rhs);
125 * @brief Retrieves the type name for this type.
128 * @return String name
130 const std::string& GetName() const;
133 * @brief Retrieves the base type name for this type.
136 * @return String of base name
138 const std::string& GetBaseName() const;
141 * @brief Creates an object from this type.
144 * @return The BaseHandle for the newly created object
146 BaseHandle CreateInstance() const;
149 * @brief Retrieves the creator function for this type.
152 * @return The creator function
154 CreateFunction GetCreator() const;
157 * @brief Retrieves the number of actions for this type.
162 size_t GetActionCount() const;
165 * @brief Retrieves the action name for the index.
168 * @param[in] index Index to lookup
169 * @return Action name or empty string where index is invalid
171 std::string GetActionName(size_t index);
174 * @brief Retrieves the number of signals for this type.
179 size_t GetSignalCount() const;
182 * @brief Retrieves the signal name for the index.
185 * @param[in] index Index to lookup
186 * @return Signal name or empty string where index is invalid
188 std::string GetSignalName(size_t index);
191 * @brief Retrieves the number of event side type registered properties for this type.
196 size_t GetPropertyCount() const;
201 * @brief Retrieves all the property indices for this type.
204 * @param[out] indices Container of property indices
205 * @note The container will be cleared
207 void GetPropertyIndices( Property::IndexContainer& indices ) const;
210 * @brief Retrieves all the child property indices for this type.
213 * @param[out] indices Container of property indices
214 * @note The container will be cleared
216 void GetChildPropertyIndices( Property::IndexContainer& indices ) const;
219 * @brief Given a property index, retrieve the property name associated with it.
222 * @param[in] index The property index
223 * @return The name of the property at the given index
224 * @exception DaliException If index is not valid.
225 * @note this method only works for custom registered properties
227 const std::string& GetPropertyName( Property::Index index ) const;
231 * @brief Given a child property name, retrieve the property index associated with it,
234 * @param[in] name The name of the property at the given index,
235 * @return The property index or Property::INVALID_INDEX
237 Property::Index GetChildPropertyIndex( const std::string& name ) const;
240 * @brief Given a child property index, retrieve the property name associated with it.
243 * @param[in] index The property index
244 * @return The name of the property at the given index, or empty string if it does not exist
246 const std::string& GetChildPropertyName( Property::Index index ) const;
249 * @brief Given a child property index, retrieve the property name associated with it.
252 * @param[in] index The property index
253 * @return The name of the property at the given index, or empty string if it does not exist
255 Property::Type GetChildPropertyType( Property::Index index ) const;
259 public: // Not intended for application developers
263 * @brief This constructor is used by Dali Get() method.
266 * @param[in] typeInfo A pointer to a Dali resource
268 explicit DALI_INTERNAL TypeInfo(Internal::TypeInfo* typeInfo);
278 #endif // DALI_TYPE_INFO_H