libgpsmm.h 2.1 KB

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