1 #ifndef _GPSD_GPSMM_H_
2 #define _GPSD_GPSMM_H_
3 
4 /*
5  * Copyright (C) 2005 Alfredo Pironti
6  *
7  * This software is distributed under a BSD-style license. See the
8  * file "COPYING" in the toop-level directory of the distribution for details.
9  *
10  */
11 #include <sys/types.h>
12 #include "gps.h" //the C library we are going to wrap
13 
14 #ifndef USE_QT
15 class gpsmm {
16 #else
17 
18 #include <QtCore/qglobal.h>
19 
20 #if defined(LIBQGPSMM_LIBRARY)
21 #  define LIBQGPSMMSHARED_EXPORT Q_DECL_EXPORT
22 #else
23 #  define LIBQGPSMMSHARED_EXPORT Q_DECL_IMPORT
24 #endif
25 
26 class LIBQGPSMMSHARED_EXPORT gpsmm {
27 #endif
28 	public:
29 		// cppcheck-suppress uninitVar
gpsmm(const char * host,const char * port)30 		gpsmm(const char *host, const char *port) : to_user(0), _gps_state() {
31 			gps_inner_open(host, port);
32 		}
33 #ifdef __UNUSED__
34 		// cppcheck-suppress uninitVar
gpsmm(void)35 		gpsmm(void) : to_user(0)
36 		{
37 		        gps_inner_open("localhost", DEFAULT_GPSD_PORT);
38 		}
39 #endif
40 		virtual ~gpsmm();
41 		struct gps_data_t* send(const char *request); //put a command to gpsd and return the updated struct
42 		struct gps_data_t* stream(int); //set watcher and policy flags
43 		struct gps_data_t* read(void); //block until gpsd returns new data, then return the updated struct
44 		const char *data(void);	// return the client data buffer
45 		bool waiting(int);	// blocking check for data waiting
46 		void clear_fix(void);
47 		void enable_debug(int, FILE*);
48 		bool is_open(void);	// check for constructor success
49 	private:
50 		struct gps_data_t *to_user;	//we return the user a copy of the internal structure. This way she can modify it without
51 						//integrity loss for the entire class
52 		struct gps_data_t* gps_inner_open(const char *host,
53 						  const char *port);
54 		struct gps_data_t _gps_state;
gps_state()55 		struct gps_data_t * gps_state() { return &_gps_state; }
backup(void)56 		struct gps_data_t* backup(void) { *to_user=*gps_state(); return to_user;}; //return the backup copy
57 };
58 #endif // _GPSD_GPSMM_H_
59