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