General: separation of marav-io as a library
[marnav.git] / include / marnav-io / nmea_reader.hpp
blob9a3f393c25d1e551e4a03abc78a9c21e81442729
1 #ifndef MARNAV_IO_NMEA_READER_HPP
2 #define MARNAV_IO_NMEA_READER_HPP
4 #include <marnav-io/device.hpp>
5 #include <marnav/nmea/sentence.hpp>
7 namespace marnav
9 namespace io
11 /// This class reads NMEA sentences from a device. Normally this would
12 /// be a serial character device (e.g. \c /dev/ttyS0 or \c /dev/ttyUSB0).
13 ///
14 /// In order to use this NMEA reader, it must be subclassed.
15 ///
16 /// This reader opens the device upon construction.
17 ///
18 class nmea_reader
20 public:
21 virtual ~nmea_reader();
23 nmea_reader(std::unique_ptr<device> && d);
24 nmea_reader(const nmea_reader &) = delete;
25 nmea_reader(nmea_reader &&) = default;
27 nmea_reader & operator=(const nmea_reader &) = delete;
28 nmea_reader & operator=(nmea_reader &&) = default;
30 void close();
31 bool read();
33 protected:
34 virtual void process_sentence(const std::string &) = 0;
36 private:
37 void process_nmea();
38 bool read_data();
40 char raw_;
41 std::string sentence_;
42 std::unique_ptr<device> dev_; ///< Device to read data from.
47 #endif