nmealib 0.0.4
NMEA 0183/NMEA 2000 parsing library
Loading...
Searching...
No Matches
mtw.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 NotMTWException(const std::string& context, const std::string& details = "") :
24 NmeaException(context, "The sentence is not an MTW sentence", details) {}
25};
26
46class MTW : public Message0183 {
47public:
59 MTW(std::string talkerId,
60 double temperature,
61 char unit);
62
63 MTW(const MTW&) = default;
64 MTW& operator=(const MTW&) = default;
65 MTW(MTW&&) noexcept = default;
66 MTW& operator=(MTW&&) noexcept = default;
67
68 ~MTW() override = default;
69
75 std::unique_ptr<nmealib::Message> clone() const override;
76
82 double getTemperature() const noexcept;
83
91 char getUnit() const noexcept;
92
101 std::string getStringContent(bool verbose) const noexcept override;
102
112 bool operator==(const MTW& other) const noexcept;
113
114private:
115 double temperature_{};
116 char unit_{};
117
118 MTW() = delete;
119
120 MTW(Message0183 baseMessage,
121 double temperature,
122 char unit) noexcept;
123
124 static std::unique_ptr<MTW> create(std::unique_ptr<Message0183> baseMessage);
125 static std::string composeRaw(const std::string& talkerId,
126 double temperature,
127 char unit);
128
129 friend class Nmea0183Factory;
130 friend class MessageRegistry;
131};
132
133} // namespace nmea0183
134} // 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 MTW (Mean Temperature of Water) sentence.
Definition mtw.h:46
double getTemperature() const noexcept
Get the water temperature value.
Definition mtw.cpp:97
char getUnit() const noexcept
Get the temperature unit character.
Definition mtw.cpp:101
std::string getStringContent(bool verbose) const noexcept override
Return a human-readable string representation of this message.
Definition mtw.cpp:70
std::unique_ptr< nmealib::Message > clone() const override
Create a polymorphic copy of this MTW message.
Definition mtw.cpp:66
MTW(const MTW &)=default
MTW & operator=(const MTW &)=default
MTW(MTW &&) 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 MTW sentence.
Definition mtw.h:14
NotMTWException(const std::string &context, const std::string &details="")
Construct a NotMTWException with context and optional details.
Definition mtw.h:23