Base class for parsing NMEA messages and SBF blocks. More...
#include <parser_base_class.hpp>
Public Member Functions | |
BaseParser ()=default | |
Default constructor of the class BaseParser. More... | |
virtual const std::string | getMessageID () const =0 |
Returns the ASCII message name. More... | |
virtual T | parseASCII (const NMEASentence &sentence, const std::string &frame_id, bool use_gnss_time, Timestamp time_obj) noexcept(false) |
Converts an NMEA sentence - both standardized and proprietary ones - into a ROS message pointer (e.g. nmea_msgs::GpggaPtr) and returns it. More... | |
virtual | ~BaseParser ()=default |
Default destructor of the class BaseParser. More... | |
Base class for parsing NMEA messages and SBF blocks.
Subclasses that parse NMEA messages should implement ParseASCII(const NMEASentence&); The base class is implemented as a template, which is a simple and yet very powerful tool in C++. The simple idea is to pass data type as a parameter so that we don’t need to write the same code for different data types. Like function templates, class templates are useful when a class defines something that is independent of the data type, as here the notion of parsing.
T | The ROS message pointer type that the parser should produce, e.g. nmea_msgs::GpggaPtr. |
Definition at line 60 of file parser_base_class.hpp.
|
default |
Default constructor of the class BaseParser.
Adding the "default" keyword to the constructor declaration is a new feature since C++11 for creating a default constructor (a constructor which can be called with no arguments). Strictly speaking, it is not the same as when the keyword is omitted, but the differences are miniscule.
Also note that in C++, the constructor cannot be virtual, because when a constructor of a class is executed, there is no virtual table in the memory, i.e. no virtual pointer defined yet.
|
virtualdefault |
Default destructor of the class BaseParser.
As opposed to the constructor, a destructor can be virtual, as here.
|
pure virtual |
Returns the ASCII message name.
GetMessageID() is a pure virtual function, i.e. a function for which writing a function declaration suffices. It is declared by assigning the value 0 in the declaration. Since we now have at least 1 pure virtual function, our class BaseParser thus becomes an "abstract" one.
|
inlinevirtualnoexcept |
Converts an NMEA sentence - both standardized and proprietary ones - into a ROS message pointer (e.g. nmea_msgs::GpggaPtr) and returns it.
The returned value should not be NULL. ParseException will be thrown if there are any issues parsing the message.
[in] | sentence | The standardized NMEA sentence to convert, of type NMEASentence |
Reimplemented in GpgsaParser, GpggaParser, GpgsvParser, and GprmcParser.
Definition at line 108 of file parser_base_class.hpp.