[3.0] Exclude internal tag module in Public API reference
[platform/core/uifw/dali-core.git] / dali / public-api / object / property-value.h
1 #ifndef __DALI_PROPERTY_VALUE_H__
2 #define __DALI_PROPERTY_VALUE_H__
3
4 /*
5  * Copyright (c) 2016 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 <iosfwd>
23
24 // INTERNAL INCLUDES
25 #include <dali/public-api/object/property.h>
26 #include <dali/public-api/math/rect.h>
27
28 namespace Dali
29 {
30 /**
31  * @addtogroup dali_core_object
32  * @{
33  */
34
35 struct AngleAxis;
36 class Quaternion;
37 struct Vector2;
38 struct Vector3;
39 struct Vector4;
40 class Matrix3;
41 class Matrix;
42
43 /**
44  * @brief A value-type representing a property value.
45  * @SINCE_1_0.0
46  */
47 class DALI_IMPORT_API Property::Value
48 {
49 public:
50
51   /**
52    * @brief Default constructor.
53    *
54    * This creates a property with type Property::NONE.
55    * @SINCE_1_0.0
56    */
57   Value();
58
59   /**
60    * @brief Create a boolean property value.
61    *
62    * @SINCE_1_0.0
63    * @param [in] boolValue A boolean value.
64    */
65   Value( bool boolValue );
66
67   /**
68    * @brief Create an integer property value.
69    *
70    * @SINCE_1_0.0
71    * @param [in] integerValue An integer value.
72    */
73   Value( int integerValue );
74
75   /**
76    * @brief Create a float property value.
77    *
78    * @SINCE_1_0.0
79    * @param [in] floatValue A floating-point value.
80    */
81   Value( float floatValue );
82
83   /**
84    * @brief Create a Vector2 property value.
85    *
86    * @SINCE_1_0.0
87    * @param [in] vectorValue A vector of 2 floating-point values.
88    */
89   Value( const Vector2& vectorValue );
90
91   /**
92    * @brief Create a Vector3 property value.
93    *
94    * @SINCE_1_0.0
95    * @param [in] vectorValue A vector of 3 floating-point values.
96    */
97   Value( const Vector3& vectorValue );
98
99   /**
100    * @brief Create a Vector4 property value.
101    *
102    * @SINCE_1_0.0
103    * @param [in] vectorValue A vector of 4 floating-point values.
104    */
105   Value( const Vector4& vectorValue );
106
107   /**
108    * @brief Create a Matrix3 property value.
109    *
110    * @SINCE_1_0.0
111    * @param [in] matrixValue A matrix of 3x3 floating-point values.
112    */
113   Value( const Matrix3& matrixValue );
114
115   /**
116    * @brief Create a Matrix property value.
117    *
118    * @SINCE_1_0.0
119    * @param [in] matrixValue A matrix of 4x4 floating-point values.
120    */
121   Value( const Matrix& matrixValue );
122
123   /**
124    * @brief Create a Vector4 property value.
125    *
126    * @SINCE_1_0.0
127    * @param [in] vectorValue A vector of 4 integer values.
128    */
129   Value( const Rect<int>& vectorValue );
130
131   /**
132    * @brief Create an orientation property value.
133    *
134    * @SINCE_1_0.0
135    * @param [in] angleAxis An angle-axis representing the rotation.
136    */
137   Value( const AngleAxis& angleAxis );
138
139   /**
140    * @brief Create an orientation property value.
141    *
142    * @SINCE_1_0.0
143    * @param [in] quaternion A quaternion representing the rotation.
144    */
145   Value( const Quaternion& quaternion );
146
147   /**
148    * @brief Create an string property value.
149    *
150    * @SINCE_1_0.0
151    * @param [in] stringValue A string.
152    */
153   Value( const std::string& stringValue );
154
155   /**
156    * @brief Create an string property value.
157    *
158    * @SINCE_1_0.0
159    * @param [in] stringValue A string.
160    */
161   Value( const char* stringValue );
162
163   /**
164    * @brief Create an array property value.
165    *
166    * @SINCE_1_0.0
167    * @param [in] arrayValue An array
168    */
169   Value( Property::Array& arrayValue );
170
171   /**
172    * @brief Create a map property value.
173    *
174    * @SINCE_1_0.0
175    * @param [in] mapValue An array
176    */
177   Value( Property::Map& mapValue );
178
179   /**
180    * @brief Explicitly set a type and initialize it.
181    *
182    * @SINCE_1_0.0
183    * @param [in] type The property value type.
184    */
185   explicit Value( Type type );
186
187   /**
188    * @brief Copy constructor
189    *
190    * @SINCE_1_0.0
191    * @param [in] value The property value to copy.
192    */
193   Value( const Value& value );
194
195   /**
196    * @brief Assign a property value.
197    *
198    * @SINCE_1_0.0
199    * @param [in] value The property value to assign from.
200    * @return a reference to this
201    */
202   Value& operator=( const Value& value );
203
204   /**
205    * @brief Non-virtual destructor.
206    *
207    * This class is not a base class.
208    * @SINCE_1_0.0
209    */
210   ~Value();
211
212   /**
213    * @brief Query the type of this property value.
214    *
215    * @SINCE_1_0.0
216    * @return The type ID.
217    */
218   Type GetType() const;
219
220   /**
221    * @internal
222    * @brief Retrieve a specific value.
223    *
224    * Works on a best-effort approach; if value type is not convertible returns a default value of the type
225    *
226    * @SINCE_1_0.0
227    * @return A value of type T.
228    */
229   template <typename T>
230   T DALI_INTERNAL Get() const
231   {
232     T temp = T(); // value (zero) initialize
233     Get( temp );
234     return temp;
235   }
236
237   /**
238    * @brief Retrieve a boolean value.
239    *
240    * @SINCE_1_0.0
241    * @param [out] boolValue On return, a boolean value.
242    * @return true if the value is successfully retrieved, false if the type is not convertible
243    * @pre GetType() is a type convertible to bool.
244    */
245   bool Get( bool& boolValue ) const;
246
247   /**
248    * @brief Retrieve a floating-point value.
249    *
250    * @SINCE_1_0.0
251    * @param [out] floatValue On return, a floating-point value.
252    * @return true if the value is successfully retrieved, false if the type is not convertible
253    * @pre GetType() is a type convertible to float.
254    */
255   bool Get( float& floatValue ) const;
256
257   /**
258    * @brief Retrieve an integer value.
259    *
260    * @SINCE_1_0.0
261    * @param [out] integerValue On return, an integer value.
262    * @return true if the value is successfully retrieved, false if the type is not convertible
263    * @pre GetType() is a type convertible to int.
264    */
265   bool Get( int& integerValue ) const;
266
267   /**
268    * @brief Retrieve an integer rectangle.
269    *
270    * @SINCE_1_0.0
271    * @param [out] rect On return, an integer rectangle.
272    * @return true if the value is successfully retrieved, false if the type is not convertible
273    * @pre GetType() is a type convertible to Rect<int>.
274    */
275   bool Get( Rect<int>& rect ) const;
276
277   /**
278    * @brief Retrieve a vector value.
279    *
280    * @SINCE_1_0.0
281    * @param [out] vectorValue On return, a vector value.
282    * @return true if the value is successfully retrieved, false if the type is not convertible
283    * @pre GetType() is a type convertible to Vector2.
284    */
285   bool Get( Vector2& vectorValue ) const;
286
287   /**
288    * @brief Retrieve a vector value.
289    *
290    * @SINCE_1_0.0
291    * @param [out] vectorValue On return, a vector value.
292    * @return true if the value is successfully retrieved, false if the type is not convertible
293    * @pre GetType() is a type convertible to Vector3.
294    */
295   bool Get( Vector3& vectorValue ) const;
296
297   /**
298    * @brief Retrieve a vector value.
299    *
300    * @SINCE_1_0.0
301    * @param [out] vectorValue On return, a vector value.
302    * @return true if the value is successfully retrieved, false if the type is not convertible
303    * @pre GetType() is a type convertible to Vector4.
304    */
305   bool Get( Vector4& vectorValue ) const;
306
307   /**
308    * @brief Retrieve a matrix3 value.
309    *
310    * @SINCE_1_0.0
311    * @param [out] matrixValue On return, a matrix3 value.
312    * @return true if the value is successfully retrieved, false if the type is not convertible
313    * @pre GetType() is a type convertible to Matrix3.
314    */
315   bool Get( Matrix3& matrixValue ) const;
316
317   /**
318    * @brief Retrieve a matrix value.
319    *
320    * @SINCE_1_0.0
321    * @param [out] matrixValue On return, a matrix value.
322    * @return true if the value is successfully retrieved, false if the type is not convertible
323    * @pre GetType() is a type convertible to Matrix.
324    */
325   bool Get( Matrix& matrixValue ) const;
326
327   /**
328    * @brief Retrieve an angle-axis value.
329    *
330    * @SINCE_1_0.0
331    * @param [out] angleAxisValue On return, a angle-axis value.
332    * @return true if the value is successfully retrieved, false if the type is not convertible
333    * @pre GetType() is a type convertible to AngleAxis.
334    */
335   bool Get( AngleAxis& angleAxisValue ) const;
336
337   /**
338    * @brief Retrieve a quaternion value.
339    *
340    * @SINCE_1_0.0
341    * @param [out] quaternionValue On return, a quaternion value.
342    * @return true if the value is successfully retrieved, false if the type is not convertible
343    * @pre GetType() is a type convertible to Quaternion.
344    */
345   bool Get( Quaternion& quaternionValue ) const;
346
347   /**
348    * @brief Retrieve an string property value.
349    *
350    * @SINCE_1_0.0
351    * @param [out] stringValue A string.
352    * @return true if the value is successfully retrieved, false if the type is not convertible
353    * @pre GetType() is a type convertible to string.
354    */
355   bool Get( std::string& stringValue ) const;
356
357   /**
358    * @brief Retrieve an array property value.
359    *
360    * @SINCE_1_0.0
361    * @param [out] arrayValue The array as a vector Property Values
362    * @return true if the value is successfully retrieved, false if the type is not convertible
363    * @pre GetType() returns Property::ARRAY.
364    */
365   bool Get( Property::Array& arrayValue ) const;
366
367   /**
368    * @brief Retrieve an map property value.
369    *
370    * @SINCE_1_0.0
371    * @param [out] mapValue The map as vector of string and Property Value pairs
372    * @return true if the value is successfully retrieved, false if the type is not convertible
373    * @pre GetType() returns Property::MAP.
374    */
375   bool Get( Property::Map& mapValue ) const;
376
377   /**
378    * @brief Retrieve the Array API of the Property::Value without copying the contents of the map
379    *
380    * @SINCE_1_0.0
381    * @return the Array API of the Property::Value or NULL if not a Property::Array
382    */
383   Property::Array* GetArray() const;
384
385   /**
386    * @brief Retrieve the Map API of the Property::Value without copying the contents of the map
387    *
388    * @SINCE_1_0.0
389    * @return  the Map API of the Property::Value or NULL if not a Property::Map
390    */
391   Property::Map* GetMap() const;
392
393   /**
394    * @brief output to stream
395    * @SINCE_1_0.0
396    */
397   friend std::ostream& operator<<( std::ostream& ouputStream, const Property::Value& value );
398
399 private:
400
401   struct DALI_INTERNAL Impl;
402   Impl* mImpl; ///< Pointer to the implementation
403
404 };
405
406 /**
407  * @brief Convert the value of the property into a string and append to an output stream.
408  *
409  * @SINCE_1_0.0
410  * @param [in] ouputStream The output stream operator.
411  * @param [in] value The value to insert
412  * @return The output stream operator.
413  */
414 DALI_IMPORT_API std::ostream& operator<<( std::ostream& ouputStream, const Property::Value& value );
415
416 /**
417  * @}
418  */
419 } // namespace Dali
420
421 #endif // __DALI_PROPERTY_VALUE_H__