Merge "Update deprecated libprivilege-control API functions." into tizen
[platform/framework/native/appfw.git] / inc / FBaseColMapEntryT.h
1 //
2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
3 //
4 // Licensed under the Apache License, Version 2.0 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16
17 /**
18  * @file                FBaseColMapEntryT.h
19  * @brief               This is the header file for the %MapEntryT class.
20  *
21  * This header file contains the declarations of the %MapEntryT class.
22  */
23 #ifndef _FBASE_COL_MAP_ENTRY_T_H_
24 #define _FBASE_COL_MAP_ENTRY_T_H_
25
26 #include <FBaseObject.h>
27
28 namespace Tizen { namespace Base { namespace Collection
29 {
30
31 /**
32  * @class       MapEntryT
33  * @brief       This class represents a template-based key-value pair.
34  *
35  * @since 2.0
36  *
37  * The %MapEntryT class represents a template-based key-value pair.
38  *
39  * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/base/mapentry.htm">MapEntry</a>.
40  *
41  */
42 template< class KeyType, class ValueType >
43 class MapEntryT
44         : public Tizen::Base::Object
45 {
46 public:
47         /**
48          * This is the default constructor for this class.
49          *
50          * @since 2.0
51          */
52         MapEntryT(void)
53                 : __key(0)
54                 , __val(0)
55         {
56         }
57
58         /**
59          * Initializes this instance of %MapEntryT with the specified key-value pair.
60          *
61          * @since 2.0
62          *
63          * @param[in]   key             The key for this mapping
64          * @param[in]   value   The value for this mapping
65          */
66         MapEntryT(const KeyType& key, const ValueType& value)
67                 : __key(key)
68                 , __val(value)
69         {
70
71         }
72
73         /**
74          * This destructor overrides Tizen::Base::Object::~Object().
75          *
76          * @since 2.0
77          */
78         virtual ~MapEntryT(void)
79         {
80
81         }
82
83         /**
84          * Copying of objects using this copy assignment operator is allowed.
85          *
86          * @since 2.0
87          *
88          * @param[in]   entry   An instance of %MapEntryT
89          */
90         MapEntryT< KeyType, ValueType >& operator =(const MapEntryT< KeyType, ValueType >& entry)
91         {
92                 if (&entry != this)
93                 {
94                         __key = entry.__key;
95                         __val = entry.__val;
96                 }
97
98                 return *this;
99         }
100
101         /**
102          * Gets the key corresponding to this entry.
103          *
104          * @since 2.0
105          *
106          * @return      The key corresponding to this entry
107          * @see         GetValue()
108          */
109         virtual const KeyType& GetKey(void) const
110         {
111                 return __key;
112         }
113
114         /**
115          * Gets the value corresponding to this entry.
116          *
117          * @since 2.0
118          *
119          * @return      The value corresponding to this entry
120          * @see                 GetKey()
121          */
122         virtual const ValueType& GetValue(void) const
123         {
124                 return __val;
125         }
126
127         /**
128          * Gets the hash value of the current instance.
129          *
130          * @since 2.0
131          *
132          * @return      The hash value of the current instance
133          * @remarks     The two Tizen::Base::Object::Equals() instances must return the same hash value. @n
134          *                      For better performance, the used hash function must generate a random distribution for all the inputs.
135          */
136         virtual int GetHashCode(void) const
137         {
138                 int hash = 0;
139                 hash += reinterpret_cast< int >(&__key);
140                 hash += reinterpret_cast< int >(&__val);
141                 return hash;
142         }
143
144 private:
145         KeyType __key;
146         ValueType __val;
147
148 }; // MapEntryT
149
150 }}} // Tizen::Base::Collection
151
152 #endif // _FBASE_COL_MAP_ENTRY_T_H_