be69bf10a72d47405b92ab6c491dad2453c39bdf
[situare] / src / gps / gpsposition.h
1 /*
2    Situare - A location system for Facebook
3    Copyright (C) 2010  Ixonos Plc. Authors:
4
5        Jussi Laitinen - jussi.laitinen@ixonos.com
6
7    Situare is free software; you can redistribute it and/or
8    modify it under the terms of the GNU General Public License
9    version 2 as published by the Free Software Foundation.
10
11    Situare is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14    GNU General Public License for more details.
15
16    You should have received a copy of the GNU General Public License
17    along with Situare; if not, write to the Free Software
18    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
19    USA.
20 */
21
22 #ifndef GPSPOSITION_H
23 #define GPSPOSITION_H
24
25 #include <QObject>
26 #include <QPointF>
27
28 class GPSPositionPrivate;
29
30 /**
31 * @brief GPSPosition class is an interface for GPS.
32 */
33 class GPSPosition : public QObject
34 {
35     Q_OBJECT
36
37 public:
38     /**
39     * @brief Friend class for GPSPosition.
40     */
41     friend class GPSPositionPrivate;
42
43     /**
44     * @brief Constructor.
45     *
46     * @param parent QObject
47     */
48     GPSPosition(QObject *parent = 0);
49
50     /**
51     * @brief GPS position mode.
52     */
53     enum Mode {Default, Simulation};
54
55 /******************************************************************************
56 * MEMBER FUNCTIONS AND SLOTS
57 ******************************************************************************/
58 public:
59     /**
60     * @brief Returns is GPS initialized.
61     *
62     * @return true if initialized, false otherwise
63     */
64     bool isInitialized();
65
66     /**
67     * @brief Checks if GPS is running.
68     *
69     * @return true if GPS running, false otherwise
70     */
71     bool isRunning();
72
73     /**
74     * @brief Return last known position.
75     */
76     QPointF lastPosition();
77
78     /**
79     * @brief Informs gps to emit last known position.
80     */
81     void requestLastPosition();
82
83     /**
84     * @brief Set GPS mode.
85     *
86     * Modes: default and simulation.
87     * @param mode GPS mode
88     * @param filePath file path to NMEA file if simulation mode is used
89     */
90     void setMode(Mode mode, const QString &filePath = 0);
91
92     /**
93     * @brief Set GPS update interval
94     *
95     * @return interval interval in milliseconds
96     */
97     void setUpdateInterval(int interval);
98
99     /**
100     * @brief Start GPS.
101     */
102     void start();
103
104     /**
105     * @brief Stop GPS.
106     */
107     void stop();
108
109 /******************************************************************************
110 * SIGNALS
111 ******************************************************************************/
112 signals:
113     /**
114     * @brief Signal for error.
115     *
116     * @param error error code
117     */
118     void error(const int error);
119
120     /**
121     * @brief Signal for position information.
122     *
123     * @param latLonCoordinate latitude and longitude values
124     * @param accuracy accuracy in metres
125     */
126     void position(QPointF latLonCoordinate, qreal accuracy);
127
128     /**
129     * @brief Signal for timeout.
130     */
131     void timeout();
132
133 /*******************************************************************************
134 * DATA MEMBERS
135 *******************************************************************************/
136 private:
137     GPSPositionPrivate *m_gpsPositionPrivate;   ///< GPSPositionPrivate object
138 };
139
140 #endif // GPSPOSITIONINTERFACE_H