7a6e173df2df96aed311a182480dc703a1759299
[platform/core/uifw/dali-core.git] / dali / public-api / object / property-array.h
1 #ifndef __DALI_PROPERTY_ARRAY_H__
2 #define __DALI_PROPERTY_ARRAY_H__
3
4 /*
5  * Copyright (c) 2015 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 <string>
23
24 // INTERNAL INCLUDES
25 #include <dali/public-api/common/dali-common.h>
26 #include <dali/public-api/object/property-value.h>
27 #include <dali/public-api/object/property.h>
28
29 namespace Dali
30 {
31
32 /**
33  * @brief A Array of property values.
34  */
35 class DALI_IMPORT_API Property::Array
36 {
37 public:
38
39   typedef std::size_t SizeType;
40
41   /**
42    * @brief Default constructor.
43    */
44   Array();
45
46   /**
47    * @brief Copy Constructor.
48    *
49    * @param[in] other The Array to copy from.
50    */
51   Array( const Array& other );
52
53   /**
54    * @brief Non-virtual destructor.
55    */
56   ~Array();
57
58   /**
59    * @brief Retrieve the number of elements in the array.
60    *
61    * @return The number of elements in the array.
62    */
63   SizeType Size() const
64   {
65     return Count();
66   }
67
68   /**
69    * @brief Retrieve the number of elements in the array.
70    *
71    * @return The number of elements in the array.
72    */
73   SizeType Count() const;
74
75   /**
76    * @brief Returns whether the array is empty.
77    *
78    * @return true if empty, false otherwise
79    */
80   bool Empty() const
81   {
82     return Count() == 0;
83   }
84
85   /**
86    * @brief Clears the array.
87    */
88   void Clear();
89
90   /**
91    * @brief Increase the capcity of the array.
92    */
93   void Reserve( SizeType size );
94
95   /**
96    * @brief Resize to size.
97    */
98   void Resize( SizeType size );
99
100   /**
101    * @brief Retrieve the capacity of the array.
102    *
103    * @return The allocated capacity of the array
104    */
105   SizeType Capacity();
106
107   /**
108    * @brief Add an element to the array.
109    *
110    * @param[in] value The value to add to the end of the array
111    */
112   void PushBack( const Value& value );
113
114   /**
115    * @brief Const access an element.
116    *
117    * @param[in] index The element index to access. No bounds checking is performed.
118    *
119    * @return The a reference to the element.
120    */
121   const Value& GetElementAt( SizeType index ) const
122   {
123     return operator[]( index );
124   }
125
126   /**
127    * @brief Access an element.
128    *
129    * @param[in] index The element index to access. No bounds checking is performed.
130    *
131    * @return The a reference to the element.
132    */
133   Value& GetElementAt( SizeType index )
134   {
135     return operator[]( index );
136   }
137
138   /**
139    * @brief Const operator to access an element.
140    *
141    * @param[in] index The element index to access. No bounds checking is performed.
142    *
143    * @return The a reference to the element.
144    *
145    */
146   const Value& operator[]( SizeType index ) const;
147
148   /**
149    * @brief Operator to access an element.
150    *
151    * @param[in] index The element index to access. No bounds checking is performed.
152    *
153    * @return The a reference to the element.
154    *
155    */
156   Value& operator[]( SizeType index );
157
158   /**
159    * @brief Assignment Operator
160    *
161    * @param[in] other The array to copy from.
162    *
163    * @return The copied array.
164    */
165   Array& operator=( const Array& other );
166
167 private:
168   struct DALI_INTERNAL Impl; ///< Private data
169   Impl* mImpl; ///< Pointer to private data
170 };
171
172 } // namespace Dali
173
174 #endif // __DALI_PROPERTY_ARRAY_H__