2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
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
9 // http://www.apache.org/licenses/LICENSE-2.0
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.
19 * @file FLoc_SyncLocationRequestInfo.h
20 * @brief This is the header file for the %_SyncLocationRequestInfo class.
22 * This header file contains the declarations of the %_SyncLocationRequestInfo class member variables.
25 #ifndef _FLOC_INTERNAL_SYNC_LOCATION_REQUEST_INFO_H_
26 #define _FLOC_INTERNAL_SYNC_LOCATION_REQUEST_INFO_H_
29 #include <unique_ptr.h>
30 #include <FBaseObject.h>
31 #include <FBaseRtTimer.h>
32 #include <FBaseRtITimerEventListener.h>
33 #include <FLocTypes.h>
34 #include <FSysSystemTime.h>
36 namespace Tizen { namespace Locations
38 class _LocationMonitor;
39 class _LocationManager;
41 class _SyncLocationRequestInfo
42 : public Tizen::Base::Object
45 _SyncLocationRequestInfo(_LocationMonitor* pLocMonitor, RequestId reqId)
46 : Tizen::Base::Object()
47 , __pLocMonitor(pLocMonitor)
52 Tizen::System::SystemTime::GetCurrentTime(__requestTime);
55 ~_SyncLocationRequestInfo(void) {}
57 _LocationMonitor* GetLocationMonitor(void) const {return __pLocMonitor;}
59 result StartTimer(Tizen::Base::Runtime::ITimerEventListener& listener)
65 std::unique_ptr< Tizen::Base::Runtime::Timer > pTimer(new (std::nothrow) Tizen::Base::Runtime::Timer());
66 SysTryReturn(NID_LOC, pTimer != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
67 "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
68 r = pTimer->Construct(listener);
69 SysTryReturn(NID_LOC, r == E_SUCCESS, r, r, "[%s] Failed to construct the timer.", GetErrorMessage(r));
71 __pTimer = std::move(pTimer);
74 const int DEFAULT_TIME_OUT = 1000;
75 r = __pTimer->Start(DEFAULT_TIME_OUT);
76 SysTryReturn(NID_LOC, r == E_SUCCESS, r, r, "[%s] Failed to start the timer.", GetErrorMessage(r));
81 bool Equals(const Tizen::Base::Runtime::Timer& timer) {return __pTimer->Equals(timer);}
83 RequestId GetRequestId(void) const {return __reqId;}
85 int GetTickCount(void) const {return __tickCount;}
87 bool IsInTime(const Tizen::Base::DateTime& timestamp)
89 return (timestamp > __requestTime) ? true : false;
92 bool IsAccuracySatisfying(LocationAccuracy accuracy)
94 if (accuracy == LOC_ACCURACY_INVALID)
100 return (accuracy <= __pLocMonitor->GetAccuracy()) ? true : false;
105 _SyncLocationRequestInfo(void);
107 _SyncLocationRequestInfo& operator =(const _SyncLocationRequestInfo& rhs);
110 Tizen::Base::DateTime __requestTime;
111 _LocationMonitor* __pLocMonitor;
112 std::unique_ptr< Tizen::Base::Runtime::Timer > __pTimer;
115 }; //_SyncLocationRequestInfo
116 }} //Tizen::Locations
117 #endif // _FLOC_INTERNAL_SYNC_LOCATION_REQUEST_INFO_H_