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