nmealib 0.0.4
NMEA 0183/NMEA 2000 parsing library
Loading...
Searching...
No Matches
hdg.h
Go to the documentation of this file.
1#pragma once
2
3#include <nmealib/nmea0183.h>
4
5namespace nmealib {
6namespace nmea0183 {
7
15public:
22 explicit NotHDGException(const std::string& context, const std::string& details = "") :
23 NmeaException(context, "The sentence is not an HDG sentence", details) {}
24};
25
37class HDG : public Message0183 {
38public:
49 HDG(std::string talkerId,
50 double magneticHeading,
51 double magneticDeviation,
52 char deviationDirection,
53 double magneticVariation,
54 char variationDirection);
55
56 HDG(const HDG&) = default;
57 HDG& operator=(const HDG&) = default;
58 HDG(HDG&&) noexcept = default;
59 HDG& operator=(HDG&&) noexcept = default;
60
61 ~HDG() override = default;
62
63 std::unique_ptr<nmealib::Message> clone() const override;
64
65 double getMagneticHeading() const noexcept;
66 double getMagneticDeviation() const noexcept;
67 char getDeviationDirection() const noexcept;
68 double getMagneticVariation() const noexcept;
69 char getVariationDirection() const noexcept;
70
71 std::string getStringContent(bool verbose) const noexcept override;
72
73 bool operator==(const HDG& other) const noexcept;
74
75private:
76 double magneticHeading_{};
77 double magneticDeviation_{};
78 char deviationDirection_{};
79 double magneticVariation_{};
80 char variationDirection_{};
81
82 HDG() = delete;
83
84 HDG(Message0183 baseMessage,
85 double magneticHeading,
86 double magneticDeviation,
87 char deviationDirection,
88 double magneticVariation,
89 char variationDirection) noexcept;
90
91 static std::unique_ptr<HDG> create(std::unique_ptr<Message0183> baseMessage);
92 static std::string composeRaw(const std::string& talkerId,
93 double magneticHeading,
94 double magneticDeviation,
95 char deviationDirection,
96 double magneticVariation,
97 char variationDirection);
98
99 friend class Nmea0183Factory;
100 friend class MessageRegistry;
101};
102
103} // namespace nmea0183
104} // 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 HDG (Heading, Deviation & Variation) sentence.
Definition hdg.h:37
HDG(const HDG &)=default
HDG & operator=(const HDG &)=default
double getMagneticVariation() const noexcept
Definition hdg.cpp:145
std::unique_ptr< nmealib::Message > clone() const override
Creates a polymorphic deep copy of this message.
Definition hdg.cpp:91
std::string getStringContent(bool verbose) const noexcept override
Returns a human-readable string representation of the message content.
Definition hdg.cpp:95
char getVariationDirection() const noexcept
Definition hdg.cpp:149
double getMagneticDeviation() const noexcept
Definition hdg.cpp:137
char getDeviationDirection() const noexcept
Definition hdg.cpp:141
double getMagneticHeading() const noexcept
Definition hdg.cpp:133
HDG(HDG &&) noexcept=default
HDG(std::string talkerId, double magneticHeading, double magneticDeviation, char deviationDirection, double magneticVariation, char variationDirection)
Construct an HDG message from individual field values.
Definition hdg.cpp:73
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 HDG sentence.
Definition hdg.h:14
NotHDGException(const std::string &context, const std::string &details="")
Construct a NotHDGException with context and optional details.
Definition hdg.h:22