OpenCPN Partial API docs
Loading...
Searching...
No Matches
comm_drv_registry.h
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#ifndef COMMDRIVERREGISTRY_H_
26#define COMMDRIVERREGISTRY_H_
27
28#include "model/comm_driver.h"
29#include "observable_evtvar.h"
30
31using DriverPtr = std::unique_ptr<AbstractCommDriver>;
32
44class CommDriverRegistry final {
45public:
46 static CommDriverRegistry& GetInstance();
47
49 void Activate(DriverPtr driver);
50
52 void Deactivate(DriverPtr& driver);
53
55 void CloseAllDrivers();
56
58 const std::vector<DriverPtr>& GetDrivers() const;
59
62
65
68
71
77
85
86private:
87 CommDriverRegistry() = default;
89 CommDriverRegistry& operator=(const CommDriverRegistry&) = delete;
90
91 std::vector<DriverPtr> drivers;
92};
93
102DriverPtr& FindDriver(const std::vector<DriverPtr>& drivers,
103 const std::string& iface,
104 const NavAddr::Bus _bus = NavAddr::Bus::Undef);
105
106#endif // COMMDRIVERREGISTRY_H_
The global driver registry, a singleton.
EventVar evt_driver_stats
Regularly notified by drivers with a DriverStats shared_ptr.
EventVar evt_driver_msg
Notified for messages from drivers.
EventVar evt_dropped_msg
Updated by drivers with a shared Navmsg pointer when receiving data otherwise dropped,...
void Deactivate(DriverPtr &driver)
Remove driver from list of active drivers.
void Activate(DriverPtr driver)
Add driver to list of active drivers.
const std::vector< DriverPtr > & GetDrivers() const
EventVar evt_driverlist_change
Notified by all driverlist updates.
void CloseAllDrivers()
Close and destroy all drivers completely.
EventVar evt_dump_stats
Notified when receiving –remote –dump_stat on local API.
EventVar evt_comm_overrun
Notified with a printable message on first detected overrun.
Generic event handling between MVC Model and Controller based on a shared EventVar variable.
Communication driver layer.
DriverPtr & FindDriver(const std::vector< DriverPtr > &drivers, const std::string &iface, const NavAddr::Bus _bus=NavAddr::Bus::Undef)
Search list of drivers for a driver with given interface string.
A common variable shared between producer and consumer which supports Listen() and Notify().