[3.0] Add missed doxygen documentation
[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 /**
32  * @addtogroup dali_core_object
33  * @{
34  */
35
36 typedef std::pair<std::string, Property::Value> StringValuePair;
37
38 /**
39  * @brief A Map of property values, the key type could be String or Property::Index.
40  * @SINCE_1_0.0
41  */
42 class DALI_IMPORT_API Property::Map
43 {
44 public:
45
46   typedef std::size_t SizeType;
47
48   /**
49    * @brief Default constructor.
50    * @SINCE_1_0.0
51    */
52   Map();
53
54   /**
55    * @brief Copy Constructor.
56    *
57    * @SINCE_1_0.0
58    * @param[in] other The Map to copy from.
59    */
60   Map( const Map& other );
61
62   /**
63    * @brief Non-virtual destructor.
64    * @SINCE_1_0.0
65    */
66   ~Map();
67
68   /**
69    * @brief Retrieve the number of elements in the map.
70    *
71    * @SINCE_1_0.0
72    * @return The number of elements in the map.
73    */
74   SizeType Count() const;
75
76   /**
77    * @brief Returns whether the map is empty.
78    *
79    * @SINCE_1_0.0
80    * @return true if empty, false otherwise
81    */
82   bool Empty() const;
83
84   /**
85    * @brief Inserts the key-value pair in the Map, with the key type as string.
86    *
87    * Does not check for duplicates
88    * @SINCE_1_0.0
89    * @param key to insert
90    * @param value to insert
91    */
92   void Insert( const char* key, const Value& value );
93
94   /**
95    * @brief Inserts the key-value pair in the Map, with the key type as string.
96    *
97    * Does not check for duplicates
98    * @SINCE_1_0.0
99    * @param key to insert
100    * @param value to insert
101    */
102   void Insert( const std::string& key, const Value& value );
103
104   /**
105    * @brief Inserts the key-value pair in the Map, with the key type as index.
106    *
107    * Does not check for duplicates
108    * @SINCE_1_1.39
109    * @param key to insert
110    * @param value to insert
111    */
112   void Insert( Property::Index key, const Value& value );
113
114   /**
115    * DEPRECATED_1_1.39. Retrieve the value with key instead of position, Use Find( key ) instead.
116    *
117    * @brief Retrieve the value of the string-value pair at the specified position.
118    *
119    * @SINCE_1_0.0
120    * @param[in] position The specified position
121    * @return A reference to the value at the specified position.
122    *
123    * @note Will assert if position >= Count()
124    */
125   Value& GetValue( SizeType position ) const;
126
127   /**
128    * DEPRECATED_1_1.39 Position based retrieval is no longer supported after extending the key type to both Index and String.
129    *
130    * @brief Retrieve the key at the specified position.
131    *
132    * @SINCE_1_0.0
133    * @param[in] position The specified position
134    * @return A const reference to the key at the specified position.
135    *
136    * @note Will assert if position >= Count()
137    */
138   const std::string& GetKey( SizeType position ) const;
139
140   /**
141    * DEPRECATED_1_1.39 Position based retrieval is no longer supported after extending the key type to both Index and String.
142    *
143    * @brief Retrieve the key & the value at the specified position.
144    *
145    * @SINCE_1_0.0
146    * @param[in] position The specified position
147    * @return A reference to the pair of key and value at the specified position.
148    *
149    * @note Will assert if position >= Count()
150    */
151   StringValuePair& GetPair( SizeType position ) const;
152
153   /**
154    * @brief Finds the value for the specified key if it exists.
155    *
156    * @SINCE_1_0.0
157    * @param[in]  key   The key to find.
158    *
159    * @return A const pointer to the value if it exists, NULL otherwise
160    */
161   Value* Find( const char* key ) const;
162
163   /**
164    * @brief Finds the value for the specified key if it exists.
165    *
166    * @SINCE_1_0.0
167    * @param[in]  key   The key to find.
168    *
169    * @return A const pointer to the value if it exists, NULL otherwise
170    */
171   Value* Find( const std::string& key ) const;
172
173   /**
174    * @brief Finds the value for the specified key if it exists.
175    *
176    * @SINCE_1_1.39
177    * @param[in]  key   The key to find.
178    *
179    * @return A const pointer to the value if it exists, NULL otherwise
180    */
181   Value* Find( Property::Index key ) const;
182
183   /**
184    * @brief Finds the value for the specified keys if either exist.
185    *
186    * Will search for the index key first.
187    *
188    * @SINCE_1_1.45
189    * @param[in]  indexKey   The index key to find.
190    * @param[in]  stringKey  The string key to find.
191    *
192    * @return A const pointer to the value if it exists, NULL otherwise
193    */
194   Value* Find( Property::Index indexKey, const std::string& stringKey ) const;
195
196   /**
197    * @brief Finds the value for the specified key if it exists and its type is type
198    *
199    * @SINCE_1_0.0
200    * @param[in]  key   The key to find.
201    * @param[in]  type  The type to check.
202    *
203    * @return A const pointer to the value if it exists, NULL otherwise
204    */
205   Value* Find( const std::string& key, Property::Type type ) const;
206
207   /**
208    * @brief Finds the value for the specified key if it exists and its type is type
209    *
210    * @SINCE_1_1.39
211    * @param[in]  key   The key to find.
212    * @param[in]  type  The type to check.
213    *
214    * @return A const pointer to the value if it exists, NULL otherwise
215    */
216   Value* Find( Property::Index key, Property::Type type ) const;
217
218   /**
219    * @brief Clears the map.
220    * @SINCE_1_0.0
221    */
222   void Clear();
223
224   /**
225    * @brief Merges values from the map 'from' to the current.
226    *
227    * Any values in 'from' will overwrite the values in the current map.
228    *
229    * @SINCE_1_0.0
230    * @param[in]  from  The map to merge from.
231    */
232   void Merge( const Map& from );
233
234   /**
235    * @brief Const operator to access element with the specified string key.
236    *
237    * @SINCE_1_0.0
238    * @param[in] key The key whose value to access.
239    *
240    * @return The value for the element with the specified key, if key doesn't exist, then Property::NONE is returned.
241    *
242    * @note Will assert if invalid-key is given.
243    */
244   const Value& operator[]( const std::string& key ) const;
245
246   /**
247    * @brief Operator to access the element with the specified string key.
248    *
249    * @SINCE_1_0.0
250    * @param[in] key The key whose value to access.
251    *
252    * @return A reference to the value for the element with the specified key.
253    *
254    * @note If an element with the key does not exist, then it is created.
255    */
256   Value& operator[]( const std::string& key );
257
258   /**
259    * @brief Const operator to access element with the specified index key.
260    *
261    * @SINCE_1_1.39
262    * @param[in] key The key whose value to access.
263    *
264    * @return The value for the element with the specified key, if key doesn't exist, then Property::NONE is returned.
265    *
266    * @note Will assert if invalid-key is given.
267    */
268   const Value& operator[]( Property::Index key ) const;
269
270   /**
271    * @brief Operator to access the element with the specified index key.
272    *
273    * @SINCE_1_1.39
274    * @param[in] key The key whose value to access.
275    *
276    * @return A reference to the value for the element with the specified key.
277    *
278    * @note If an element with the key does not exist, then it is created.
279    */
280   Value& operator[]( Property::Index key );
281
282   /**
283    * @brief Assignment Operator
284    *
285    * @SINCE_1_0.0
286    * @param[in] other The map to copy from.
287    *
288    * @return The copied map.
289    */
290   Map& operator=( const Map& other );
291
292   /**
293    * @brief output to stream
294    * @SINCE_1_1.28
295    */
296   friend std::ostream& operator<<( std::ostream& stream, const Property::Map& map );
297
298 private:
299   struct DALI_INTERNAL Impl; ///< Private data
300   Impl* mImpl; ///< Pointer to private data
301 };
302
303 /**
304  * @brief Convert the key/value pairs of the property map into a string and append to an output stream.
305  *
306  * @SINCE_1_1.28
307  * @param [in] stream The output stream operator.
308  * @param [in] map The map to insert
309  * @return The output stream operator.
310  */
311 DALI_IMPORT_API std::ostream& operator<<( std::ostream& stream, const Property::Map& map );
312
313
314 /**
315  * @}
316  */
317 } // namespace Dali
318
319 #endif // __DALI_PROPERTY_MAP_H__