GNSS-SDR  0.0.17
An Open Source GNSS Software Defined Receiver
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  */
39 {
40 public:
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 
49  {
50  // google::protobuf::ShutdownProtobufLibrary();
51  }
52 
53  inline Serdes_Nav_Message(const Serdes_Nav_Message& other) noexcept //!< Copy constructor
54  {
55  this->navmsg_ = other.navmsg_;
56  }
57 
58  inline Serdes_Nav_Message& operator=(const Serdes_Nav_Message& rhs) noexcept //!< Copy assignment operator
59  {
60  this->navmsg_ = rhs.navmsg_;
61  return *this;
62  }
63 
64  inline Serdes_Nav_Message(Serdes_Nav_Message&& other) noexcept //!< Move constructor
65  {
66  this->navmsg_ = std::move(other.navmsg_);
67  }
68 
69  inline Serdes_Nav_Message& operator=(Serdes_Nav_Message&& other) noexcept //!< Move assignment operator
70  {
71  if (this != &other)
72  {
73  this->navmsg_ = std::move(other.navmsg_);
74  }
75  return *this;
76  }
77 
78  inline std::string createProtobuffer(const std::shared_ptr<Nav_Message_Packet> nav_msg_packet) //!< Serialization into a string
79  {
80  navmsg_.Clear();
81  std::string data;
82 
83  navmsg_.set_system(nav_msg_packet->system);
84  navmsg_.set_signal(nav_msg_packet->signal);
85  navmsg_.set_prn(nav_msg_packet->prn);
86  navmsg_.set_tow_at_current_symbol_ms(nav_msg_packet->tow_at_current_symbol_ms);
87  navmsg_.set_nav_message(nav_msg_packet->nav_message);
88 
89  navmsg_.SerializeToString(&data);
90 
91  return data;
92  }
93 
94  inline Nav_Message_Packet readProtobuffer(const gnss_sdr::navMsg& msg) const //!< Deserialization
95  {
96  Nav_Message_Packet navmsg;
97 
98  navmsg.system = msg.system();
99  navmsg.signal = msg.signal();
100  navmsg.prn = msg.prn();
101  navmsg.tow_at_current_symbol_ms = msg.tow_at_current_symbol_ms();
102  navmsg.nav_message = msg.nav_message();
103 
104  return navmsg;
105  }
106 
107 private:
108  gnss_sdr::navMsg navmsg_{};
109 };
110 
111 
112 /** \} */
113 /** \} */
114 #endif // GNSS_SDR_SERDES_NAV_MESSAGE_H
This class implements serialization and deserialization of Nav_Message_Packet objects using Protocol ...
Serdes_Nav_Message & operator=(Serdes_Nav_Message &&other) noexcept
< Move assignment operator
std::string signal
GNSS signal: "1C" for GPS L1 C/A, "1B" for Galileo E1b/c, "1G" for Glonass L1 C/A, "2S" for GPS L2 L2C(M), "2G" for Glonass L2 C/A, "L5" for GPS L5 and "5X" for Galileo E5a.
std::string createProtobuffer(const std::shared_ptr< Nav_Message_Packet > nav_msg_packet)
Nav_Message_Packet readProtobuffer(const gnss_sdr::navMsg &msg) const
< Deserialization
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.
Serdes_Nav_Message(Serdes_Nav_Message &&other) noexcept
< Move constructor
std::string nav_message
Content of the navigation page.
Serdes_Nav_Message(const Serdes_Nav_Message &other) noexcept
< Copy constructor
Serdes_Nav_Message & operator=(const Serdes_Nav_Message &rhs) noexcept
< Copy assignment operator