Merge "Add dali-vector extension support for types that have destructor and/or copy...
[platform/core/uifw/dali-core.git] / dali / public-api / object / property-array.cpp
1 /*
2  * Copyright (c) 2015 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 // CLASS HEADER
19 #include <dali/public-api/object/property-array.h>
20
21 // INTERNAL INCLUDES
22 #include <dali/public-api/common/vector-wrapper.h>
23
24 namespace Dali
25 {
26
27 namespace
28 {
29 }; // unnamed namespace
30
31 struct Property::Array::Impl
32 {
33   typedef std::vector<Value> Array;
34
35   Array mArray;
36 };
37
38 Property::Array::Array()
39 : mImpl( new Impl )
40 {
41 }
42
43 Property::Array::Array( const Property::Array& other )
44 : mImpl( new Impl )
45 {
46   mImpl->mArray = other.mImpl->mArray;
47 }
48
49 Property::Array::~Array()
50 {
51   delete mImpl;
52 }
53
54
55 unsigned int Property::Array::Size() const
56 {
57   return mImpl->mArray.size();
58 }
59
60 unsigned int Property::Array::Count() const
61 {
62   return Size();
63 }
64
65 void Property::Array::PushBack(const Value& value)
66 {
67   mImpl->mArray.push_back( value );
68 }
69
70 bool Property::Array::Empty() const
71 {
72   return mImpl->mArray.empty();
73 }
74
75 void Property::Array::Clear()
76 {
77   mImpl->mArray.clear();
78 }
79
80 void Property::Array::Reserve(size_t size)
81 {
82   mImpl->mArray.reserve(size);
83 }
84
85 void Property::Array::Resize(size_t size)
86 {
87   mImpl->mArray.resize(size);
88 }
89
90 size_t Property::Array::Capacity()
91 {
92   return mImpl->mArray.capacity();
93 }
94
95 const Property::Value& Property::Array::operator[]( const std::size_t index ) const
96 {
97   return mImpl->mArray[ index ];
98 }
99
100 Property::Value& Property::Array::operator[]( const std::size_t index )
101 {
102   return mImpl->mArray[ index ];
103 }
104
105 Property::Array& Property::Array::operator=( const Property::Array& other )
106 {
107   if( this != &other )
108   {
109     delete mImpl;
110     mImpl = new Impl;
111     mImpl->mArray = other.mImpl->mArray;
112   }
113   return *this;
114 }
115
116 } // namespace Dali