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