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