nmealib 0.0.4
NMEA 0183/NMEA 2000 parsing library
Loading...
Searching...
No Matches
mwv.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 NotMWVException(const std::string& context, const std::string& details = "") :
23 NmeaException(context, "The sentence is not an MWV sentence", details) {}
24};
25
37class MWV : public Message0183 {
38public:
49 MWV(std::string talkerId,
50 double windAngle,
51 char reference,
52 double windSpeed,
53 char windSpeedUnits,
54 char status
55 );
56
57 MWV(const MWV&) = default;
58 MWV& operator=(const MWV&) = default;
59 MWV(MWV&&) noexcept = default;
60 MWV& operator=(MWV&&) noexcept = default;
61
62 ~MWV() override = default;
63
69 std::unique_ptr<nmealib::Message> clone() const override;
70
72 double getWindAngle() const noexcept;
74 char getReference() const noexcept;
76 double getWindSpeed() const noexcept;
78 char getWindSpeedUnits() const noexcept;
80 char getStatus() const noexcept;
81
88 std::string getStringContent(bool verbose) const noexcept override;
89
98 bool operator==(const MWV& other) const noexcept;
99
100private:
101 double windAngle_{};
102 char reference_{};
103 double windSpeed_{};
104 char windSpeedUnits_{};
105 char status_{};
106
107 MWV() = delete;
108
109 MWV(Message0183 baseMessage,
110 double windAngle,
111 char reference,
112 double windSpeed,
113 char windSpeedUnits,
114 char status
115 ) noexcept;
116
117 static std::unique_ptr<MWV> create(std::unique_ptr<Message0183> baseMessage);
118 static std::string composeRaw(const std::string& talkerId,
119 double windAngle,
120 char reference,
121 double windSpeed,
122 char windSpeedUnits,
123 char status);
124
125 friend class Nmea0183Factory;
126 friend class MessageRegistry;
127};
128
129} // namespace nmea0183
130} // 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 MWV (Wind Speed and Angle) sentence.
Definition mwv.h:37
MWV(const MWV &)=default
MWV(MWV &&) noexcept=default
char getReference() const noexcept
Get reference indicator.
Definition mwv.cpp:135
std::unique_ptr< nmealib::Message > clone() const override
Create a polymorphic copy of this MWV message.
Definition mwv.cpp:90
double getWindSpeed() const noexcept
Get wind speed value.
Definition mwv.cpp:139
double getWindAngle() const noexcept
Get wind angle in degrees.
Definition mwv.cpp:131
char getStatus() const noexcept
Get data status indicator.
Definition mwv.cpp:147
std::string getStringContent(bool verbose) const noexcept override
Return a human-readable string representation of this message.
Definition mwv.cpp:94
MWV & operator=(const MWV &)=default
char getWindSpeedUnits() const noexcept
Get wind speed unit indicator.
Definition mwv.cpp:143
MWV(std::string talkerId, double windAngle, char reference, double windSpeed, char windSpeedUnits, char status)
Construct an MWV message from individual field values.
Definition mwv.cpp:72
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 MWV sentence.
Definition mwv.h:14
NotMWVException(const std::string &context, const std::string &details="")
Construct a NotMWVException with context and optional details.
Definition mwv.h:22