66b0448eb11a413c6b0104d77897c25b2cb3ebd4
[framework/osp/social.git] / src / FScl_CategoryChangeInfoImpl.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_CategoryChangeInfoImpl.cpp
19  * @brief               This is the implementation for _CategoryChangeInfoImpl class.
20  *
21  * This file contains definitions of @e _CategoryChangeInfoImpl class.
22  */
23
24 #include <new>
25 #include <FBaseResult.h>
26 #include <FSclCategoryChangeInfo.h>
27 #include <FBaseSysLog.h>
28 #include "FScl_RecordImpl.h"
29 #include "FScl_CategoryChangeInfoImpl.h"
30
31 using namespace Tizen::Base;
32 using namespace Tizen::Base::Collection;
33
34 namespace Tizen { namespace Social
35 {
36
37 _CategoryChangeInfoImpl::_CategoryChangeInfoImpl(void)
38         : __categoryId(INVALID_RECORD_ID)
39         , __addressbookId(INVALID_ADDRESSBOOK_ID)
40         , __version(0)
41         , __changeType(RECORD_CHANGE_TYPE_ADDED)
42 {
43         // empty body
44 }
45
46 _CategoryChangeInfoImpl::_CategoryChangeInfoImpl(const _CategoryChangeInfoImpl& rhs)
47 {
48         __categoryId = rhs.__categoryId;
49         __addressbookId = rhs.__addressbookId;
50         __version = rhs.__version;
51         __changeType = rhs.__changeType;
52 }
53
54 _CategoryChangeInfoImpl::~_CategoryChangeInfoImpl(void)
55 {
56         // empty body
57 }
58
59 _CategoryChangeInfoImpl&
60 _CategoryChangeInfoImpl::operator =(const _CategoryChangeInfoImpl& rhs)
61 {
62         if (this == &rhs)
63         {
64                 return *this;
65         }
66
67         __categoryId = rhs.__categoryId;
68         __addressbookId = rhs.__addressbookId;
69         __version = rhs.__version;
70         __changeType = rhs.__changeType;
71
72         return *this;
73 }
74
75 bool
76 _CategoryChangeInfoImpl::operator ==(const _CategoryChangeInfoImpl& rhs) const
77 {
78         if (__categoryId != rhs.__categoryId)
79         {
80                 return false;
81         }
82
83         if (__addressbookId != rhs.__addressbookId)
84         {
85                 return false;
86         }
87
88         if (__version != rhs.__version)
89         {
90                 return false;
91         }
92
93         if (__changeType != rhs.__changeType)
94         {
95                 return false;
96         }
97
98         return true;
99 }
100
101
102 bool
103 _CategoryChangeInfoImpl::Equals(const Object& rhs) const
104 {
105         const _CategoryChangeInfoImpl* pCategoryChangeInfoImpl = dynamic_cast<const _CategoryChangeInfoImpl*>(&rhs);
106
107         if (pCategoryChangeInfoImpl == null)
108         {
109                 return false;
110         }
111
112         return *this == *pCategoryChangeInfoImpl;
113 }
114
115 int
116 _CategoryChangeInfoImpl::GetHashCode(void) const
117 {
118         int hashCode = 0;
119
120         hashCode = __categoryId;
121         hashCode += __addressbookId;
122         hashCode += __version;
123
124         hashCode += __changeType;
125
126         return hashCode;
127 }
128
129 AddressbookId
130 _CategoryChangeInfoImpl::GetAddressbookId(void) const
131 {
132         return __addressbookId;
133 }
134
135 void
136 _CategoryChangeInfoImpl::SetAddressbookId(AddressbookId addressbookId)
137 {
138         __addressbookId = addressbookId;
139 }
140
141 RecordId
142 _CategoryChangeInfoImpl::GetCategoryId(void) const
143 {
144         return __categoryId;
145 }
146
147 int
148 _CategoryChangeInfoImpl::GetVersion(void) const
149 {
150         return __version;
151 }
152
153 RecordChangeType
154 _CategoryChangeInfoImpl::GetChangeType(void) const
155 {
156         return __changeType;
157 }
158
159 void
160 _CategoryChangeInfoImpl::SetCategoryId(RecordId categoryId)
161 {
162         __categoryId = categoryId;
163 }
164
165 void
166 _CategoryChangeInfoImpl::SetVersion(int version)
167 {
168         __version = version;
169 }
170
171 void
172 _CategoryChangeInfoImpl::SetChangeType(RecordChangeType changeType)
173 {
174         __changeType = changeType;
175 }
176
177 _CategoryChangeInfoImpl*
178 _CategoryChangeInfoImpl::GetInstance(CategoryChangeInfo& categoryChangeInfo)
179 {
180         return categoryChangeInfo.__pCategoryChangeInfoImpl;
181 }
182
183 const _CategoryChangeInfoImpl*
184 _CategoryChangeInfoImpl::GetInstance(const CategoryChangeInfo& categoryChangeInfo)
185 {
186         return categoryChangeInfo.__pCategoryChangeInfoImpl;
187 }
188
189 }} // Tizen::Social