nmealib 0.0.4
NMEA 0183/NMEA 2000 parsing library
Loading...
Searching...
No Matches
hdm.h
Go to the documentation of this file.
1#pragma once
2
3#include <nmealib/nmea0183.h>
4
5namespace nmealib {
6namespace nmea0183 {
7
15public:
23 explicit NotHDMException(const std::string& context, const std::string& details = "") :
24 NmeaException(context, "The sentence is not an HDM sentence", details) {}
25};
26
47class HDM : public Message0183 {
48public:
60 HDM(std::string talkerId,
61 double heading,
62 char indicator);
63
64 HDM(const HDM&) = default;
65 HDM& operator=(const HDM&) = default;
66 HDM(HDM&&) noexcept = default;
67 HDM& operator=(HDM&&) noexcept = default;
68
69 ~HDM() override = default;
70
76 std::unique_ptr<nmealib::Message> clone() const override;
77
83 double getHeading() const noexcept;
84
92 char getIndicator() const noexcept;
93
102 std::string getStringContent(bool verbose) const noexcept override;
103
113 bool operator==(const HDM& other) const noexcept;
114
115private:
116 double heading_{};
117 char indicator_{};
118
119 HDM() = delete;
120
121 HDM(Message0183 baseMessage,
122 double heading,
123 char indicator) noexcept;
124
125 static std::unique_ptr<HDM> create(std::unique_ptr<Message0183> baseMessage);
126 static std::string composeRaw(const std::string& talkerId,
127 double heading,
128 char indicator);
129
130 friend class Nmea0183Factory;
131 friend class MessageRegistry;
132};
133
134} // namespace nmea0183
135} // 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 a parsed NMEA 0183 HDM (Heading – Magnetic) sentence.
Definition hdm.h:47
double getHeading() const noexcept
Get the vessel heading in degrees magnetic.
Definition hdm.cpp:97
HDM & operator=(const HDM &)=default
std::string getStringContent(bool verbose) const noexcept override
Return a human-readable string representation of this message.
Definition hdm.cpp:70
char getIndicator() const noexcept
Get the magnetic heading indicator character.
Definition hdm.cpp:101
std::unique_ptr< nmealib::Message > clone() const override
Create a polymorphic copy of this HDM message.
Definition hdm.cpp:66
HDM(const HDM &)=default
HDM(HDM &&) noexcept=default
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 HDM sentence.
Definition hdm.h:14
NotHDMException(const std::string &context, const std::string &details="")
Construct a NotHDMException with context and optional details.
Definition hdm.h:23