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