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 #include <dali/public-api/object/property.h>
23 #include <dali/public-api/math/rect.h>
25 namespace Dali DALI_IMPORT_API
37 * @brief Container of Dali::Property::Value.
39 typedef std::vector<Property::Value> PropertyValueContainer;
40 typedef PropertyValueContainer::iterator PropertyValueIter; ///< Iterator for Dali::PropertyValueContainer
41 typedef PropertyValueContainer::const_iterator PropertyValueConstIter; ///< Const iterator for Dali::PropertyValueContainer
44 * @brief A value-type representing a property value.
51 * @brief Default constructor.
53 * This creates a property with type Property::INVALID.
58 * @brief Create a boolean property value.
60 * @param [in] boolValue A boolean value.
62 Value(bool boolValue);
65 * @brief Create a float property value.
67 * @param [in] floatValue A floating-point value.
69 Value(float floatValue);
72 * @brief Create an integer property value.
74 * @param [in] integerValue An integer value.
76 Value(int integerValue);
79 * @brief Create an unsigned integer property value.
81 * @param [in] unsignedIntegerValue An unsinged integer value.
83 Value(unsigned int unsignedIntegerValue);
86 * @brief Create a Vector2 property value.
88 * @param [in] vectorValue A vector of 2 floating-point values.
90 Value(const Vector2& vectorValue);
93 * @brief Create a Vector3 property value.
95 * @param [in] vectorValue A vector of 3 floating-point values.
97 Value(const Vector3& vectorValue);
100 * @brief Create a Vector4 property value.
102 * @param [in] vectorValue A vector of 4 floating-point values.
104 Value(const Vector4& vectorValue);
107 * @brief Create a Matrix3 property value.
109 * @param [in] matrixValue A matrix of 3x3 floating-point values.
111 Value(const Matrix3& matrixValue);
114 * @brief Create a Matrix property value.
116 * @param [in] matrixValue A matrix of 4x4 floating-point values.
118 Value(const Matrix& matrixValue);
121 * @brief Create a Vector4 property value.
123 * @param [in] vectorValue A vector of 4 integer values.
125 Value(const Rect<int>& vectorValue);
128 * @brief Create an rotation property value.
130 * @param [in] angleAxis An angle-axis representing the rotation.
132 Value(const AngleAxis& angleAxis);
135 * @brief Create an rotation property value.
137 * @param [in] quaternion A quaternion representing the rotation.
139 Value(const Quaternion& quaternion);
142 * @brief Create an string property value.
144 * @param [in] stringValue A string.
146 Value(const std::string& stringValue);
149 * @brief Create an string property value.
151 * @param [in] stringValue A string.
153 Value(const char* stringValue);
156 * @brief Copy a property value.
158 * @param [in] value The property value to copy.
160 Value(const Value& value);
163 * @brief Create an array property value.
165 * @param [in] arrayValue An array
167 Value(Property::Array& arrayValue);
170 * @brief Create a map property value.
172 * @param [in] mapValue An array
174 Value(Property::Map& mapValue);
177 * @brief Explicitly set a type and initialize it.
179 * @param [in] type The property value type.
181 explicit Value(Type type);
184 * @brief Assign a property value.
186 * @param [in] value The property value to assign from.
187 * @return a reference to this
189 Value& operator=(const Value& value);
192 * @brief Non-virtual destructor.
197 * @brief Query the type of this property value.
199 * @return The type ID.
201 Type GetType() const;
204 * @brief Retrieve a specific value.
206 * @pre GetType() returns the Property::Type for type T.
207 * @return A value of type T.
209 template <typename T>
218 * @brief Retrieve a boolean value.
220 * @pre GetType() returns Property::BOOLEAN.
221 * @param [out] boolValue On return, a boolean value.
223 void Get(bool& boolValue) const;
226 * @brief Retrieve a floating-point value.
228 * @pre GetType() returns Property::FLOAT.
229 * @param [out] floatValue On return, a floating-point value.
231 void Get(float& floatValue) const;
234 * @brief Retrieve an integer value.
236 * @pre GetType() returns Property::INTEGER.
237 * @param [out] integerValue On return, an integer value.
239 void Get(int& integerValue) const;
242 * @brief Retrieve an unsigned integer value.
244 * @pre GetType() returns Property::UNSIGNED_INTEGER.
245 * @param [out] unsignedIntegerValue On return, an unsigned integer value.
247 void Get(unsigned int& unsignedIntegerValue) const;
250 * @brief Retrieve an integer rectangle.
252 * @pre GetType() returns Property::RECTANGLE.
253 * @param [out] rect On return, an integer rectangle.
255 void Get(Rect<int>& rect) const;
258 * @brief Retrieve a vector value.
260 * @pre GetType() returns Property::VECTOR2.
261 * @param [out] vectorValue On return, a vector value.
263 void Get(Vector2& vectorValue) const;
266 * @brief Retrieve a vector value.
268 * @pre GetType() returns Property::VECTOR3.
269 * @param [out] vectorValue On return, a vector value.
271 void Get(Vector3& vectorValue) const;
274 * @brief Retrieve a vector value.
276 * @pre GetType() returns Property::VECTOR4.
277 * @param [out] vectorValue On return, a vector value.
279 void Get(Vector4& vectorValue) const;
282 * @brief Retrieve a matrix3 value.
284 * @pre GetType() returns Property::MATRIX3.
285 * @param [out] matrixValue On return, a matrix3 value.
287 void Get(Matrix3& matrixValue) const;
290 * @brief Retrieve a matrix value.
292 * @pre GetType() returns Property::MATRIX.
293 * @param [out] matrixValue On return, a matrix value.
295 void Get(Matrix& matrixValue) const;
298 * @brief Retrieve an angle-axis value.
300 * @pre GetType() returns Property::ROTATION.
301 * @param [out] angleAxisValue On return, a angle-axis value.
303 void Get(AngleAxis& angleAxisValue) const;
306 * @brief Retrieve a quaternion value.
308 * @pre GetType() returns Property::ROTATION.
309 * @param [out] quaternionValue On return, a quaternion value.
311 void Get(Quaternion& quaternionValue) const;
314 * @brief Retrieve an string property value.
316 * @pre GetType() returns Property::STRING.
317 * @param [out] stringValue A string.
319 void Get(std::string& stringValue) const;
322 * @brief Retrieve an array property value.
324 * @pre GetType() returns Property::ARRAY.
325 * @param [out] arrayValue The array as a vector Property Values
327 void Get(Property::Array& arrayValue) const;
330 * @brief Retrieve an map property value.
332 * @pre GetType() returns Property::MAP.
333 * @param [out] mapValue The map as vector of string and Property Value pairs
335 void Get(Property::Map& mapValue) const;
338 * @brief Retrieve a property value from the internal map.
340 * @pre GetType() returns Property::MAP.
341 * @param [in] key A string.
342 * @return Property value if avaiable at key or Invalid
344 Property::Value& GetValue(const std::string& key) const;
347 * @brief Retrieve a property value from the internal map.
349 * @param [in] key A string.
350 * @return true if the key exists, false if not a map or key does not exist
352 bool HasKey(const std::string& key) const;
355 * @brief Retrieve a property value from the internal array or map.
357 * @pre GetType() returns Property::ARRAY or Property::MAP.
358 * @param [in] index The item index.
359 * @return Key at the index or empty if index is out of range
361 const std::string& GetKey(const int index) const;
364 * @brief Set a property value in the map.
366 * @pre GetType() returns Property::MAP.
367 * @param [in] key A string key.
368 * @param [in] value The value to set.
369 * @return Property value if avaiable at key
371 void SetValue(const std::string& key, const Property::Value &value);
374 * @brief Retrieve a property value from the internal array or map.
376 * @pre GetType() returns Property::ARRAY or Property::MAP.
377 * @param [in] index The item index.
378 * @return Property value if avaiable at key or Invalid
380 Property::Value& GetItem(const int index) const;
383 * @brief Set a property value in the array or map.
385 * @pre GetType() returns Property::ARRAY or Property::MAP.
386 * @pre index < GetSize()
387 * @param [in] index The property value index
388 * @param [in] value The value to set.
389 * @return Property value if index < GetSize()
391 void SetItem(const int index, const Property::Value &value);
394 * @brief Set a property value in the array.
396 * @pre GetType() returns Property::ARRAY.
397 * @param [in] value The value to set.
398 * @return THe index of the item just added
400 int AppendItem(const Property::Value &value);
403 * @brief Retrieve the length of the array or map.
406 * @pre GetType() returns Property::ARRAY or Property::MAP
407 * @return The length of the array
414 Impl* mImpl; ///< Pointer to the implementation
419 #endif // __DALI_PROPERTY_VALUE_H__