Tizen 2.0 Release
[framework/osp/locations.git] / src / FLocLocation.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 #include <new>
19 #include <FBaseDateTime.h>
20 #include <FBaseSysLog.h>
21 #include <FLocLocation.h>
22 #include "FLoc_LocationImpl.h"
23
24 using namespace Tizen::Base;
25
26 namespace Tizen { namespace Locations
27 {
28
29 Location::Location(void)
30         : Tizen::Base::Object()
31         , __pImpl(null)
32 {
33         __pImpl = new (std::nothrow) _LocationImpl();
34
35         if (__pImpl == null)
36         {
37                 SetLastResult(E_OUT_OF_MEMORY);
38         }
39 }
40
41 Location::Location(const Location& rhs)
42         : Tizen::Base::Object()
43         , __pImpl(null)
44 {
45         __pImpl = new (std::nothrow) _LocationImpl(*_LocationImpl::GetInstance(rhs));
46         if (__pImpl == null)
47         {
48                 SetLastResult(E_OUT_OF_MEMORY);
49         }
50 }
51
52 Location::~Location(void)
53 {
54         delete __pImpl;
55 }
56
57 bool
58 Location::Equals(const Tizen::Base::Object& rhs) const
59 {
60         SysAssertf(__pImpl != null, "The location object is in an invalid state.");
61
62         const Location* pRhs = dynamic_cast< const Location* >(&rhs);
63
64         if (pRhs == null)
65         {
66                 return false;
67         }
68
69         return __pImpl->Equals(*_LocationImpl::GetInstance(*pRhs));
70 }
71
72 int
73 Location::GetHashCode(void) const
74 {
75         SysAssertf(__pImpl != null, "The location object is in an invalid state.");
76         return __pImpl->GetHashCode();
77 }
78
79 double
80 Location::GetHorizontalAccuracy(void) const
81 {
82         SysAssertf(__pImpl != null, "The location object is in an invalid state.");
83         return __pImpl->GetHorizontalAccuracy();
84 }
85
86 double
87 Location::GetVerticalAccuracy(void) const
88 {
89         SysAssertf(__pImpl != null, "The location object is in an invalid state.");
90         return __pImpl->GetVerticalAccuracy();
91 }
92
93 double
94 Location::GetCourse(void) const
95 {
96         SysAssertf(__pImpl != null, "The location object is in an invalid state.");
97         return __pImpl->GetCourse();
98 }
99
100 Coordinates
101 Location::GetCoordinates(void) const
102 {
103         SysAssertf(__pImpl != null, "The location object is in an invalid state.");
104         return __pImpl->GetCoordinates();
105 }
106
107 double
108 Location::GetSpeed(void) const
109 {
110         SysAssertf(__pImpl != null, "The location object is in an invalid state.");
111         return __pImpl->GetSpeed();
112 }
113
114 Tizen::Base::DateTime
115 Location::GetTimestamp(void) const
116 {
117         SysAssertf(__pImpl != null, "The location object is in an invalid state.");
118         return __pImpl->GetTimestamp();
119 }
120
121 Tizen::Base::String
122 Location::GetExtraInfo(const Tizen::Base::String& key) const
123 {
124         SysAssertf(__pImpl != null, "The location object is in an invalid state.");
125         return __pImpl->GetExtraInfo(key);
126 }
127
128 bool
129 Location::IsValid(void) const
130 {
131         SysAssertf(__pImpl != null, "The location object is in an invalid state.");
132         return __pImpl->IsValid();
133 }
134
135 Location&
136 Location::operator =(const Location& rhs)
137 {
138         SysAssertf(__pImpl != null, "The location object is in an invalid state.");
139
140         if (this == &rhs)
141         {
142                 return *this;
143         }
144
145         *__pImpl = *_LocationImpl::GetInstance(rhs);
146
147         return *this;
148 }
149 }}