nmealib 0.0.4
NMEA 0183/NMEA 2000 parsing library
Loading...
Searching...
No Matches
gsv.h
Go to the documentation of this file.
1#pragma once
2
3#include <nmealib/nmea0183.h>
4
5#include <cstddef>
6#include <optional>
7#include <vector>
8
9namespace nmealib {
10namespace nmea0183 {
11
13public:
14 explicit NotGSVException(const std::string& context, const std::string& details = "") :
15 NmeaException(context, "The sentence is not a GSV sentence", details) {}
16};
17
18class GSV : public Message0183 {
19public:
21 unsigned int satelliteId{};
22 int elevation{};
23 unsigned int azimuth{};
24 std::optional<unsigned int> snr{};
25 };
26
27 GSV(std::string talkerId,
28 unsigned int totalSentences,
29 unsigned int sentenceNumber,
30 unsigned int satellitesInView,
31 std::vector<SatelliteInfo> satellites,
32 std::optional<unsigned int> signalId = std::nullopt
33 );
34
35 GSV(const GSV&) = default;
36 GSV& operator=(const GSV&) = default;
37 GSV(GSV&&) noexcept = default;
38 GSV& operator=(GSV&&) noexcept = default;
39
40 ~GSV() override = default;
41
42 std::unique_ptr<nmealib::Message> clone() const override;
43
44 unsigned int getTotalSentences() const noexcept;
45 unsigned int getSentenceNumber() const noexcept;
46 unsigned int getSatellitesInView() const noexcept;
47 const std::vector<SatelliteInfo>& getSatellites() const noexcept;
48 std::size_t getSatelliteCount() const noexcept;
49 const SatelliteInfo* getSatellite(std::size_t index) const noexcept;
50 bool hasSignalId() const noexcept;
51 std::optional<unsigned int> getSignalId() const noexcept;
52
53 std::string getStringContent(bool verbose) const noexcept override;
54 bool operator==(const GSV& other) const noexcept;
55
56private:
57 unsigned int totalSentences_{};
58 unsigned int sentenceNumber_{};
59 unsigned int satellitesInView_{};
60 std::vector<SatelliteInfo> satellites_{};
61 std::optional<unsigned int> signalId_{};
62
63 GSV() = delete;
64
65 GSV(Message0183 baseMessage,
66 unsigned int totalSentences,
67 unsigned int sentenceNumber,
68 unsigned int satellitesInView,
69 std::vector<SatelliteInfo> satellites,
70 std::optional<unsigned int> signalId
71 ) noexcept;
72
73 static std::unique_ptr<GSV> create(std::unique_ptr<Message0183> baseMessage);
74 static std::string composeRaw(const std::string& talkerId,
75 unsigned int totalSentences,
76 unsigned int sentenceNumber,
77 unsigned int satellitesInView,
78 const std::vector<SatelliteInfo>& satellites,
79 std::optional<unsigned int> signalId);
80
81 friend class Nmea0183Factory;
82 friend class MessageRegistry;
83};
84
85} // namespace nmea0183
86} // 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.
unsigned int getTotalSentences() const noexcept
Definition gsv.cpp:199
GSV(std::string talkerId, unsigned int totalSentences, unsigned int sentenceNumber, unsigned int satellitesInView, std::vector< SatelliteInfo > satellites, std::optional< unsigned int > signalId=std::nullopt)
Definition gsv.cpp:124
std::optional< unsigned int > getSignalId() const noexcept
Definition gsv.cpp:230
GSV(GSV &&) noexcept=default
GSV(const GSV &)=default
GSV & operator=(const GSV &)=default
const std::vector< SatelliteInfo > & getSatellites() const noexcept
Definition gsv.cpp:211
std::size_t getSatelliteCount() const noexcept
Definition gsv.cpp:215
unsigned int getSentenceNumber() const noexcept
Definition gsv.cpp:203
bool hasSignalId() const noexcept
Definition gsv.cpp:226
std::unique_ptr< nmealib::Message > clone() const override
Creates a polymorphic deep copy of this message.
Definition gsv.cpp:142
unsigned int getSatellitesInView() const noexcept
Definition gsv.cpp:207
std::string getStringContent(bool verbose) const noexcept override
Returns a human-readable string representation of the message content.
Definition gsv.cpp:146
const SatelliteInfo * getSatellite(std::size_t index) const noexcept
Definition gsv.cpp:219
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.
NotGSVException(const std::string &context, const std::string &details="")
Definition gsv.h:14
std::optional< unsigned int > snr
Definition gsv.h:24