Tizen 2.0 Release
[framework/osp/locations.git] / src / FLocLocationCriteria.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 <FBaseSysLog.h>
19 #include <FSecAccessController.h>
20 #include <FLocLocationCriteria.h>
21 #include <FSec_AccessControlTypes.h>
22
23 using namespace Tizen::Security;
24
25 namespace Tizen { namespace Locations
26 {
27
28 LocationCriteria::LocationCriteria(void)
29         : Tizen::Base::Object()
30         , __accuracy(LOC_ACCURACY_ANY)
31         , __pImpl(null)
32 {
33 }
34
35 LocationCriteria::LocationCriteria(const LocationCriteria& rhs)
36         : Tizen::Base::Object()
37         , __accuracy(rhs.__accuracy)
38         , __pImpl(null)
39 {
40 }
41
42 LocationCriteria::~LocationCriteria(void)
43 {
44 }
45
46 bool
47 LocationCriteria::Equals(const Base::Object& rhs) const
48 {
49         const LocationCriteria* pRhs = dynamic_cast< const LocationCriteria* >(&rhs);
50
51         if (pRhs == null)
52         {
53                 return false;
54         }
55
56         if (__accuracy != pRhs->__accuracy)
57         {
58                 return false;
59         }
60
61         return true;
62 }
63
64 int
65 LocationCriteria::GetHashCode(void) const
66 {
67         int hashCode = 0;
68
69         hashCode = __accuracy * 37;
70
71         return hashCode;
72 }
73
74 result
75 LocationCriteria::SetAccuracy(LocationAccuracy accuracy)
76 {
77         SysTryReturn(NID_LOC, accuracy >= LOC_ACCURACY_FINEST && accuracy <= LOC_ACCURACY_ANY, E_INVALID_ARG, E_INVALID_ARG,
78                                  "[E_INVALID_ARG] The accuracy value is out of range.");
79
80         __accuracy = accuracy;
81         return E_SUCCESS;
82 }
83
84 LocationAccuracy
85 LocationCriteria::GetAccuracy(void) const
86 {
87         return __accuracy;
88 }
89
90 LocationCriteria&
91 LocationCriteria::operator =(const LocationCriteria& rhs)
92 {
93         if (this == &rhs)
94         {
95                 return *this;
96         }
97
98         __accuracy = rhs.__accuracy;
99
100         return *this;
101 }
102 }}