1 #ifndef DALI_PROPERTY_ARRAY_H
2 #define DALI_PROPERTY_ARRAY_H
5 * Copyright (c) 2019 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 <initializer_list>
26 #include <dali/public-api/common/dali-common.h>
27 #include <dali/public-api/object/property-value.h>
28 #include <dali/public-api/object/property.h>
33 * @addtogroup dali_core_object
38 * @brief A Array of property values.
41 class DALI_CORE_API Property::Array
44 using SizeType = std::size_t;
47 * @brief Default constructor.
53 * @brief Constructor from initializer_list.
56 * @param[in] values An initializer_list of values
58 Array( const std::initializer_list< Value >& values );
61 * @brief Copy constructor.
64 * @param[in] other The Array to copy from
66 Array( const Array& other );
69 * @brief Move constructor.
71 * A move constructor enables the resources owned by an r-value object to be moved into an l-value without copying.
73 * @param[in] other The Array to move from
74 * @note After the @a other array is used, it becomes invalid and is no longer usable.
76 Array( Array&& other );
79 * @brief Non-virtual destructor.
85 * @brief Retrieves the number of elements in the array.
88 * @return The number of elements in the array
96 * @brief Retrieves the number of elements in the array.
99 * @return The number of elements in the array
101 SizeType Count() const;
104 * @brief Returns whether the array is empty.
107 * @return @c true if empty, @c false otherwise
115 * @brief Clears the array.
121 * @brief Increases the capacity of the array.
123 * @param[in] size The size to reserve
125 void Reserve( SizeType size );
128 * @brief Resizes to size.
130 * @param[in] size The size to resize
132 void Resize( SizeType size );
135 * @brief Retrieves the capacity of the array.
138 * @return The allocated capacity of the array
143 * @brief Adds an element to the array.
146 * @param[in] value The value to add to the end of the array
148 void PushBack( const Value& value );
151 * @brief Add an element to the array.
154 * @param[in] value The value to add to the end of the array
155 * @return A reference to this object
157 inline Property::Array& Add( const Value& value )
164 * @brief Const access an element.
167 * @param[in] index The element index to access. No bounds checking is performed
168 * @return The a reference to the element
170 const Value& GetElementAt( SizeType index ) const
172 return operator[]( index );
176 * @brief Accesses an element.
179 * @param[in] index The element index to access. No bounds checking is performed
180 * @return The a reference to the element
182 Value& GetElementAt( SizeType index )
184 return operator[]( index );
188 * @brief Const operator to access an element.
191 * @param[in] index The element index to access. No bounds checking is performed
192 * @return The a reference to the element
195 const Value& operator[]( SizeType index ) const;
198 * @brief Operator to access an element.
201 * @param[in] index The element index to access. No bounds checking is performed
202 * @return The a reference to the element
205 Value& operator[]( SizeType index );
208 * @brief Assignment operator.
211 * @param[in] other The array to copy from
213 * @return The copied array.
215 Array& operator=( const Array& other );
218 * @brief Move assignment operator.
221 * @param[in] other The array to copy from
223 * @return The moved array.
225 * @note After the @a other array is used, it becomes invalid and is no longer usable.
227 Array& operator=( Array&& other );
230 * @brief Output to stream.
233 friend DALI_CORE_API std::ostream& operator<<( std::ostream& stream, const Property::Array& array );
236 struct DALI_INTERNAL Impl; ///< Private data
237 Impl* mImpl; ///< Pointer to private data
241 * @brief Converts the values of the property array into a string and append to an output stream.
244 * @param[in] stream The output stream operator
245 * @param[in] array The array to insert
246 * @return The output stream operator
248 DALI_CORE_API std::ostream& operator<<( std::ostream& stream, const Property::Array& array );
255 #endif // DALI_PROPERTY_ARRAY_H