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, write to the *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
18 **************************************************************************/
19
27#ifndef ABSTRACT_NMEA_LOG_
28#define ABSTRACT_NMEA_LOG_
29
30#include "model/comm_navmsg.h"
31#include "model/navmsg_filter.h"
32
34struct Logline {
35 const std::shared_ptr<const NavMsg> navmsg;
36 const NavmsgStatus state;
37 const std::string message;
38 std::string error_msg;
39 std::string prefix;
40
41 Logline() = default;
42
43 Logline(const std::shared_ptr<const NavMsg>& navmsg, NavmsgStatus sts)
44 : navmsg(navmsg),
45 state(sts),
46 message(navmsg ? navmsg->to_string() : ""),
47 error_msg("Unknown error") {}
48
49 explicit Logline(const std::shared_ptr<const NavMsg>& navmsg)
50 : Logline(navmsg, [navmsg] {
51 if (navmsg->state == NavMsg::State::kOk) return NavmsgStatus();
52
53 NavmsgStatus navmsg_status;
54 if (navmsg->state == NavMsg::State::kBadChecksum)
55 navmsg_status.status = NavmsgStatus::State::kChecksumError;
56 else if (navmsg->state == NavMsg::State::kCannotParse)
57 navmsg_status.status = NavmsgStatus::State::kMalformed;
58 else if (navmsg->state == NavMsg::State::kFiltered)
59 navmsg_status.accepted = NavmsgStatus::Accepted::kFilteredDropped;
60 return navmsg_status;
61 }()) {}
62};
63
72class NmeaLog {
73public:
74 virtual ~NmeaLog() = default;
75
77 virtual void Add(const Logline& l) = 0;
78
80 [[nodiscard]] virtual bool IsVisible() const = 0;
81};
82
83#endif // ABSTRACT_NMEA_LOG_
Representation of message status as determined by the multiplexer.
NMEA Log Interface.
Definition nmea_log.h:72
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:34