You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

59 lines
1.8KB

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