Public Member Functions | List of all members
BaseParser< T > Class Template Referenceabstract

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...
 
template<typename SBFStructT >
parseBinary (const SBFStructT &bin_msg) noexcept(false)
 Converts bin_msg into a ROS message pointer (e.g. nmea_msgs::GpggaPtr) and returns it. More...
 
virtual ~BaseParser ()=default
 Default destructor of the class BaseParser. More...
 

Detailed Description

template<typename T>
class BaseParser< T >

Base class for parsing NMEA messages and SBF blocks.

Subclasses that parse NMEA messages should implement ParseASCII(const NMEASentence&); subclasses that parse SBF blocks should implement ParseBinary(const SBFBlock&). 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.

Template Parameters
TThe ROS message pointer type that the parser should produce, e.g. nmea_msgs::GpggaPtr.

Definition at line 62 of file parser_base_class.hpp.

Constructor & Destructor Documentation

◆ BaseParser()

template<typename T>
BaseParser< T >::BaseParser ( )
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.

◆ ~BaseParser()

template<typename T>
virtual BaseParser< T >::~BaseParser ( )
virtualdefault

Default destructor of the class BaseParser.

As opposed to the constructor, a destructor can be virtual, as here.

Member Function Documentation

◆ getMessageID()

template<typename T>
virtual const std::string BaseParser< T >::getMessageID ( ) const
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.

Returns
The ASCII message name.

Implemented in GpggaParser, GpgsaParser, GpgsvParser, and GprmcParser.

◆ parseASCII()

template<typename T>
virtual T BaseParser< T >::parseASCII ( const NMEASentence sentence,
const std::string &  frame_id,
bool  use_gnss_time,
Timestamp  time_obj 
)
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.

Parameters
[in]sentenceThe standardized NMEA sentence to convert, of type NMEASentence
Returns
A valid ROS message pointer

Reimplemented in GpggaParser, GpgsaParser, GpgsvParser, and GprmcParser.

Definition at line 126 of file parser_base_class.hpp.

◆ parseBinary()

template<typename T>
template<typename SBFStructT >
T BaseParser< T >::parseBinary ( const SBFStructT &  bin_msg)
inlinenoexcept

Converts bin_msg 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 block.

Parameters
[in]bin_msgThe message to convert, of type const SBFStructT
Returns
A valid ROS message pointer

Definition at line 111 of file parser_base_class.hpp.


The documentation for this class was generated from the following file:


septentrio_gnss_driver
Author(s): Tibor Dome
autogenerated on Sat Mar 11 2023 03:12:56