GNSS-SDR 0.0.21
An Open Source GNSS Software Defined Receiver
Loading...
Searching...
No Matches
serdes_nav_message.h
Go to the documentation of this file.
1/*!
2 * \file serdes_nav_message.h
3 * \brief Serialization / Deserialization of Nav_Message_Packet objects using
4 * Protocol Buffers
5 * \author Carles Fernandez-Prades, 2021. cfernandez(at)cttc.es
6 *
7 * -----------------------------------------------------------------------------
8 *
9 * GNSS-SDR is a Global Navigation Satellite System software-defined receiver.
10 * This file is part of GNSS-SDR.
11 *
12 * Copyright (C) 2010-2021 (see AUTHORS file for a list of contributors)
13 * SPDX-License-Identifier: GPL-3.0-or-later
14 *
15 * -----------------------------------------------------------------------------
16 */
17
18#ifndef GNSS_SDR_SERDES_NAV_MESSAGE_H
19#define GNSS_SDR_SERDES_NAV_MESSAGE_H
20
21#include "nav_message.pb.h" // file created by Protocol Buffers at compile time
22#include "nav_message_packet.h"
23#include <cstdint>
24#include <memory>
25#include <string>
26#include <utility>
27
28/** \addtogroup Telemetry_Decoder
29 * \{ */
30/** \addtogroup Telemetry_Decoder_libs
31 * \{ */
32
33
34/*!
35 * \brief This class implements serialization and deserialization of
36 * Nav_Message_Packet objects using Protocol Buffers.
37 */
38class Serdes_Nav_Message
39{
40public:
41 Serdes_Nav_Message()
42 {
43 // Verify that the version of the library that we linked against is
44 // compatible with the version of the headers we compiled against.
45 GOOGLE_PROTOBUF_VERIFY_VERSION;
46 }
47
48 ~Serdes_Nav_Message()
49 {
50 // google::protobuf::ShutdownProtobufLibrary();
51 }
52
53 inline Serdes_Nav_Message(const Serdes_Nav_Message& other) noexcept : navmsg_(other.navmsg_) //!< Copy constructor
54 {
55 }
56
57 inline Serdes_Nav_Message& operator=(const Serdes_Nav_Message& rhs) noexcept //!< Copy assignment operator
58 {
59 if (this != &rhs)
60 {
61 this->navmsg_.CopyFrom(rhs.navmsg_);
62 }
63 return *this;
64 }
65
66 inline Serdes_Nav_Message(Serdes_Nav_Message&& other) noexcept : navmsg_(std::move(other.navmsg_)) //!< Move constructor
67 {
68 // Set the other object's navmsg_ to a default-constructed state
69 other.navmsg_ = gnss_sdr::navMsg{};
70 }
71
72 inline Serdes_Nav_Message& operator=(Serdes_Nav_Message&& other) noexcept //!< Move assignment operator
73 {
74 if (this != &other)
75 {
76 navmsg_ = std::move(other.navmsg_);
77 other.navmsg_ = gnss_sdr::navMsg{};
78 }
79 return *this;
80 }
81
82 inline std::string createProtobuffer(const std::shared_ptr<Nav_Message_Packet> nav_msg_packet) //!< Serialization into a string
83 {
84 navmsg_.Clear();
85 std::string data;
86
87 navmsg_.set_system(nav_msg_packet->system);
88 navmsg_.set_signal(nav_msg_packet->signal);
89 navmsg_.set_prn(nav_msg_packet->prn);
90 navmsg_.set_tow_at_current_symbol_ms(nav_msg_packet->tow_at_current_symbol_ms);
91 navmsg_.set_nav_message(nav_msg_packet->nav_message);
92
93 navmsg_.SerializeToString(&data);
94
95 return data;
96 }
97
98 inline Nav_Message_Packet readProtobuffer(const gnss_sdr::navMsg& msg) const //!< Deserialization
99 {
100 Nav_Message_Packet navmsg;
101
102 navmsg.system = msg.system();
103 navmsg.signal = msg.signal();
104 navmsg.prn = msg.prn();
105 navmsg.tow_at_current_symbol_ms = msg.tow_at_current_symbol_ms();
106 navmsg.nav_message = msg.nav_message();
107
108 return navmsg;
109 }
110
111private:
112 gnss_sdr::navMsg navmsg_{};
113};
114
115
116/** \} */
117/** \} */
118#endif // GNSS_SDR_SERDES_NAV_MESSAGE_H
std::string signal
GNSS signal: "1C" for GPS L1 C/A, "1B" for Galileo E1b/c, "1G" for Glonass L1 C/A,...
std::string nav_message
Content of the navigation page.
std::string system
GNSS constellation: "G" for GPS, "R" for Glonass, "S" for SBAS, "E" for Galileo and "C" for Beidou.
int32_t tow_at_current_symbol_ms
Time of week of the current symbol, in ms.
This class implements serialization and deserialization of Nav_Message_Packet objects using Protocol ...
Nav_Message_Packet readProtobuffer(const gnss_sdr::navMsg &msg) const
< Deserialization
Serdes_Nav_Message & operator=(const Serdes_Nav_Message &rhs) noexcept
< Copy assignment operator
std::string createProtobuffer(const std::shared_ptr< Nav_Message_Packet > nav_msg_packet)
Serdes_Nav_Message & operator=(Serdes_Nav_Message &&other) noexcept
< Move assignment operator
Class for storage of decoded navigation messages.