Fix code for TDIS-5396
[framework/osp/social.git] / src / FScl_CalEventChangeInfoImpl.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  * @file                FScl_CalEventChangeInfoImpl.cpp
19  * @brief               This is the implementation for _CalEventChangeInfoImpl class.
20  *
21  * This file contains definitions of @e _CalEventChangeInfoImpl class.
22  */
23
24 #include <FSclCalEventChangeInfo.h>
25 #include <FSclRecord.h>
26 #include "FScl_CalEventChangeInfoImpl.h"
27 #include "FScl_RecordImpl.h"
28
29 using namespace Tizen::Base;
30
31 namespace Tizen { namespace Social
32 {
33
34 const static int _INVALID_VERSION = -1;
35
36 _CalEventChangeInfoImpl::_CalEventChangeInfoImpl(void)
37         : __changeType(RECORD_CHANGE_TYPE_ADDED)
38         , __eventId(INVALID_RECORD_ID)
39         , __calendarId(INVALID_RECORD_ID)
40         , __version(_INVALID_VERSION)
41 {
42 }
43
44 _CalEventChangeInfoImpl::_CalEventChangeInfoImpl(const _CalEventChangeInfoImpl& rhs)
45         : __changeType(rhs.__changeType)
46         , __eventId(rhs.__eventId)
47         , __calendarId(rhs.__calendarId)
48         , __version(rhs.__version)
49 {
50 }
51
52 _CalEventChangeInfoImpl::~_CalEventChangeInfoImpl(void)
53 {
54 }
55
56 _CalEventChangeInfoImpl&
57 _CalEventChangeInfoImpl::operator =(const _CalEventChangeInfoImpl& rhs)
58 {
59         if (this == &rhs)
60         {
61                 return *this;
62         }
63
64         __changeType = rhs.__changeType;
65         __eventId = rhs.__eventId;
66         __calendarId = rhs.__calendarId;
67         __version = rhs.__version;
68
69         return *this;
70 }
71
72 bool
73 _CalEventChangeInfoImpl::Equals(const Object& rhs) const
74 {
75         const _CalEventChangeInfoImpl* pCalEventChangeInfoImpl = dynamic_cast<const _CalEventChangeInfoImpl*>(&rhs);
76
77         if (pCalEventChangeInfoImpl == null)
78         {
79                 return false;
80         }
81
82         return (__changeType == pCalEventChangeInfoImpl->__changeType && __eventId == pCalEventChangeInfoImpl->__eventId
83                         && __calendarId == pCalEventChangeInfoImpl->__calendarId && __version == pCalEventChangeInfoImpl->__version);
84 }
85
86 int
87 _CalEventChangeInfoImpl::GetHashCode(void) const
88 {
89         int hashCode = 17;
90
91         hashCode = ( hashCode << 4 ) ^ ( hashCode >> 28 ) ^ __changeType;
92         hashCode = static_cast<int>(( hashCode << 4 ) ^ ( hashCode >> 28 ) ^ __eventId);
93         hashCode = static_cast<int>(( hashCode << 4 ) ^ ( hashCode >> 28 ) ^ __calendarId);
94         hashCode = ( hashCode << 4 ) ^ ( hashCode >> 28 ) ^ __version;
95
96         return hashCode;
97 }
98
99 RecordChangeType
100 _CalEventChangeInfoImpl::GetChangeType(void) const
101 {
102         return __changeType;
103 }
104
105 RecordId
106 _CalEventChangeInfoImpl::GetEventId(void) const
107 {
108         return __eventId;
109 }
110
111 RecordId
112 _CalEventChangeInfoImpl::GetCalendarId(void) const
113 {
114         return __calendarId;
115 }
116
117 int
118 _CalEventChangeInfoImpl::GetVersion(void) const
119 {
120         return __version;
121 }
122
123 void
124 _CalEventChangeInfoImpl::SetChangeType(RecordChangeType changeType)
125 {
126         __changeType = changeType;
127 }
128
129 void
130 _CalEventChangeInfoImpl::SetEventId(RecordId eventId)
131 {
132         __eventId = eventId;
133 }
134
135 void
136 _CalEventChangeInfoImpl::SetCalendarId(RecordId calendarId)
137 {
138         __calendarId = calendarId;
139 }
140
141 void
142 _CalEventChangeInfoImpl::SetVersion(int version)
143 {
144         __version = version;
145 }
146
147 _CalEventChangeInfoImpl*
148 _CalEventChangeInfoImpl::GetInstance(CalEventChangeInfo& calEventChangeInfo)
149 {
150         return calEventChangeInfo.__pCalEventChangeInfoImpl;
151 }
152
153 const _CalEventChangeInfoImpl*
154 _CalEventChangeInfoImpl::GetInstance(const CalEventChangeInfo& calEventChangeInfo)
155 {
156         return calEventChangeInfo.__pCalEventChangeInfoImpl;
157 }
158
159 }}      // Tizen::Social