blob: c9cf3d148a7a98c6e297b1e78a86781f23b40499 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
#pragma once
#include "../std/string.hpp"
#include "../std/vector.hpp"
#include <boost/function.hpp>
namespace location
{
enum TLocationStatus
{
ENotSupported, //!< GpsInfo fields are not valid with this value
EDisabledByUser, //!< GpsInfo fields are not valid with this value
EAccurateMode,
ERoughMode //!< in this mode compass is turned off
};
/// @note always check m_status before using this structure
struct GpsInfo
{
TLocationStatus m_status;
double m_timestamp; //!< seconds from 01/01/1970
double m_latitude; //!< degrees @TODO mercator
double m_longitude; //!< degrees @TODO mercator
double m_horizontalAccuracy; //!< metres
double m_altitude; //!< metres
double m_verticalAccuracy; //!< metres
double m_course; //!< positive degrees from the true North
double m_speed; //!< metres per second
};
struct CompassInfo
{
double m_timestamp; //!< seconds from 01/01/1970
double m_magneticHeading; //!< positive degrees from the magnetic North
double m_trueHeading; //!< positive degrees from the true North
double m_accuracy; //!< offset from magnetic to true North
int m_x;
int m_y;
int m_z;
};
typedef boost::function1<void, GpsInfo const &> TGpsCallback;
typedef boost::function1<void, CompassInfo const &> TCompassCallback;
class LocationService
{
typedef vector<TGpsCallback> GpsObserversT;
GpsObserversT m_gpsObservers;
typedef vector<TCompassCallback> CompassObserversT;
CompassObserversT m_compassObservers;
protected:
void NotifySubscribers(GpsInfo const & info);
void NotifySubscribers(CompassInfo const & info);
public:
/// @note unsubscribe doesn't work with boost::function
void SubscribeToGpsUpdates(TGpsCallback observer);
void SubscribeToCompassUpdates(TCompassCallback observer);
// void Unsubscribe(TGpsCallback observer);
// void Unsubscribe(TCompassCallback observer);
/// to change active accuracy mode just call it again
/// @param useAccurateMode if true also enables compass if it's available
virtual void StartUpdate(bool useAccurateMode) = 0;
virtual void StopUpdate() = 0;
};
}
extern "C" location::LocationService & GetLocationService();
|