Fix code for TDIS-5396
[framework/osp/social.git] / src / FScl_ContactEventImpl.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_ContactEventImpl.cpp
19 * @brief        This is the implementation for _ContactEventImpl class.
20 *
21 * This file contains definitions of @e _ContactEventImpl class.
22 */
23
24 #include <FSclContactEvent.h>
25 #include <FBaseSysLog.h>
26 #include "FScl_ContactEventImpl.h"
27
28 using namespace Tizen::Base;
29
30 namespace Tizen { namespace Social
31 {
32
33 _ContactEventImpl::_ContactEventImpl(void)
34 : __type(CONTACT_EVENT_TYPE_BIRTHDAY)
35 , __isDateChanged(false)
36 {
37 }
38
39 _ContactEventImpl::_ContactEventImpl(const _ContactEventImpl& rhs)
40 {
41         __date = rhs.__date;
42         __type = rhs.__type;
43         __label = rhs.__label;
44         __isDateChanged = rhs.__isDateChanged;
45 }
46
47 _ContactEventImpl::~_ContactEventImpl(void)
48 {
49
50 }
51
52 _ContactEventImpl&
53 _ContactEventImpl::operator =(const _ContactEventImpl& rhs)
54 {
55         if (this == &rhs)
56         {
57                 return *this;
58         }
59
60         __date = rhs.__date;
61         __type = rhs.__type;
62         __label = rhs.__label;
63         __isDateChanged = rhs.__isDateChanged;
64
65         return *this;
66 }
67
68 bool
69 _ContactEventImpl::operator ==(const _ContactEventImpl& rhs) const
70 {
71         if (__date != rhs.__date)
72         {
73                 return false;
74         }
75
76         if (__type != rhs.__type)
77         {
78                 return false;
79         }
80
81         if (__label != rhs.__label)
82         {
83                 return false;
84         }
85
86         return true;
87 }
88
89 bool
90 _ContactEventImpl::operator !=(const _ContactEventImpl& rhs) const
91 {
92         return !(*this == rhs);
93 }
94
95 bool
96 _ContactEventImpl::Equals(const Object& rhs) const
97 {
98         const _ContactEventImpl* pContactEvent = dynamic_cast<const _ContactEventImpl*>(&rhs);
99         if (pContactEvent == null)
100         {
101                 return false;
102         }
103
104         return *this == *pContactEvent;
105 }
106
107 int
108 _ContactEventImpl::GetHashCode(void) const
109 {
110         int hash = __date.GetHashCode() + __label.GetHashCode() + __type;
111
112         return hash;
113 }
114
115 ContactEventType
116 _ContactEventImpl::GetType(void) const
117 {
118         return __type;
119 }
120
121 DateTime
122 _ContactEventImpl::GetDate(void) const
123 {
124         return __date;
125 }
126
127 String
128 _ContactEventImpl::GetLabel(void) const
129 {
130         return __label;
131 }
132
133 void
134 _ContactEventImpl::SetType(ContactEventType type)
135 {
136         __type = type;
137 }
138
139 void
140 _ContactEventImpl::SetDate(const DateTime& date)
141 {
142         __date = date;
143         __isDateChanged = true;
144 }
145
146 void
147 _ContactEventImpl::SetLabel(const String& label)
148 {
149         __label = label;
150 }
151
152 bool
153 _ContactEventImpl::IsDateChanged(void) const
154 {
155         return __isDateChanged;
156 }
157
158 const _ContactEventImpl*
159 _ContactEventImpl::GetInstance(const ContactEvent& contactEvent)
160 {
161         return contactEvent.__pContactEventImpl;
162 }
163
164 _ContactEventImpl*
165 _ContactEventImpl::GetInstance(ContactEvent& contactEvent)
166 {
167         return contactEvent.__pContactEventImpl;
168 }
169
170 }} // Tizen::Social