1 #ifndef __DALI_PROPERTY_VALUE_H__
2 #define __DALI_PROPERTY_VALUE_H__
5 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
22 * @addtogroup CAPI_DALI_OBJECT_MODULE
27 #include <dali/public-api/object/property.h>
28 #include <dali/public-api/math/rect.h>
30 namespace Dali DALI_IMPORT_API
42 * @brief Container of Dali::Property::Value%s.
44 typedef std::vector<Property::Value> PropertyValueContainer;
45 typedef PropertyValueContainer::iterator PropertyValueIter; ///< Iterator for Dali::PropertyValueContainer
46 typedef PropertyValueContainer::const_iterator PropertyValueConstIter; ///< Const iterator for Dali::PropertyValueContainer
49 * @brief A value-type representing a property value.
56 * @brief Default constructor.
58 * This creates a property with type Property::INVALID.
63 * @brief Create a boolean property value.
65 * @param [in] boolValue A boolean value.
67 Value(bool boolValue);
70 * @brief Create a float property value.
72 * @param [in] floatValue A floating-point value.
74 Value(float floatValue);
77 * @brief Create an integer property value.
79 * @param [in] integerValue An integer value.
81 Value(int integerValue);
84 * @brief Create an unsigned integer property value.
86 * @param [in] unsignedIntegerValue An unsinged integer value.
88 Value(unsigned int unsignedIntegerValue);
91 * @brief Create a Vector2 property value.
93 * @param [in] vectorValue A vector of 2 floating-point values.
95 Value(const Vector2& vectorValue);
98 * @brief Create a Vector3 property value.
100 * @param [in] vectorValue A vector of 3 floating-point values.
102 Value(const Vector3& vectorValue);
105 * @brief Create a Vector4 property value.
107 * @param [in] vectorValue A vector of 4 floating-point values.
109 Value(const Vector4& vectorValue);
112 * @brief Create a Matrix3 property value.
114 * @param [in] matrixValue A matrix of 3x3 floating-point values.
116 Value(const Matrix3& matrixValue);
119 * @brief Create a Matrix property value.
121 * @param [in] matrixValue A matrix of 4x4 floating-point values.
123 Value(const Matrix& matrixValue);
126 * @brief Create a Vector4 property value.
128 * @param [in] vectorValue A vector of 4 integer values.
130 Value(const Rect<int>& vectorValue);
133 * @brief Create an rotation property value.
135 * @param [in] angleAxis An angle-axis representing the rotation.
137 Value(const AngleAxis& angleAxis);
140 * @brief Create an rotation property value.
142 * @param [in] quaternion A quaternion representing the rotation.
144 Value(const Quaternion& quaternion);
147 * @brief Create an string property value.
149 * @param [in] stringValue A string.
151 Value(const std::string& stringValue);
154 * @brief Create an string property value.
156 * @param [in] stringValue A string.
158 Value(const char* stringValue);
161 * @brief Copy a property value.
163 * @param [in] value The property value to copy.
165 Value(const Value& value);
168 * @brief Create an array property value.
170 * @param [in] arrayValue An array
172 Value(Property::Array& arrayValue);
175 * @brief Create a map property value.
177 * @param [in] mapValue An array
179 Value(Property::Map& mapValue);
182 * @brief Explicitly set a type and initialize it.
184 * @param [in] type The property value type.
186 explicit Value(Type type);
189 * @brief Assign a property value.
191 * @param [in] value The property value to assign from.
192 * @return a reference to this
194 Value& operator=(const Value& value);
197 * @brief Non-virtual destructor.
202 * @brief Query the type of this property value.
204 * @return The type ID.
206 Type GetType() const;
209 * @brief Retrieve a specific value.
211 * @pre GetType() returns the Property::Type for type T.
212 * @return A value of type T.
214 template <typename T>
223 * @brief Retrieve a boolean value.
225 * @pre GetType() returns Property::BOOLEAN.
226 * @param [out] boolValue On return, a boolean value.
228 void Get(bool& boolValue) const;
231 * @brief Retrieve a floating-point value.
233 * @pre GetType() returns Property::FLOAT.
234 * @param [out] floatValue On return, a floating-point value.
236 void Get(float& floatValue) const;
239 * @brief Retrieve an integer value.
241 * @pre GetType() returns Property::INTEGER.
242 * @param [out] integerValue On return, an integer value.
244 void Get(int& integerValue) const;
247 * @brief Retrieve an unsigned integer value.
249 * @pre GetType() returns Property::UNSIGNED_INTEGER.
250 * @param [out] unsignedIntegerValue On return, an unsigned integer value.
252 void Get(unsigned int& unsignedIntegerValue) const;
255 * @brief Retrieve an integer rectangle.
257 * @pre GetType() returns Property::RECTANGLE.
258 * @param [out] rect On return, an integer rectangle.
260 void Get(Rect<int>& rect) const;
263 * @brief Retrieve a vector value.
265 * @pre GetType() returns Property::VECTOR2.
266 * @param [out] vectorValue On return, a vector value.
268 void Get(Vector2& vectorValue) const;
271 * @brief Retrieve a vector value.
273 * @pre GetType() returns Property::VECTOR3.
274 * @param [out] vectorValue On return, a vector value.
276 void Get(Vector3& vectorValue) const;
279 * @brief Retrieve a vector value.
281 * @pre GetType() returns Property::VECTOR4.
282 * @param [out] vectorValue On return, a vector value.
284 void Get(Vector4& vectorValue) const;
287 * @brief Retrieve a matrix3 value.
289 * @pre GetType() returns Property::MATRIX3.
290 * @param [out] matrixValue On return, a matrix3 value.
292 void Get(Matrix3& matrixValue) const;
295 * @brief Retrieve a matrix value.
297 * @pre GetType() returns Property::MATRIX.
298 * @param [out] matrixValue On return, a matrix value.
300 void Get(Matrix& matrixValue) const;
303 * @brief Retrieve an angle-axis value.
305 * @pre GetType() returns Property::ROTATION.
306 * @param [out] angleAxisValue On return, a angle-axis value.
308 void Get(AngleAxis& angleAxisValue) const;
311 * @brief Retrieve a quaternion value.
313 * @pre GetType() returns Property::ROTATION.
314 * @param [out] quaternionValue On return, a quaternion value.
316 void Get(Quaternion& quaternionValue) const;
319 * @brief Retrieve an string property value.
321 * @pre GetType() returns Property::STRING.
322 * @param [out] stringValue A string.
324 void Get(std::string& stringValue) const;
327 * @brief Retrieve an array property value.
329 * @pre GetType() returns Property::ARRAY.
330 * @param [out] arrayValue The array as a vector Property Values
332 void Get(Property::Array& arrayValue) const;
335 * @brief Retrieve an map property value.
337 * @pre GetType() returns Property::MAP.
338 * @param [out] mapValue The map as vector of string and Property Value pairs
340 void Get(Property::Map& mapValue) const;
343 * @brief Retrieve a property value from the internal map.
345 * @pre GetType() returns Property::MAP.
346 * @param [in] key A string.
347 * @return Property value if avaiable at key or Invalid
349 Property::Value& GetValue(const std::string& key) const;
352 * @brief Retrieve a property value from the internal map.
354 * @param [in] key A string.
355 * @return true if the key exists, false if not a map or key does not exist
357 bool HasKey(const std::string& key) const;
360 * @brief Retrieve a property value from the internal array or map.
362 * @pre GetType() returns Property::ARRAY or Property::MAP.
363 * @param [in] index The item index.
364 * @return Key at the index or empty if index is out of range
366 const std::string& GetKey(const int index) const;
369 * @brief Set a property value in the map.
371 * @pre GetType() returns Property::MAP.
372 * @param [in] key A string key.
373 * @param [in] value The value to set.
374 * @return Property value if avaiable at key
376 void SetValue(const std::string& key, const Property::Value &value);
379 * @brief Retrieve a property value from the internal array or map.
381 * @pre GetType() returns Property::ARRAY or Property::MAP.
382 * @param [in] index The item index.
383 * @return Property value if avaiable at key or Invalid
385 Property::Value& GetItem(const int index) const;
388 * @brief Set a property value in the array or map.
390 * @pre GetType() returns Property::ARRAY or Property::MAP.
391 * @pre index < GetSize()
392 * @param [in] index The property value index
393 * @param [in] value The value to set.
394 * @return Property value if index < GetSize()
396 void SetItem(const int index, const Property::Value &value);
399 * @brief Set a property value in the array.
401 * @pre GetType() returns Property::ARRAY.
402 * @param [in] value The value to set.
403 * @return THe index of the item just added
405 int AppendItem(const Property::Value &value);
408 * @brief Retrieve the length of the array or map.
411 * @pre GetType() returns Property::ARRAY or Property::MAP
412 * @return The length of the array
419 Impl* mImpl; ///< Pointer to the implementation
427 #endif // __DALI_PROPERTY_VALUE_H__