OpenCPN Partial API docs
Loading...
Searching...
No Matches
nmea_log.h
Go to the documentation of this file.
1/**************************************************************************
2 * Copyright (C) 2024 - 2025 Alec Leamas *
3 * *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
8 * *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
13 * *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, see <https://www.gnu.org/licenses/>. *
16 **************************************************************************/
17
25#ifndef ABSTRACT_NMEA_LOG_
26#define ABSTRACT_NMEA_LOG_
27
28#include "model/comm_navmsg.h"
29#include "model/navmsg_filter.h"
30
32struct Logline {
33 const std::shared_ptr<const NavMsg> navmsg;
34 const NavmsgStatus state;
35 const std::string message;
36 std::string error_msg;
37 std::string prefix;
38
39 Logline() = default;
40
41 Logline(const std::shared_ptr<const NavMsg>& navmsg, NavmsgStatus sts)
42 : navmsg(navmsg),
43 state(sts),
44 message(navmsg ? navmsg->to_string() : ""),
45 error_msg("Unknown error") {}
46
47 explicit Logline(const std::shared_ptr<const NavMsg>& navmsg)
48 : Logline(navmsg, [navmsg] {
49 if (navmsg->state == NavMsg::State::kOk) return NavmsgStatus();
50
51 NavmsgStatus navmsg_status;
52 if (navmsg->state == NavMsg::State::kBadChecksum)
53 navmsg_status.status = NavmsgStatus::State::kChecksumError;
54 else if (navmsg->state == NavMsg::State::kCannotParse)
55 navmsg_status.status = NavmsgStatus::State::kMalformed;
56 else if (navmsg->state == NavMsg::State::kFiltered)
57 navmsg_status.accepted = NavmsgStatus::Accepted::kFilteredDropped;
58 return navmsg_status;
59 }()) {}
60};
61
70class NmeaLog {
71public:
72 virtual ~NmeaLog() = default;
73
75 virtual void Add(const Logline& l) = 0;
76
78 [[nodiscard]] virtual bool IsVisible() const = 0;
79};
80
81#endif // ABSTRACT_NMEA_LOG_
Representation of message status as determined by the multiplexer.
NMEA Log Interface.
Definition nmea_log.h:70
virtual bool IsVisible() const =0
Return true if log is visible i.e., if it's any point using Add().
virtual void Add(const Logline &l)=0
Add a formatted string to log output.
Raw, undecoded messages definitions.
Data monitor filter definitions.
Item in the log window.
Definition nmea_log.h:32