Fix the boiler plate codes
[framework/osp/social.git] / src / FSclCalendar.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                FSclCalendar.cpp
18  * @brief               This is the implementation for Calendar class.
19  *
20  * This file contains definitions of @e Calendar class.
21  */
22
23 #include <new>
24 #include <FSclCalendar.h>
25 #include <FBaseSysLog.h>
26 #include "FScl_CalendarImpl.h"
27
28 using namespace Tizen::Base;
29
30 namespace Tizen { namespace Social
31 {
32
33 Calendar::Calendar(CalendarItemType itemType)
34 : Record(RECORD_TYPE_CALENDAR)
35 , __pCalendarImpl(null)
36 {
37         __pCalendarImpl = new (std::nothrow) _CalendarImpl(itemType);
38         SysTryReturnVoidResult(NID_SCL, __pCalendarImpl != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
39 }
40
41 Calendar::Calendar(const Calendar& rhs)
42 : Record(rhs)
43 , __pCalendarImpl(null)
44 {
45         __pCalendarImpl = new (std::nothrow) _CalendarImpl(*rhs.__pCalendarImpl);
46         SysTryReturnVoidResult(NID_SCL, __pCalendarImpl != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
47 }
48
49 Calendar::~Calendar(void)
50 {
51         delete __pCalendarImpl;
52 }
53
54 Calendar&
55 Calendar::operator =(const Calendar& rhs)
56 {
57         if (this == &rhs)
58         {
59                 return *this;
60         }
61
62         Record::operator=(rhs);
63
64         *__pCalendarImpl = *rhs.__pCalendarImpl;
65
66         return *this;
67 }
68
69 bool
70 Calendar::Equals(const Tizen::Base::Object& rhs) const
71 {
72         const Calendar* pCalendar = dynamic_cast<const Calendar*>(&rhs);
73
74         if (pCalendar == null)
75         {
76                 return false;
77         }
78
79         return (Record::GetRecordId() == pCalendar->GetRecordId());
80 }
81
82 int
83 Calendar::GetHashCode(void) const
84 {
85         int hashCode = 17;
86
87         hashCode = static_cast<int>(( hashCode << 4 ) ^ ( hashCode >> 28 ) ^ Record::GetRecordId());
88
89         return hashCode;
90 }
91
92 String
93 Calendar::GetName(void) const
94 {
95         return __pCalendarImpl->GetName();
96 }
97
98 CalendarItemType
99 Calendar::GetItemType(void) const
100 {
101         return __pCalendarImpl->GetItemType();
102 }
103
104 AccountId
105 Calendar::GetAccountId(void) const
106 {
107         return __pCalendarImpl->GetAccountId();
108 }
109
110 result
111 Calendar::GetColor(byte& red, byte& green, byte& blue) const
112 {
113         result r = __pCalendarImpl->GetColor(red, green, blue);
114         SysTryReturnResult(NID_SCL, r == E_SUCCESS, r, "Propagating.");
115
116         return E_SUCCESS;
117 }
118
119 void
120 Calendar::SetName(const Tizen::Base::String& name)
121 {
122         __pCalendarImpl->SetName(name);
123 }
124
125 void
126 Calendar::SetColor(byte red, byte green, byte blue)
127 {
128         __pCalendarImpl->SetColor(red, green, blue);
129 }
130
131 void
132 Calendar::ClearColor(void)
133 {
134         __pCalendarImpl->ClearColor();
135 }
136
137 }}      // Tizen::Social