Purge underscored header file barriers
[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) 2019 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 Retrieves the type name for this type.
126    *
127    * @SINCE_1_0.0
128    * @return String name
129    */
130   const std::string& GetName() const;
131
132   /**
133    * @brief Retrieves the base type name for this type.
134    *
135    * @SINCE_1_0.0
136    * @return String of base name
137    */
138   const std::string& GetBaseName() const;
139
140   /**
141    * @brief Creates an object from this type.
142    *
143    * @SINCE_1_0.0
144    * @return The BaseHandle for the newly created object
145    */
146   BaseHandle CreateInstance() const;
147
148   /**
149    * @brief Retrieves the creator function for this type.
150    *
151    * @SINCE_1_0.0
152    * @return The creator function
153    */
154   CreateFunction GetCreator() const;
155
156   /**
157    * @brief Retrieves the number of actions for this type.
158    *
159    * @SINCE_1_0.0
160    * @return The count
161    */
162   size_t GetActionCount() const;
163
164   /**
165    * @brief Retrieves the action name for the index.
166    *
167    * @SINCE_1_0.0
168    * @param[in] index Index to lookup
169    * @return Action name or empty string where index is invalid
170    */
171   std::string GetActionName(size_t index);
172
173   /**
174    * @brief Retrieves the number of signals for this type.
175    *
176    * @SINCE_1_0.0
177    * @return The count
178    */
179   size_t GetSignalCount() const;
180
181   /**
182    * @brief Retrieves the signal name for the index.
183    *
184    * @SINCE_1_0.0
185    * @param[in] index Index to lookup
186    * @return Signal name or empty string where index is invalid
187    */
188   std::string GetSignalName(size_t index);
189
190   /**
191    * @brief Retrieves the number of event side type registered properties for this type.
192    *
193    * @SINCE_1_0.0
194    * @return The count
195    */
196   size_t GetPropertyCount() const;
197
198   // Properties
199
200   /**
201    * @brief Retrieves all the property indices for this type.
202    *
203    * @SINCE_1_0.0
204    * @param[out] indices Container of property indices
205    * @note The container will be cleared
206    */
207   void GetPropertyIndices( Property::IndexContainer& indices ) const;
208
209   /**
210    * @brief Retrieves all the child property indices for this type.
211    *
212    * @SINCE_1_3.20
213    * @param[out] indices Container of property indices
214    * @note The container will be cleared
215    */
216   void GetChildPropertyIndices( Property::IndexContainer& indices ) const;
217
218   /**
219    * @brief Given a property index, retrieve the property name associated with it.
220    *
221    * @SINCE_1_0.0
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
226    */
227   const std::string& GetPropertyName( Property::Index index ) const;
228
229
230   /**
231    * @brief Given a child property name, retrieve the property index associated with it,
232    *
233    * @SINCE_1_3.20
234    * @param[in] name The name of the property at the given index,
235    * @return The property index or Property::INVALID_INDEX
236    */
237   Property::Index GetChildPropertyIndex( const std::string& name ) const;
238
239   /**
240    * @brief Given a child property index, retrieve the property name associated with it.
241    *
242    * @SINCE_1_3.20
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
245    */
246   const std::string& GetChildPropertyName( Property::Index index ) const;
247
248   /**
249    * @brief Given a child property index, retrieve the property name associated with it.
250    *
251    * @SINCE_1_3.20
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
254    */
255   Property::Type GetChildPropertyType( Property::Index index ) const;
256
257
258
259 public: // Not intended for application developers
260
261   /// @cond internal
262   /**
263    * @brief This constructor is used by Dali Get() method.
264    *
265    * @SINCE_1_0.0
266    * @param[in] typeInfo A pointer to a Dali resource
267    */
268   explicit DALI_INTERNAL TypeInfo(Internal::TypeInfo* typeInfo);
269   /// @endcond
270
271 };
272
273 /**
274  * @}
275  */
276 } // namespace Dali
277
278 #endif // DALI_TYPE_INFO_H