Merge branch 'master' into error_procedur
[situare] / src / gps / gpsposition.h
index 15aa158..be69bf1 100644 (file)
 #ifndef GPSPOSITION_H
 #define GPSPOSITION_H
 
-#include <QGeoPositionInfoSource>
+#include <QObject>
 #include <QPointF>
 
-QTM_USE_NAMESPACE
+class GPSPositionPrivate;
 
 /**
-* @brief GPSPosition class use GPS to receive location information.
-*
-* @class GPSPosition engine.h "gps/gpsposition.h"
+* @brief GPSPosition class is an interface for GPS.
 */
 class GPSPosition : public QObject
 {
@@ -38,16 +36,34 @@ class GPSPosition : public QObject
 
 public:
     /**
-    * @brief Start GPS.
+    * @brief Friend class for GPSPosition.
+    */
+    friend class GPSPositionPrivate;
+
+    /**
+    * @brief Constructor.
+    *
+    * @param parent QObject
     */
     GPSPosition(QObject *parent = 0);
-    ~GPSPosition();
+
+    /**
+    * @brief GPS position mode.
+    */
+    enum Mode {Default, Simulation};
 
 /******************************************************************************
 * MEMBER FUNCTIONS AND SLOTS
 ******************************************************************************/
 public:
     /**
+    * @brief Returns is GPS initialized.
+    *
+    * @return true if initialized, false otherwise
+    */
+    bool isInitialized();
+
+    /**
     * @brief Checks if GPS is running.
     *
     * @return true if GPS running, false otherwise
@@ -55,65 +71,70 @@ public:
     bool isRunning();
 
     /**
-    * @brief Start GPS.
+    * @brief Return last known position.
     */
-    void start();
+    QPointF lastPosition();
 
     /**
-    * @brief Stop GPS.
+    * @brief Informs gps to emit last known position.
     */
-    void stop();
+    void requestLastPosition();
 
     /**
-    * @brief Request GPS update.
+    * @brief Set GPS mode.
+    *
+    * Modes: default and simulation.
+    * @param mode GPS mode
+    * @param filePath file path to NMEA file if simulation mode is used
     */
-    void update();
-
-private slots:
+    void setMode(Mode mode, const QString &filePath = 0);
 
     /**
-    * @brief Slot for received position update.
+    * @brief Set GPS update interval
     *
-    * @param positionInfo Geo position info.
+    * @return interval interval in milliseconds
     */
-    void positionUpdated(QGeoPositionInfo positionInfo);
+    void setUpdateInterval(int interval);
 
     /**
-    * @brief Slot for update timeout.
-    *
-    * Called when request timeout occurs.
+    * @brief Start GPS.
     */
-    void updateTimeout();
+    void start();
+
+    /**
+    * @brief Stop GPS.
+    */
+    void stop();
 
 /******************************************************************************
 * SIGNALS
 ******************************************************************************/
 signals:
     /**
+    * @brief Signal for error.
+    *
+    * @param error error code
+    */
+    void error(const int error);
+
+    /**
     * @brief Signal for position information.
     *
     * @param latLonCoordinate latitude and longitude values
+    * @param accuracy accuracy in metres
     */
-    void position(QPointF latLonCoordinate);
+    void position(QPointF latLonCoordinate, qreal accuracy);
 
     /**
     * @brief Signal for timeout.
     */
     void timeout();
 
-    /**
-    * @brief Signal for error.
-    *
-    * @param message error message
-    */
-    void error(const QString &message);
-
+/*******************************************************************************
+* DATA MEMBERS
+*******************************************************************************/
 private:
-    QGeoPositionInfoSource *m_gpsSource;        ///< GPS position info source
-    bool m_running;                             ///< GPS is running
-    int m_updateInterval;                       ///< GPS update interval
+    GPSPositionPrivate *m_gpsPositionPrivate;   ///< GPSPositionPrivate object
 };
 
-const int DEFAULT_UPDATE_INTERVAL = 5000;   ///< Default update interval
-
-#endif // GPSPOSITION_H
+#endif // GPSPOSITIONINTERFACE_H