Merge "Klockwork: Remove unreachable code" into tizen
[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) 2014 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 Clears the map.
109    */
110   void Clear();
111
112   /**
113    * @brief Merges values from the map 'from' to the current.
114    *
115    * Any values in 'from' will overwrite the values in the current map.
116    *
117    * @param[in]  from  The map to merge from.
118    */
119   void Merge( const Map& from );
120
121   /**
122    * @brief Const operator to access element with the specified key.
123    *
124    * @param[in] key The key whose value to access.
125    *
126    * @return The value for the element with the specified key, if key doesn't exist, then Property::NONE is returned.
127    *
128    * @note Will assert if invalid-key is given.
129    */
130   const Value& operator[]( const std::string& key ) const;
131
132   /**
133    * @brief Operator to access the element with the specified key.
134    *
135    * @param[in] key The key whose value to access.
136    *
137    * @return A reference to the value for the element with the specified key.
138    *
139    * @note If an element with the key does not exist, then it is created.
140    */
141   Value& operator[]( const std::string& key );
142
143   /**
144    * @brief Assignment Operator
145    *
146    * @param[in] other The map to copy from.
147    *
148    * @return The copied map.
149    */
150   Map& operator=( const Map& other );
151
152 private:
153   struct DALI_INTERNAL Impl; ///< Private data
154   Impl* mImpl; ///< Pointer to private data
155 };
156
157 } // namespace Dali
158
159 #endif // __DALI_PROPERTY_MAP_H__