Make Dali::Vector movable & add use Modern C++ semantics on public & devel classes
[platform/core/uifw/dali-core.git] / dali / public-api / object / type-info.h
1 #ifndef DALI_TYPE_INFO_H
2 #define DALI_TYPE_INFO_H
3
4 /*
5  * Copyright (c) 2020 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 // EXTERNAL INCLUDES
22 #include <cstdint> // uint32_t
23
24 // INTERNAL INCLUDES
25 #include <dali/public-api/object/base-handle.h>
26 #include <dali/public-api/common/vector-wrapper.h>
27
28 namespace Dali
29 {
30 /**
31  * @addtogroup dali_core_object
32  * @{
33  */
34
35 class ConnectionTrackerInterface;
36 class FunctorDelegate;
37
38 namespace Internal DALI_INTERNAL
39 {
40   class TypeInfo;
41 };
42
43 /**
44  * @brief TypeInfo class for instantiation of registered types and introspection of
45  * their actions and signals.
46  *
47  * See TypeRegistry for methods of type registration and TypeInfo retrieval.
48  * @SINCE_1_0.0
49  */
50 class DALI_CORE_API TypeInfo : public BaseHandle
51 {
52 public:
53
54   using CreateFunction = BaseHandle (*)(); ///< Function signature for creating an instance of the associated object type. @SINCE_1_0.0
55
56   using ActionFunction = bool (*)(BaseObject*, const std::string&, const Property::Map&); ///< Function signature for creating scriptable actions @SINCE_1_0.0
57
58   /**
59    * @brief Connects a callback function with the object's signals.
60    *
61    * @SINCE_1_0.0
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.
68    */
69   using SignalConnectorFunction = bool (*)(BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor);
70
71   /**
72    * @brief Callback to set an event-thread only property.
73    *
74    * @SINCE_1_0.0
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.
79    */
80   using SetPropertyFunction = void (*)( BaseObject* object, Property::Index index, const Property::Value& value );
81
82   /**
83    * @brief Callback to get the value of an event-thread only property.
84    *
85    * @SINCE_1_0.0
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.
90    */
91   using GetPropertyFunction = Property::Value (*)( BaseObject* object, Property::Index index );
92
93   /**
94    * @brief Allows the creation of an empty TypeInfo handle.
95    * @SINCE_1_0.0
96    */
97   TypeInfo();
98
99   /**
100    * @brief Destructor.
101    *
102    * This is non-virtual since derived Handle types must not contain data or virtual methods.
103    * @SINCE_1_0.0
104    */
105   ~TypeInfo();
106
107   /**
108    * @brief This copy constructor is required for (smart) pointer semantics.
109    *
110    * @SINCE_1_0.0
111    * @param[in] handle A reference to the copied handle
112    */
113   TypeInfo(const TypeInfo& handle);
114
115   /**
116    * @brief This assignment operator is required for (smart) pointer semantics.
117    *
118    * @SINCE_1_0.0
119    * @param[in] rhs A reference to the copied handle
120    * @return A reference to this
121    */
122   TypeInfo& operator=(const TypeInfo& rhs);
123
124   /**
125    * @brief Move constructor.
126    *
127    * @SINCE_1_9.22
128    * @param[in] rhs A reference to the moved handle
129    */
130   TypeInfo( TypeInfo&& rhs );
131
132   /**
133    * @brief Move assignment operator.
134    *
135    * @SINCE_1_9.22
136    * @param[in] rhs A reference to the moved handle
137    * @return A reference to this handle
138    */
139   TypeInfo& operator=( TypeInfo&& rhs );
140
141   /**
142    * @brief Retrieves the type name for this type.
143    *
144    * @SINCE_1_0.0
145    * @return String name
146    */
147   const std::string& GetName() const;
148
149   /**
150    * @brief Retrieves the base type name for this type.
151    *
152    * @SINCE_1_0.0
153    * @return String of base name
154    */
155   const std::string& GetBaseName() const;
156
157   /**
158    * @brief Creates an object from this type.
159    *
160    * @SINCE_1_0.0
161    * @return The BaseHandle for the newly created object
162    */
163   BaseHandle CreateInstance() const;
164
165   /**
166    * @brief Retrieves the creator function for this type.
167    *
168    * @SINCE_1_0.0
169    * @return The creator function
170    */
171   CreateFunction GetCreator() const;
172
173   /**
174    * @brief Retrieves the number of actions for this type.
175    *
176    * @SINCE_1_0.0
177    * @return The count
178    */
179   size_t GetActionCount() const;
180
181   /**
182    * @brief Retrieves the action name for the index.
183    *
184    * @SINCE_1_0.0
185    * @param[in] index Index to lookup
186    * @return Action name or empty string where index is invalid
187    */
188   std::string GetActionName(size_t index);
189
190   /**
191    * @brief Retrieves the number of signals for this type.
192    *
193    * @SINCE_1_0.0
194    * @return The count
195    */
196   size_t GetSignalCount() const;
197
198   /**
199    * @brief Retrieves the signal name for the index.
200    *
201    * @SINCE_1_0.0
202    * @param[in] index Index to lookup
203    * @return Signal name or empty string where index is invalid
204    */
205   std::string GetSignalName(size_t index);
206
207   /**
208    * @brief Retrieves the number of event side type registered properties for this type.
209    *
210    * @SINCE_1_0.0
211    * @return The count
212    */
213   size_t GetPropertyCount() const;
214
215   // Properties
216
217   /**
218    * @brief Retrieves all the property indices for this type.
219    *
220    * @SINCE_1_0.0
221    * @param[out] indices Container of property indices
222    * @note The container will be cleared
223    */
224   void GetPropertyIndices( Property::IndexContainer& indices ) const;
225
226   /**
227    * @brief Retrieves all the child property indices for this type.
228    *
229    * @SINCE_1_3.20
230    * @param[out] indices Container of property indices
231    * @note The container will be cleared
232    */
233   void GetChildPropertyIndices( Property::IndexContainer& indices ) const;
234
235   /**
236    * @brief Given a property index, retrieve the property name associated with it.
237    *
238    * @SINCE_1_0.0
239    * @param[in] index The property index
240    * @return The name of the property at the given index
241    * @exception DaliException If index is not valid.
242    * @note this method only works for custom registered properties
243    */
244   const std::string& GetPropertyName( Property::Index index ) const;
245
246
247   /**
248    * @brief Given a child property name, retrieve the property index associated with it,
249    *
250    * @SINCE_1_3.20
251    * @param[in] name The name of the property at the given index,
252    * @return The property index or Property::INVALID_INDEX
253    */
254   Property::Index GetChildPropertyIndex( const std::string& name ) const;
255
256   /**
257    * @brief Given a child property index, retrieve the property name associated with it.
258    *
259    * @SINCE_1_3.20
260    * @param[in] index The property index
261    * @return The name of the property at the given index, or empty string if it does not exist
262    */
263   const std::string& GetChildPropertyName( Property::Index index ) const;
264
265   /**
266    * @brief Given a child property index, retrieve the property name associated with it.
267    *
268    * @SINCE_1_3.20
269    * @param[in] index The property index
270    * @return The name of the property at the given index, or empty string if it does not exist
271    */
272   Property::Type GetChildPropertyType( Property::Index index ) const;
273
274
275
276 public: // Not intended for application developers
277
278   /// @cond internal
279   /**
280    * @brief This constructor is used by Dali Get() method.
281    *
282    * @SINCE_1_0.0
283    * @param[in] typeInfo A pointer to a Dali resource
284    */
285   explicit DALI_INTERNAL TypeInfo(Internal::TypeInfo* typeInfo);
286   /// @endcond
287
288 };
289
290 /**
291  * @}
292  */
293 } // namespace Dali
294
295 #endif // DALI_TYPE_INFO_H