Merge "Export internal APIs needed by samsung-socil" into tizen_2.1
[framework/osp/social.git] / src / FScl_RelationshipImpl.cpp
1 //
2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
3 //
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
7 //
8 //     http://www.apache.org/licenses/LICENSE-2.0
9 //
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.
15 //
16 /**
17 * @file         FScl_RelationshipImpl.cpp
18 * @brief        This is the implementation for _RelationshipImpl class.
19 *
20 * This file contains definitions of @e _RelationshipImpl class.
21 */
22
23 #include <FBaseSysLog.h>
24 #include <FSclRelationship.h>
25 #include "FScl_RelationshipImpl.h"
26
27 using namespace Tizen::Base;
28
29 namespace Tizen { namespace Social
30 {
31
32 _RelationshipImpl::_RelationshipImpl(void)
33 : __type(CONTACT_RELATIONSHIP_TYPE_ASSISTANT)
34 {
35 }
36
37 _RelationshipImpl::_RelationshipImpl(const _RelationshipImpl& rhs)
38 {
39         __name = rhs.__name;
40         __type = rhs.__type;
41         __label = rhs.__label;
42 }
43
44 _RelationshipImpl::~_RelationshipImpl(void)
45 {
46
47 }
48
49 _RelationshipImpl&
50 _RelationshipImpl::operator =(const _RelationshipImpl& rhs)
51 {
52         if (this == &rhs)
53         {
54                 return *this;
55         }
56
57         __name = rhs.__name;
58         __type = rhs.__type;
59         __label = rhs.__label;
60
61         return *this;
62 }
63
64 bool
65 _RelationshipImpl::operator ==(const _RelationshipImpl& rhs) const
66 {
67         if (__name != rhs.__name)
68         {
69                 return false;
70         }
71
72         if (__type != rhs.__type)
73         {
74                 return false;
75         }
76
77         if (__label != rhs.__label)
78         {
79                 return false;
80         }
81
82         return true;
83 }
84
85 bool
86 _RelationshipImpl::operator !=(const _RelationshipImpl& rhs) const
87 {
88         return !(*this == rhs);
89 }
90
91 bool
92 _RelationshipImpl::Equals(const Object& rhs) const
93 {
94         const _RelationshipImpl* pRelationship= dynamic_cast<const _RelationshipImpl*>(&rhs);
95         if (pRelationship == null)
96         {
97                 return false;
98         }
99
100         return *this == *pRelationship;
101 }
102
103 int
104 _RelationshipImpl::GetHashCode(void) const
105 {
106         int hash = __name.GetHashCode() + __label.GetHashCode() + __type;
107
108         return hash;
109 }
110
111 RelationshipType
112 _RelationshipImpl::GetType(void) const
113 {
114         return __type;
115 }
116
117 String
118 _RelationshipImpl::GetRelativeName(void) const
119 {
120         return __name;
121 }
122
123 String
124 _RelationshipImpl::GetLabel(void) const
125 {
126         return __label;
127 }
128
129 void
130 _RelationshipImpl::SetType(RelationshipType type)
131 {
132         __type = type;
133 }
134
135 void
136 _RelationshipImpl::SetRelativeName(const String& name)
137 {
138         __name = name;
139 }
140
141 void
142 _RelationshipImpl::SetLabel(const String& label)
143 {
144         __label = label;
145 }
146
147 const _RelationshipImpl*
148 _RelationshipImpl::GetInstance(const Relationship& relationship)
149 {
150         return relationship.__pRelationshipImpl;
151 }
152
153 _RelationshipImpl*
154 _RelationshipImpl::GetInstance(Relationship& relationship)
155 {
156         return relationship.__pRelationshipImpl;
157 }
158
159
160 }} // Tizen::Social