fix exception for CreateAddressbookN()
[framework/osp/social.git] / src / FSclRelationship.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         FSclRelationship.cpp
19 * @brief        This is the implementation for Relationship class.
20 *
21 * This file contains definitions of @e Relationship 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 Relationship::Relationship(void)
34 {
35         __pRelationshipImpl = new (std::nothrow) _RelationshipImpl();
36         SysTryReturnVoidResult(NID_SCL, __pRelationshipImpl != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
37 }
38
39 Relationship::Relationship(const Relationship& rhs)
40 {
41         __pRelationshipImpl = new (std::nothrow) _RelationshipImpl(*rhs.__pRelationshipImpl);
42         SysTryReturnVoidResult(NID_SCL, __pRelationshipImpl != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
43 }
44
45 Relationship::~Relationship(void)
46 {
47         delete __pRelationshipImpl;
48 }
49
50 Relationship&
51 Relationship::operator =(const Relationship& rhs)
52 {
53         if (this == &rhs)
54         {
55                 return *this;
56         }
57
58         *__pRelationshipImpl = *rhs.__pRelationshipImpl;
59
60         return *this;
61 }
62
63 bool
64 Relationship::operator ==(const Relationship& rhs) const
65 {
66         if (__name != rhs.__name)
67         {
68                 return false;
69         }
70
71         return *__pRelationshipImpl == *rhs.__pRelationshipImpl;;
72 }
73
74 bool
75 Relationship::operator !=(const Relationship& rhs) const
76 {
77         return !(*this == rhs);
78 }
79
80 bool
81 Relationship::Equals(const Object& rhs) const
82 {
83         const Relationship* pRelationship = dynamic_cast<const Relationship*>(&rhs);
84         if (pRelationship == null)
85         {
86                 return false;
87         }
88
89         return *this == *pRelationship;
90 }
91
92 int
93 Relationship::GetHashCode(void) const
94 {
95         return __pRelationshipImpl->GetHashCode();
96 }
97
98 RelationshipType
99 Relationship::GetType(void) const
100 {
101         return __pRelationshipImpl->GetType();
102 }
103
104 String
105 Relationship::GetRelativeName(void) const
106 {
107         return __pRelationshipImpl->GetRelativeName();
108 }
109
110 String
111 Relationship::GetLabel(void) const
112 {
113         return __pRelationshipImpl->GetLabel();
114 }
115
116 void
117 Relationship::SetType(RelationshipType type)
118 {
119         __pRelationshipImpl->SetType(type);
120 }
121
122 void
123 Relationship::SetRelativeName(const String& name)
124 {
125         __pRelationshipImpl->SetRelativeName(name);
126 }
127
128 void
129 Relationship::SetLabel(const String& label)
130 {
131         __pRelationshipImpl->SetLabel(label);
132 }
133
134 }} // Tizen::Social