ad2aa835e3092f521eaf0da0960d63550331f0cb
[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
29 namespace Tizen { namespace Base { namespace Collection
30 {
31
32 /**
33  * @class MapEntryT
34  * @brief       This class represents a template-based key-value pair.
35  *
36  * @since 2.0
37  *
38  * The %MapEntryT class represents a template-based key-value pair.
39  *
40  * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/base/mapentry.htm">MapEntry</a>.
41  *
42  */
43 template< class KeyType, class ValueType >
44 class MapEntryT
45         : public Tizen::Base::Object
46 {
47 public:
48         /**
49          * This is the default constructor for this class.
50          *
51          * @since 2.0
52          */
53         MapEntryT(void)
54                 : __key(0)
55                 , __val(0)
56         {
57         }
58
59         /**
60          * Initializes this instance of %MapEntryT with the specified key-value pair.
61          *
62          * @since 2.0
63          *
64          * @param[in]   key The key for this mapping
65          * @param[in]   value   The value for this mapping
66          */
67         MapEntryT(const KeyType& key, const ValueType& value)
68                 : __key(key)
69                 , __val(value)
70         {
71
72         }
73
74         /**
75          * This destructor overrides Tizen::Base::Object::~Object().
76          *
77          * @since 2.0
78          */
79         virtual ~MapEntryT(void)
80         {
81
82         }
83
84         /**
85          * Copying of objects using this copy assignment operator is allowed.
86          *
87          * @since 2.0
88          *
89          * @param[in]   entry   An instance of %MapEntryT
90          */
91         MapEntryT< KeyType, ValueType >& operator =(const MapEntryT< KeyType, ValueType >& entry)
92         {
93                 if (&entry != this)
94                 {
95                         __key = entry.__key;
96                         __val = entry.__val;
97                 }
98
99                 return *this;
100         }
101
102         /**
103          * Gets the key corresponding to this entry.
104          *
105          * @since 2.0
106          *
107          * @return      The key corresponding to this entry
108          * @see                 GetValue()
109          */
110         virtual const KeyType& GetKey(void) const
111         {
112                 return __key;
113         }
114
115         /**
116          * Gets the value corresponding to this entry.
117          *
118          * @since 2.0
119          *
120          * @return      The value corresponding to this entry
121          * @see                 GetKey()
122          */
123         virtual const ValueType& GetValue(void) const
124         {
125                 return __val;
126         }
127
128         /**
129          * Gets the hash value of the current instance.
130          *
131          * @since 2.0
132          *
133          * @return      The hash value of the current instance
134          * @remarks     The two Tizen::Base::Object::Equals() instances must return the same hash value. For better performance, @n
135          *                      the used hash function must generate a random distribution for all inputs.
136          */
137         virtual int GetHashCode(void) const
138         {
139                 int hash = 0;
140                 hash += reinterpret_cast< int >(&__key);
141                 hash += reinterpret_cast< int >(&__val);
142                 return hash;
143         }
144
145 private:
146         KeyType __key;
147         ValueType __val;
148
149 }; // MapEntryT
150
151 }}} // Tizen::Base::Collection
152
153 #endif // _FBASE_COL_MAP_ENTRY_T_H_