summaryrefslogtreecommitdiff
path: root/libgpsmm.h
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2011-02-02 14:54:21 -0500
committerEric S. Raymond <esr@thyrsus.com>2011-02-02 14:54:21 -0500
commit0113c042a1eb3080eb4e1b73c0db8234250d996a (patch)
treeb400a73552603830d8c6b5e6c790e56d3edaa8b4 /libgpsmm.h
parent0a1b13f791a6fa0965207deb44c3c67ff3deaf23 (diff)
downloadgpsd-0113c042a1eb3080eb4e1b73c0db8234250d996a.tar.gz
Rebuild the C++ interface to use RAII.
Simplifies the code and invalidates Berlios ug #17778: crash in libgpsmm.
Diffstat (limited to 'libgpsmm.h')
-rw-r--r--libgpsmm.h14
1 files changed, 11 insertions, 3 deletions
diff --git a/libgpsmm.h b/libgpsmm.h
index e3f99497..3c77a403 100644
--- a/libgpsmm.h
+++ b/libgpsmm.h
@@ -18,10 +18,16 @@ class gpsmm {
class LIBQGPSMMSHARED_EXPORT gpsmm {
#endif
public:
- gpsmm();
+ gpsmm(const char *host, const char *port) : to_user(0) {
+ gps_inner_open(host, port);
+ }
+#ifdef __UNUSED__
+ gpsmm(void) : to_user(0)
+ {
+ gps_inner_open("localhost", DEFAULT_GPSD_PORT);
+ }
+#endif
virtual ~gpsmm();
- struct gps_data_t* open(const char *host,const char *port); //opens the connection with gpsd, MUST call this before any other method
- struct gps_data_t* open(void); //open() with default values
struct gps_data_t* send(const char *request); //put a command to gpsd and return the updated struct
struct gps_data_t* stream(int); //set watcher and policy flags
struct gps_data_t* read(void); //block until gpsd returns new data, then return the updated struct
@@ -32,6 +38,8 @@ class LIBQGPSMMSHARED_EXPORT gpsmm {
private:
struct gps_data_t *to_user; //we return the user a copy of the internal structure. This way she can modify it without
//integrity loss for the entire class
+ struct gps_data_t* gps_inner_open(const char *host,
+ const char *port);
struct gps_data_t _gps_data;
struct gps_data_t * gps_data() { return &_gps_data; }
struct gps_data_t* backup(void) { *to_user=*gps_data(); return to_user;}; //return the backup copy