nmealib 0.0.4
NMEA 0183/NMEA 2000 parsing library
Loading...
Searching...
No Matches
nmea0183Factory.cpp
Go to the documentation of this file.
2#include "messageRegistry.hpp"
3
4namespace nmealib {
5namespace nmea0183 {
6
7std::unique_ptr<Message0183> Nmea0183Factory::create(const std::string& raw, Message::TimePoint ts) {
8 auto baseMessage = Message0183::create(raw, ts);
9 if (!baseMessage) {
10 return nullptr;
11 }
12
13 std::string sentenceType = baseMessage->getSentenceType();
14
15 // Dispatch through the message registry
16 // The registry was populated with all known message types at library initialization
17 return MessageRegistry::instance().create(sentenceType, std::move(baseMessage));
18}
19
20} // namespace nmea0183
21} // namespace nmealib
std::chrono::system_clock::time_point TimePoint
Definition message.h:30
static std::unique_ptr< Message0183 > create(const std::string &raw, TimePoint ts=std::chrono::system_clock::now())
Protected factory method to create a Message0183 from a raw sentence string.
Definition nmea0183.cpp:47
static MessageRegistry & instance()
Get the singleton instance of the MessageRegistry.
std::unique_ptr< Message0183 > create(const std::string &sentenceType, std::unique_ptr< Message0183 > baseMessage)
Create a typed message from a generic Message0183.
static std::unique_ptr< Message0183 > create(const std::string &raw, Message::TimePoint ts=std::chrono::system_clock::now())
Creates a typed NMEA 0183 message from a raw sentence string.