OpenCPN Partial API docs
Loading...
Searching...
No Matches
comm_appmsg_bus.cpp
Go to the documentation of this file.
1/***************************************************************************
2 * Copyright (C) 2022 by David Register *
3 * Copyright (C) 2022 Alec Leamas *
4 * *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, see <https://www.gnu.org/licenses/>. *
17 **************************************************************************/
18
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 // precompiled headers
31
34
35void AppMsgBus::Notify(const std::shared_ptr<const AppMsg>& msg) {
36 std::string key = "Internal::" + msg->GetKey();
37 NavMsgBus::GetInstance().RegisterKey(key);
38 Observable(*msg).Notify(msg);
39}
40
41AppMsgBus& AppMsgBus::GetInstance() {
42 static AppMsgBus instance;
43 return instance;
44}
Application layer messaging, a singleton.
void Notify(const std::shared_ptr< const AppMsg > &msg)
Send message to everyone listening to given message type.
void RegisterKey(const std::string &key)
Register a message type in list the GetActiveMessages() list.
The observable notify/listen basic nuts and bolts.
Definition observable.h:100
virtual void Notify()
Notify all listeners about variable change.
Decoded messages send/receive support.
Raw messages layer, supports sending and recieving navmsg messages.