Support for ASTC compressed textures wrapped in KTX files
[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) 2015 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
22 // INTERNAL INCLUDES
23 #include <dali/public-api/object/base-handle.h>
24 #include <dali/public-api/common/vector-wrapper.h>
25
26 namespace Dali
27 {
28 /**
29  * @addtogroup dali_core_object
30  * @{
31  */
32
33 class ConnectionTrackerInterface;
34 class FunctorDelegate;
35
36 namespace Internal DALI_INTERNAL
37 {
38   class TypeInfo;
39 };
40
41 /**
42  * @brief TypeInfo class for instantiation of registered types and introspection of
43  * their actions and signals.
44  *
45  * See TypeRegistry for methods of type registration and TypeInfo retrieval.
46  */
47 class DALI_IMPORT_API TypeInfo : public BaseHandle
48 {
49 public:
50   typedef BaseHandle (*CreateFunction)(); ///< Function signature for creating an instance of the associated object type.
51
52   typedef bool (*ActionFunction)(BaseObject*, const std::string&, const Property::Map&); ///< Function signature for creating scriptable actions
53
54   /**
55    * @brief Connects a callback function with the object's signals.
56    *
57    * @param[in] object The object providing the signal.
58    * @param[in] tracker Used to disconnect the signal.
59    * @param[in] signalName The signal to connect to.
60    * @param[in] functor A newly allocated FunctorDelegate.
61    * @return True if the signal was connected.
62    * @post If a signal was connected, ownership of functor was passed to CallbackBase. Otherwise the caller is responsible for deleting the unused functor.
63    */
64   typedef bool (*SignalConnectorFunction)(BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor);
65
66   /**
67    * @brief Callback to set an event-thread only property.
68    *
69    * @see PropertyRegistration.
70    * @param[in] object The object whose property should be set.
71    * @param[in] index The index of the property being set.
72    * @param[in] value The new value of the property for the object specified.
73    */
74   typedef void (*SetPropertyFunction)( BaseObject* object, Property::Index index, const Property::Value& value );
75
76   /**
77    * @brief Callback to get the value of an event-thread only property.
78    *
79    * @see PropertyRegistration.
80    * @param[in] object The object whose property value is required.
81    * @param[in] index The index of the property required.
82    * @return The current value of the property for the object specified.
83    */
84   typedef Property::Value (*GetPropertyFunction)( BaseObject* object, Property::Index index );
85
86   /**
87    * @brief Allows the creation of an empty TypeInfo handle.
88    */
89   TypeInfo();
90
91   /**
92    * @brief Destructor
93    *
94    * This is non-virtual since derived Handle types must not contain data or virtual methods.
95    */
96   ~TypeInfo();
97
98   /**
99    * @brief This copy constructor is required for (smart) pointer semantics.
100    *
101    * @param [in] handle A reference to the copied handle
102    */
103   TypeInfo(const TypeInfo& handle);
104
105   /**
106    * @brief This assignment operator is required for (smart) pointer semantics.
107    *
108    * @param [in] rhs  A reference to the copied handle
109    * @return A reference to this
110    */
111   TypeInfo& operator=(const TypeInfo& rhs);
112
113   /**
114    * @brief Retrieve the type name for this type.
115    *
116    * @return string name
117    */
118   const std::string& GetName() const;
119
120   /**
121    * @brief Retrieve the base type name for this type.
122    *
123    * @return string of base name
124    */
125   const std::string& GetBaseName() const;
126
127   /**
128    * @brief Create an object from this type.
129    *
130    * @return the BaseHandle for the newly created object
131    */
132   BaseHandle CreateInstance() const;
133
134   /**
135    * @brief Retrieve the creator function for this type.
136    *
137    * @return the creator function
138    */
139   CreateFunction GetCreator() const;
140
141   /**
142    * @brief Retrieve the number of actions for this type.
143    *
144    * @return The count
145    */
146   size_t GetActionCount() const;
147
148   /**
149    * @brief Retrieve the action name for the index.
150    *
151    * @param[in] index Index to lookup
152    * @return action name or empty string where index is invalid
153    */
154   std::string GetActionName(size_t index);
155
156   /**
157    * @brief Retrieve the number of signals for this type.
158    *
159    * @return The count
160    */
161   size_t GetSignalCount() const;
162
163   /**
164    * @brief Retrieve the signal name for the index.
165    *
166    * @param[in] index Index to lookup
167    * @return signal name or empty string where index is invalid
168    */
169   std::string GetSignalName(size_t index);
170
171   /**
172    * @brief Retrieve the number of event side type registered properties for this type.
173    *
174    * This count does not include all properties
175    * @return The count
176    */
177   size_t GetPropertyCount() const;
178
179   // Properties
180
181   /**
182    * @brief Retrieve all the property indices for this type.
183    *
184    * @param[out] indices Container of property indices
185    * @note The container will be cleared
186    */
187   void GetPropertyIndices( Property::IndexContainer& indices ) const;
188
189   /**
190    * @brief Given a property index, retrieve the property name associated with it.
191    *
192    * @exception DaliException If index is not valid.
193    *
194    * @param[in] index The property index.
195    * @return The name of the property at the given index.
196    */
197   const std::string& GetPropertyName( Property::Index index ) const;
198
199 public: // Not intended for application developers
200
201   /**
202    * @brief This constructor is used by Dali Get() method.
203    *
204    * @param [in] typeInfo A pointer to a Dali resource
205    */
206   explicit DALI_INTERNAL TypeInfo(Internal::TypeInfo* typeInfo);
207
208 };
209
210 /**
211  * @}
212  */
213 } // namespace Dali
214
215 #endif // __DALI_TYPE_INFO_H__