OpenCPN Partial API docs
Loading...
Searching...
No Matches
data_monitor_src.h
Go to the documentation of this file.
1/***************************************************************************
2 * Copyright (C) 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
26
27#ifndef DATA_MONITOR_SRC__
28#define DATA_MONITOR_SRC__
29
30#include <functional>
31#include <memory>
32#include <string>
33#include <unordered_map>
34
35#include <wx/event.h>
36
38
39#include "model/comm_navmsg.h"
41#include "model/ocpn_utils.h"
42
49class DataMonitorSrc : public wxEvtHandler {
51 using SinkFunc = std::function<void(const std::shared_ptr<const NavMsg>&)>;
52
53public:
58 DataMonitorSrc(const SinkFunc& sink_func);
59
60private:
61 SinkFunc m_sink_func;
62 std::unordered_map<std::string, obs::Listener> m_listeners;
63 obs::Listener new_msg_lstnr;
64 obs::Listener undelivered_msg_lstnr;
65
67 void OnNewMessage();
68
70 void OnMessage(ObservedEvt& ev);
71};
72
73#endif // DATA_MONITOR_SRC__
DataMonitorSrc(const SinkFunc &sink_func)
Create instance which listens and forwards messages using the sink_func callback function.
Custom event class for OpenCPN's notification system.
Define an action to be performed when a KeyProvider is notified.
Definition observable.h:293
Raw, undecoded messages definitions.
Raw messages layer, supports sending and recieving navmsg messages.
General observable pattern implementation built on top of wxWidgets event handling.
Miscellaneous utilities, many of which string related.