nmealib 0.0.4
NMEA 0183/NMEA 2000 parsing library
Loading...
Searching...
No Matches
vlw.h
Go to the documentation of this file.
1#pragma once
2
3#include <nmealib/nmea0183.h>
4
5#include <optional>
6
7namespace nmealib {
8namespace nmea0183 {
9
11public:
12 explicit NotVLWException(const std::string& context, const std::string& details = "") :
13 NmeaException(context, "The sentence is not a VLW sentence", details) {}
14};
15
16class VLW : public Message0183 {
17public:
18 VLW(std::string talkerId,
19 double totalWaterDistanceNm,
20 double waterDistanceSinceResetNm,
21 std::optional<double> totalGroundDistanceNm = std::nullopt,
22 std::optional<double> groundDistanceSinceResetNm = std::nullopt);
23
24 VLW(const VLW&) = default;
25 VLW& operator=(const VLW&) = default;
26 VLW(VLW&&) noexcept = default;
27 VLW& operator=(VLW&&) noexcept = default;
28
29 ~VLW() override = default;
30
31 std::unique_ptr<nmealib::Message> clone() const override;
32
33 double getTotalWaterDistanceNm() const noexcept;
34 char getTotalWaterDistanceUnit() const noexcept;
35 double getWaterDistanceSinceResetNm() const noexcept;
36 char getWaterDistanceSinceResetUnit() const noexcept;
37
38 bool hasGroundDistanceData() const noexcept;
39 double getTotalGroundDistanceNm() const noexcept;
40 char getTotalGroundDistanceUnit() const noexcept;
41 double getGroundDistanceSinceResetNm() const noexcept;
42 char getGroundDistanceSinceResetUnit() const noexcept;
43
44 std::string getStringContent(bool verbose) const noexcept override;
45 bool operator==(const VLW& other) const noexcept;
46
47private:
48 double totalWaterDistanceNm_{};
49 char totalWaterDistanceUnit_{};
50 double waterDistanceSinceResetNm_{};
51 char waterDistanceSinceResetUnit_{};
52 bool hasGroundDistanceData_{};
53 double totalGroundDistanceNm_{};
54 char totalGroundDistanceUnit_{};
55 double groundDistanceSinceResetNm_{};
56 char groundDistanceSinceResetUnit_{};
57
58 VLW() = delete;
59
60 VLW(Message0183 baseMessage,
61 double totalWaterDistanceNm,
62 char totalWaterDistanceUnit,
63 double waterDistanceSinceResetNm,
64 char waterDistanceSinceResetUnit,
66 double totalGroundDistanceNm,
67 char totalGroundDistanceUnit,
68 double groundDistanceSinceResetNm,
69 char groundDistanceSinceResetUnit) noexcept;
70
71 static std::unique_ptr<VLW> create(std::unique_ptr<Message0183> baseMessage);
72 static std::string composeRaw(const std::string& talkerId,
73 double totalWaterDistanceNm,
74 double waterDistanceSinceResetNm,
75 std::optional<double> totalGroundDistanceNm,
76 std::optional<double> groundDistanceSinceResetNm);
77
78 friend class Nmea0183Factory;
79 friend class MessageRegistry;
80};
81
82} // namespace nmea0183
83} // 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.
NotVLWException(const std::string &context, const std::string &details="")
Definition vlw.h:12
char getTotalWaterDistanceUnit() const noexcept
Definition vlw.cpp:175
double getWaterDistanceSinceResetNm() const noexcept
Definition vlw.cpp:179
VLW(const VLW &)=default
std::unique_ptr< nmealib::Message > clone() const override
Creates a polymorphic deep copy of this Message0183.
Definition vlw.cpp:119
char getWaterDistanceSinceResetUnit() const noexcept
Definition vlw.cpp:183
char getTotalGroundDistanceUnit() const noexcept
Definition vlw.cpp:195
VLW(std::string talkerId, double totalWaterDistanceNm, double waterDistanceSinceResetNm, std::optional< double > totalGroundDistanceNm=std::nullopt, std::optional< double > groundDistanceSinceResetNm=std::nullopt)
Definition vlw.cpp:99
double getTotalGroundDistanceNm() const noexcept
Definition vlw.cpp:191
std::string getStringContent(bool verbose) const noexcept override
Returns a human-readable string representation of the message content.
Definition vlw.cpp:123
bool hasGroundDistanceData() const noexcept
Definition vlw.cpp:187
VLW & operator=(const VLW &)=default
VLW(VLW &&) noexcept=default
char getGroundDistanceSinceResetUnit() const noexcept
Definition vlw.cpp:203
double getTotalWaterDistanceNm() const noexcept
Definition vlw.cpp:171
double getGroundDistanceSinceResetNm() const noexcept
Definition vlw.cpp:199