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