Remove std::vector from public api
[platform/core/uifw/dali-core.git] / dali / public-api / object / property-map.h
1 #ifndef __DALI_PROPERTY_MAP_H__
2 #define __DALI_PROPERTY_MAP_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 typedef std::pair<std::string, Property::Value> StringValuePair;
32
33 /**
34  * @brief A Map of property values.
35  */
36 class DALI_IMPORT_API Property::Map
37 {
38 public:
39
40   /**
41    * @brief Default constructor.
42    */
43   Map();
44
45   /**
46    * @brief Copy Constructor.
47    *
48    * @param[in] other The Map to copy from.
49    */
50   Map( const Map& other );
51
52   /**
53    * @brief Non-virtual destructor.
54    */
55   ~Map();
56
57   /**
58    * @brief Retrieve the number of elements in the map.
59    *
60    * @return The number of elements in the map.
61    */
62   unsigned int Count() const;
63
64   /**
65    * @brief Returns whether the map is empty.
66    *
67    * @return true if empty, false otherwise
68    */
69   bool Empty() const;
70
71   /**
72    * @brief Retrieve the value at the specified position.
73    *
74    * @return A reference to the value at the specified position.
75    *
76    * @note Will assert if position >= Count()
77    */
78   Value& GetValue( unsigned int position ) const;
79
80   /**
81    * @brief Retrieve the key at the specified position.
82    *
83    * @return A const reference to the key at the specified position.
84    *
85    * @note Will assert if position >= Count()
86    */
87   const std::string& GetKey( unsigned int position ) const;
88
89   /**
90    * @brief Retrieve the key & the value at the specified position.
91    *
92    * @return A reference to the pair of key and value at the specified position.
93    *
94    * @note Will assert if position >= Count()
95    */
96   StringValuePair& GetPair( unsigned int position ) const;
97
98   /**
99    * @brief Finds the value for the specified key if it exists.
100    *
101    * @param[in]  key   The key to find.
102    *
103    * @return A const pointer to the value if it exists, NULL otherwise
104    */
105   Value* Find( const std::string& key ) const;
106
107   /**
108    * @brief Finds the value for the specified key if it exists and its type is type
109    *
110    * @param[in]  key   The key to find.
111    * @param[in]  type  The type to check.
112    *
113    * @return A const pointer to the value if it exists, NULL otherwise
114    */
115   Value* Find( const std::string& key, Property::Type type ) const;
116
117   /**
118    * @brief Clears the map.
119    */
120   void Clear();
121
122   /**
123    * @brief Merges values from the map 'from' to the current.
124    *
125    * Any values in 'from' will overwrite the values in the current map.
126    *
127    * @param[in]  from  The map to merge from.
128    */
129   void Merge( const Map& from );
130
131   /**
132    * @brief Const operator to access element with the specified key.
133    *
134    * @param[in] key The key whose value to access.
135    *
136    * @return The value for the element with the specified key, if key doesn't exist, then Property::NONE is returned.
137    *
138    * @note Will assert if invalid-key is given.
139    */
140   const Value& operator[]( const std::string& key ) const;
141
142   /**
143    * @brief Operator to access the element with the specified key.
144    *
145    * @param[in] key The key whose value to access.
146    *
147    * @return A reference to the value for the element with the specified key.
148    *
149    * @note If an element with the key does not exist, then it is created.
150    */
151   Value& operator[]( const std::string& key );
152
153   /**
154    * @brief Assignment Operator
155    *
156    * @param[in] other The map to copy from.
157    *
158    * @return The copied map.
159    */
160   Map& operator=( const Map& other );
161
162 private:
163   struct DALI_INTERNAL Impl; ///< Private data
164   Impl* mImpl; ///< Pointer to private data
165 };
166
167 } // namespace Dali
168
169 #endif // __DALI_PROPERTY_MAP_H__