diff options
author | Eric S. Raymond <esr@thyrsus.com> | 2011-02-02 14:54:21 -0500 |
---|---|---|
committer | Eric S. Raymond <esr@thyrsus.com> | 2011-02-02 14:54:21 -0500 |
commit | 0113c042a1eb3080eb4e1b73c0db8234250d996a (patch) | |
tree | b400a73552603830d8c6b5e6c790e56d3edaa8b4 /www | |
parent | 0a1b13f791a6fa0965207deb44c3c67ff3deaf23 (diff) | |
download | gpsd-0113c042a1eb3080eb4e1b73c0db8234250d996a.tar.gz |
Rebuild the C++ interface to use RAII.
Simplifies the code and invalidates Berlios ug #17778: crash in libgpsmm.
Diffstat (limited to 'www')
-rw-r--r-- | www/protocol-transition.txt | 44 |
1 files changed, 37 insertions, 7 deletions
diff --git a/www/protocol-transition.txt b/www/protocol-transition.txt index 927a7f05..bbe920ce 100644 --- a/www/protocol-transition.txt +++ b/www/protocol-transition.txt @@ -403,17 +403,47 @@ of the gpsdata structure. Two new DOPs, xdop and ydop, are available; these express dilution of precision in longitude and latitude, respectively. -The raw_hook member is gone. +There is a gps_waiting() method analogous to the waiting() method in +the Python class -- a non-blocking way to check if input is waiting +from the daemon. -The 2.91 API includes a gps_waiting() method analogous to the -waiting() method in the Python class -- a non-blocking way to check -if input is waiting from the daemon. +The raw_hook member is gone. == C++ client library changes == -The C++ client library continues to be a trivial class wrpapper around -the C. About all you need to know is that the query() method is gone -and there is a new stream() method that calls gps_stream(). +In API version 5, the C++ library defines a single object using RAII. +There are no explicit open() and close() methods; instead, you initialize +the object handing it a host and server, and the connection is shut down +when the object is deleted or goes out of scope. + +The following code skeleton implements a C++ client: + +---------------------------------------------------------------------- + +int main(void) +{ + gpsmm gps_rec("localhost", DEFAULT_GPSD_PORT); + + gps_rec.stream(WATCH_ENABLE|WATCH_JSON); + + for (;;) { + struct gps_data_t* newdata; + + if (!gps_rec.waiting()) + continue; + + if ((newdata = gps_rec.read()) == NULL) { + cerr << "Read error.\n"; + return 1; + } else { + PROCESS(newdata); + } + } + return 0; +} + +---------------------------------------------------------------------- + == Python client library changes == |