nmealib 0.0.4
NMEA 0183/NMEA 2000 parsing library
Loading...
Searching...
No Matches
xdr.h
Go to the documentation of this file.
1#pragma once
2
3#include <nmealib/nmea0183.h>
4
5#include <cstddef>
6#include <vector>
7
8namespace nmealib {
9namespace nmea0183 {
10
18public:
25 explicit NotXDRException(const std::string& context, const std::string& details = "") :
26 NmeaException(context, "The sentence is not an XDR sentence", details) {}
27};
28
43class XDR : public Message0183 {
44public:
52 double measurement{};
54 char units{};
56 std::string name;
57 };
58
65 XDR(std::string talkerId, std::vector<TransducerMeasurement> transducers);
66
67 XDR(const XDR&) = default;
68 XDR& operator=(const XDR&) = default;
69 XDR(XDR&&) noexcept = default;
70 XDR& operator=(XDR&&) noexcept = default;
71
72 ~XDR() override = default;
73
79 std::unique_ptr<nmealib::Message> clone() const override;
80
86 const std::vector<TransducerMeasurement>& getTransducers() const noexcept;
87
93 std::size_t getTransducerCount() const noexcept;
94
101 const TransducerMeasurement* getTransducer(std::size_t index) const noexcept;
102
109 std::string getStringContent(bool verbose) const noexcept override;
110
119 bool operator==(const XDR& other) const noexcept;
120
121private:
122 std::vector<TransducerMeasurement> transducers_;
123
124 XDR() = delete;
125
126 XDR(Message0183 baseMessage, std::vector<TransducerMeasurement> transducers) noexcept;
127
128 static std::unique_ptr<XDR> create(std::unique_ptr<Message0183> baseMessage);
129 static std::string composeRaw(const std::string& talkerId,
130 const std::vector<TransducerMeasurement>& transducers);
131
132 friend class Nmea0183Factory;
133 friend class MessageRegistry;
134};
135
136} // namespace nmea0183
137} // namespace nmealib
Defines a base class for NMEA messages, encapsulating common properties and behaviors.
Definition message.h:14
Base exception class for all NMEA library errors.
Represents an NMEA 0183 sentence.
Definition nmea0183.h:98
Registry for message type creators.
Factory for creating typed NMEA 0183 message objects from raw sentence strings.
Exception thrown when a sentence is not a valid XDR sentence.
Definition xdr.h:17
NotXDRException(const std::string &context, const std::string &details="")
Construct a NotXDRException with context and optional details.
Definition xdr.h:25
Represents a parsed NMEA 0183 XDR (Transducer Measurement) sentence.
Definition xdr.h:43
std::size_t getTransducerCount() const noexcept
Get the number of transducer measurements in this sentence.
Definition xdr.cpp:118
XDR & operator=(const XDR &)=default
const std::vector< TransducerMeasurement > & getTransducers() const noexcept
Get all transducer measurements in this sentence.
Definition xdr.cpp:114
std::string getStringContent(bool verbose) const noexcept override
Return a human-readable string representation of this message.
Definition xdr.cpp:69
XDR(const XDR &)=default
std::unique_ptr< nmealib::Message > clone() const override
Create a polymorphic copy of this XDR message.
Definition xdr.cpp:65
XDR(XDR &&) noexcept=default
const TransducerMeasurement * getTransducer(std::size_t index) const noexcept
Get a transducer measurement by index.
Definition xdr.cpp:122
One transducer measurement quadruplet in an XDR sentence.
Definition xdr.h:48
std::string name
Free-form transducer name/label.
Definition xdr.h:56
char units
Single-character units code.
Definition xdr.h:54
char transducerType
Single-character transducer type identifier.
Definition xdr.h:50
double measurement
Numeric measurement value.
Definition xdr.h:52