2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 // Licensed under the Apache License, Version 2.0 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
8 // http://www.apache.org/licenses/LICENSE-2.0
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
17 * @file FScl_PhoneNumberImpl.cpp
18 * @brief This is the implementation for _PhoneNumberImpl class.
20 * This file contains definitions of @e _PhoneNumberImpl class.
23 #include <unique_ptr.h>
24 #include <FSclPhoneNumber.h>
25 #include <FBaseSysLog.h>
26 #include <FBase_StringConverter.h>
27 #include "FScl_PhoneNumberImpl.h"
29 using namespace Tizen::Base;
31 namespace Tizen { namespace Social
34 _PhoneNumberImpl::_PhoneNumberImpl(void)
36 , __type(PHONENUMBER_TYPE_HOME)
37 , __isPhoneTypeChanged(false)
42 _PhoneNumberImpl::_PhoneNumberImpl(PhoneNumberType type, const String& number)
46 , __isPhoneTypeChanged(false)
51 _PhoneNumberImpl::_PhoneNumberImpl(const _PhoneNumberImpl& rhs)
53 __recordId = rhs.__recordId;
55 __label = rhs.__label;
56 __number = rhs.__number;
57 __isPhoneTypeChanged = rhs.__isPhoneTypeChanged;
60 _PhoneNumberImpl::~_PhoneNumberImpl(void)
65 _PhoneNumberImpl::operator =(const _PhoneNumberImpl& rhs)
72 __recordId = rhs.__recordId;
74 __label = rhs.__label;
75 __number = rhs.__number;
76 __isPhoneTypeChanged = rhs.__isPhoneTypeChanged;
82 _PhoneNumberImpl::operator ==(const _PhoneNumberImpl& rhs) const
84 if (__type != rhs.__type || __label != rhs.__label || __number != rhs.__number)
93 _PhoneNumberImpl::Equals(const Object& rhs) const
95 const _PhoneNumberImpl* pPhoneNumberImpl = dynamic_cast<const _PhoneNumberImpl*>(&rhs);
97 if (pPhoneNumberImpl == null)
102 return (*this == *pPhoneNumberImpl);
106 _PhoneNumberImpl::GetHashCode(void) const
108 int hashCode = __recordId;
110 hashCode += __number.GetHashCode();
111 hashCode += __label.GetHashCode();
117 _PhoneNumberImpl::operator !=(const _PhoneNumberImpl& rhs) const
119 return !(*this == rhs);
123 _PhoneNumberImpl::GetType(void) const
129 _PhoneNumberImpl::GetPhoneNumber(void) const
135 _PhoneNumberImpl::SetType(PhoneNumberType type)
138 __isPhoneTypeChanged = true;
142 _PhoneNumberImpl::SetPhoneNumber(const String& number)
144 SysTryReturn(NID_SCL, !number.IsEmpty(), E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The phone number is empty.", GetErrorMessage(E_INVALID_ARG));
152 _PhoneNumberImpl::SetLabel(const String& label)
158 _PhoneNumberImpl::GetLabel(void) const
164 _PhoneNumberImpl::SetRecordId(int recordId)
166 __recordId = recordId;
170 _PhoneNumberImpl::GetRecordId(void) const
176 _PhoneNumberImpl::IsEmpty(void) const
178 return __number.IsEmpty();
182 _PhoneNumberImpl::IsPhoneNumberTypeChanged(void) const
184 return __isPhoneTypeChanged;
188 _PhoneNumberImpl::GetInstance(PhoneNumber& phoneNumber)
190 return phoneNumber.__pPhoneNumberImpl;
193 const _PhoneNumberImpl*
194 _PhoneNumberImpl::GetInstance(const PhoneNumber& phoneNumber)
196 return phoneNumber.__pPhoneNumberImpl;