sync with tizen_2.0
[platform/framework/native/appfw.git] / src / base / collection / FBaseColMapEntry.cpp
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                FBaseColMapEntry.cpp
20  * @brief               This is the implementation for MapEntry class.
21  */
22
23 #include <FBaseColMapEntry.h>
24 #include <FBaseErrors.h>
25
26
27 namespace Tizen { namespace Base { namespace Collection
28 {
29
30 MapEntry::MapEntry(void)
31         : _pKey(null)
32         , _pValue(null)
33         , __pMapEntryImpl(null)
34 {
35 }
36
37 MapEntry::MapEntry(const Object& pKey, const Object& pValue)
38         : __pMapEntryImpl(null)
39 {
40         _pKey = const_cast <Object*>(&pKey);
41         _pValue = const_cast <Object*>(&pValue);
42 }
43
44 MapEntry::~MapEntry(void)
45 {
46 }
47
48 const Object*
49 MapEntry::GetKey(void) const
50 {
51         return _pKey;
52 }
53
54 const Object*
55 MapEntry::GetValue(void) const
56 {
57         return _pValue;
58 }
59
60 Object*
61 MapEntry::GetKey(void)
62 {
63         return _pKey;
64 }
65
66 Object*
67 MapEntry::GetValue(void)
68 {
69         return _pValue;
70 }
71
72 bool
73 MapEntry::Equals(const Object& obj) const
74 {
75         const MapEntry* pOther = dynamic_cast <const MapEntry*>(&obj);
76         if (pOther == null)
77         {
78                 return false;
79         }
80
81         if (_pKey->Equals(*(pOther->_pKey)) && _pValue->Equals(*(pOther->_pValue)))
82         {
83                 return true;
84         }
85
86         return false;
87 }
88 int
89 MapEntry::GetHashCode(void) const
90 {
91         int hash = 0;
92         if (_pKey != null)
93         {
94                 hash += _pKey->GetHashCode();
95         }
96         if (_pValue != null)
97         {
98                 hash += _pValue->GetHashCode();
99         }
100         return hash;
101 }
102 } } }  // Tizen::Base::Collection