Utils: optional constructors now not defaulted anymore.
[marnav.git] / src / marnav / nmea / dpt.hpp
blob2d5620f670857fb119ade589a66c29be108c34e4
1 #ifndef __MARNAV__NMEA__DPT__HPP__
2 #define __MARNAV__NMEA__DPT__HPP__
4 #include <marnav/nmea/sentence.hpp>
5 #include <marnav/utils/optional.hpp>
7 namespace marnav
9 namespace nmea
11 MARNAV_NMEA_DECLARE_SENTENCE_PARSE_FUNC(dpt)
13 /// @brief DPT - Depth of Water
14 ///
15 /// Water depth relative to the transducer and offset of the measuring transducer.
16 ///
17 /// @code
18 /// 1 2 3
19 /// | | |
20 /// $--DPT,x.x,x.x,x.x*hh<CR><LF>
21 /// @endcode
22 ///
23 /// Field Number:
24 /// 1. Depth meters
25 /// 2. Offset from transducer
26 /// - positive value means distance from tansducer to water line
27 /// - negative value means distance from transducer to keel
28 /// 3. Max depth in meters, might be empty. This field exists allegedly since NMEA 3.0
29 ///
30 class dpt : public sentence
32 MARNAV_NMEA_SENTENCE_FRIENDS(dpt)
34 public:
35 constexpr static const sentence_id ID = sentence_id::DPT;
36 constexpr static const char * TAG = "DPT";
38 dpt();
39 dpt(const std::string & talker);
40 dpt(const dpt &) = default;
41 dpt & operator=(const dpt &) = default;
42 dpt(dpt &&) = default;
43 dpt & operator=(dpt &&) = default;
45 protected:
46 dpt(const std::string & talker, fields::const_iterator first, fields::const_iterator last);
47 virtual std::vector<std::string> get_data() const override;
49 private:
50 double depth_meter = 0.0;
51 double transducer_offset = 0.0;
52 utils::optional<double> max_depth;
54 public:
55 decltype(depth_meter) get_depth_meter() const noexcept { return depth_meter; }
56 decltype(transducer_offset) get_transducer_offset() const noexcept
58 return transducer_offset;
60 decltype(max_depth) get_max_depth() const noexcept { return max_depth; }
62 void set_depth_meter(double t) noexcept { depth_meter = t; }
63 void set_transducer_offset(double t) noexcept { transducer_offset = t; }
64 void set_max_depth(double t) noexcept { max_depth = t; }
69 #endif