OpenCPN Partial API docs
Loading...
Searching...
No Matches
comm_drv_internal.cpp
Go to the documentation of this file.
1/***************************************************************************
2 * Copyright (C) 2024 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
25// For compilers that support precompilation, includes "wx.h".
26#include <wx/wxprec.h>
27
28#ifndef WX_PRECOMP
29#include <wx/wx.h>
30#endif
31
32#include <wx/log.h>
33#include <wx/string.h>
34
35#include "config.h"
39#include "model/logger.h"
40
41#include "observable.h"
42
43CommDriverInternal::CommDriverInternal(DriverListener& listener)
44 : AbstractCommDriver(NavAddr::Bus::Plugin, "internal"),
45 m_listener(listener) {
46 this->attributes["commPort"] = "internal";
47 this->attributes["ioDirection"] = "OUT";
48}
49
50bool CommDriverInternal::SendMessage(std::shared_ptr<const NavMsg> msg,
51 std::shared_ptr<const NavAddr> addr) {
52 auto msg_plugin = std::dynamic_pointer_cast<const PluginMsg>(msg);
53 if (!msg_plugin) {
54 WARNING_LOG << " CommDriverInternal::SendMessage::Illegal message type";
55 return false;
56 }
57 NavMsgBus::GetInstance().Notify(msg_plugin);
58 return true;
59}
Common interface for all drivers.
Definition comm_driver.h:58
bool SendMessage(std::shared_ptr< const NavMsg > msg, std::shared_ptr< const NavAddr > addr) override
Send a message to all plugins and core on internal bus.
Interface implemented by transport layer and possible other parties like test code which should handl...
Definition comm_driver.h:48
Where messages are sent to or received from.
void Notify(std::shared_ptr< const NavMsg > message)
Accept message received by driver, make it available for upper layers.
Plugin ABI encapsulation.
Internal send-only driver, send to plugins.
Driver registration container, a singleton.
Raw messages layer, supports sending and recieving navmsg messages.
Enhanced logging interface on top of wx/log.h.