Modify doxygen group names
[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.
40  */
41 class DALI_IMPORT_API Property::Map
42 {
43 public:
44
45   typedef std::size_t SizeType;
46
47   /**
48    * @brief Default constructor.
49    */
50   Map();
51
52   /**
53    * @brief Copy Constructor.
54    *
55    * @param[in] other The Map to copy from.
56    */
57   Map( const Map& other );
58
59   /**
60    * @brief Non-virtual destructor.
61    */
62   ~Map();
63
64   /**
65    * @brief Retrieve the number of elements in the map.
66    *
67    * @return The number of elements in the map.
68    */
69   SizeType Count() const;
70
71   /**
72    * @brief Returns whether the map is empty.
73    *
74    * @return true if empty, false otherwise
75    */
76   bool Empty() const;
77
78   /**
79    * @brief Inserts the key-value pair in the Map.
80    *
81    * Does not check for duplicates
82    * @param key to insert
83    * @param value to insert
84    */
85   void Insert( const char* key, const Value& value );
86
87   /**
88    * @brief Inserts the key-value pair in the Map.
89    *
90    * Does not check for duplicates
91    * @param key to insert
92    * @param value to insert
93    */
94   void Insert( const std::string& key, const Value& value );
95
96   /**
97    * @brief Retrieve the value at the specified position.
98    *
99    * @return A reference to the value at the specified position.
100    *
101    * @note Will assert if position >= Count()
102    */
103   Value& GetValue( SizeType position ) const;
104
105   /**
106    * @brief Retrieve the key at the specified position.
107    *
108    * @return A const reference to the key at the specified position.
109    *
110    * @note Will assert if position >= Count()
111    */
112   const std::string& GetKey( SizeType position ) const;
113
114   /**
115    * @brief Retrieve the key & the value at the specified position.
116    *
117    * @return A reference to the pair of key and value at the specified position.
118    *
119    * @note Will assert if position >= Count()
120    */
121   StringValuePair& GetPair( SizeType position ) const;
122
123   /**
124    * @brief Finds the value for the specified key if it exists.
125    *
126    * @param[in]  key   The key to find.
127    *
128    * @return A const pointer to the value if it exists, NULL otherwise
129    */
130   Value* Find( const char* key ) const;
131
132   /**
133    * @brief Finds the value for the specified key if it exists.
134    *
135    * @param[in]  key   The key to find.
136    *
137    * @return A const pointer to the value if it exists, NULL otherwise
138    */
139   Value* Find( const std::string& key ) const;
140
141   /**
142    * @brief Finds the value for the specified key if it exists and its type is type
143    *
144    * @param[in]  key   The key to find.
145    * @param[in]  type  The type to check.
146    *
147    * @return A const pointer to the value if it exists, NULL otherwise
148    */
149   Value* Find( const std::string& key, Property::Type type ) const;
150
151   /**
152    * @brief Clears the map.
153    */
154   void Clear();
155
156   /**
157    * @brief Merges values from the map 'from' to the current.
158    *
159    * Any values in 'from' will overwrite the values in the current map.
160    *
161    * @param[in]  from  The map to merge from.
162    */
163   void Merge( const Map& from );
164
165   /**
166    * @brief Const operator to access element with the specified key.
167    *
168    * @param[in] key The key whose value to access.
169    *
170    * @return The value for the element with the specified key, if key doesn't exist, then Property::NONE is returned.
171    *
172    * @note Will assert if invalid-key is given.
173    */
174   const Value& operator[]( const std::string& key ) const;
175
176   /**
177    * @brief Operator to access the element with the specified key.
178    *
179    * @param[in] key The key whose value to access.
180    *
181    * @return A reference to the value for the element with the specified key.
182    *
183    * @note If an element with the key does not exist, then it is created.
184    */
185   Value& operator[]( const std::string& key );
186
187   /**
188    * @brief Assignment Operator
189    *
190    * @param[in] other The map to copy from.
191    *
192    * @return The copied map.
193    */
194   Map& operator=( const Map& other );
195
196 private:
197   struct DALI_INTERNAL Impl; ///< Private data
198   Impl* mImpl; ///< Pointer to private data
199 };
200
201 /**
202  * @}
203  */
204 } // namespace Dali
205
206 #endif // __DALI_PROPERTY_MAP_H__