General: standard compliance with underscores
[marnav.git] / include / marnav / ais / message_08.hpp
blob876eac6cb3149e42751ab6b5ac124a277d72d937
1 #ifndef MARNAV_AIS_MESSAGE_08_HPP
2 #define MARNAV_AIS_MESSAGE_08_HPP
4 #include <marnav/ais/message.hpp>
5 #include <marnav/utils/mmsi.hpp>
7 namespace marnav
9 namespace ais
11 class binary_001_11; // forward
12 class binary_200_10; // forward
14 /// @brief Binary Broadcast Message
15 class message_08 : public message
17 friend class detail::factory;
19 public:
20 constexpr static message_id ID = message_id::binary_broadcast_message;
21 constexpr static std::size_t SIZE_BITS_HEAD = 56u;
22 constexpr static std::size_t SIZE_BITS_MAX = 1008u;
24 message_08();
25 message_08(const message_08 &) = default;
26 message_08 & operator=(const message_08 &) = default;
27 message_08(message_08 &&) = default;
28 message_08 & operator=(message_08 &&) = default;
30 protected:
31 message_08(const raw & bits);
32 void read_data(const raw & bits);
33 virtual raw get_data() const override;
35 private:
36 // clang-format off
37 bitset_value< 6, 2, uint32_t> repeat_indicator = 0;
38 bitset_value< 8, 30, uint32_t> mmsi = 0;
39 bitset_value<40, 10, uint32_t> dac = 0; ///< Designate Area Cod3
40 bitset_value<50, 6, uint32_t> fid = 0; ///< Functional ID
41 // clang-format on
43 // unfortuanately std::variant is C++17, therefore we need to store
44 // the binary payload and parse it later.
45 raw payload;
47 public:
48 uint32_t get_repeat_indicator() const noexcept { return repeat_indicator; }
49 utils::mmsi get_mmsi() const noexcept { return utils::mmsi{mmsi}; }
50 uint32_t get_dac() const noexcept { return dac; }
51 uint32_t get_fid() const noexcept { return fid; }
53 // payload
54 void read_binary(binary_001_11 & m) const;
55 void read_binary(binary_200_10 & m) const;
57 void set_repeat_indicator(uint32_t t) noexcept { repeat_indicator = t; }
58 void set_mmsi(const utils::mmsi & t) noexcept { mmsi = t; }
59 void set_dac(uint32_t t) noexcept { dac = t; }
60 void set_fid(uint32_t t) noexcept { fid = t; }
62 // payload
63 void write_binary(const binary_001_11 & m);
64 void write_binary(const binary_200_10 & m);
69 #endif