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