[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gpsd-dev] [PATCH] libgpsmm: add is_open method
From: |
spdawson |
Subject: |
[gpsd-dev] [PATCH] libgpsmm: add is_open method |
Date: |
Sun, 8 Dec 2013 11:20:05 +0000 |
From: Simon Dawson <address@hidden>
The gpsmm constructor effectively hides the useful status flag returned
by the underlying gps_open call.
It is extremely useful for client code to be able to check that the
gpsmm constructor was successful. To this end, add a gpsmm::is_open method
which simply checks that the gpsmm::to_user member is non-NULL. A NULL
gpsmm::to_user member can only mean that the constructor was not successful.
Signed-off-by: Simon Dawson <address@hidden>
---
libgpsmm.cpp | 5 +++++
libgpsmm.h | 1 +
2 files changed, 6 insertions(+)
diff --git a/libgpsmm.cpp b/libgpsmm.cpp
index fa421aa..2707e44 100644
--- a/libgpsmm.cpp
+++ b/libgpsmm.cpp
@@ -83,6 +83,11 @@ void gpsmm::enable_debug(int level, FILE *fp)
#endif /* CLIENTDEBUG_ENABLE */
}
+bool gpsmm::is_open(void)
+{
+ return to_user != NULL;
+}
+
gpsmm::~gpsmm()
{
if ( to_user != NULL ) {
diff --git a/libgpsmm.h b/libgpsmm.h
index 2b87b89..ab656b6 100644
--- a/libgpsmm.h
+++ b/libgpsmm.h
@@ -45,6 +45,7 @@ class LIBQGPSMMSHARED_EXPORT gpsmm {
bool waiting(int); // blocking check for data waiting
void clear_fix(void);
void enable_debug(int, FILE*);
+ bool is_open(void); // check for constructor success
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
--
1.8.3.2
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gpsd-dev] [PATCH] libgpsmm: add is_open method,
spdawson <=