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 "observable/evtvar.h"
29
30#include "model/comm_driver.h"
31
32using DriverPtr = std::unique_ptr<AbstractCommDriver>;
33
45class CommDriverRegistry final {
46public:
47 static CommDriverRegistry& GetInstance();
48
50 void Activate(DriverPtr driver);
51
53 void Deactivate(DriverPtr& driver);
54
56 void CloseAllDrivers();
57
59 const std::vector<DriverPtr>& GetDrivers() const;
60
62 obs::EventVar evt_driverlist_change;
63
65 obs::EventVar evt_dump_stats;
66
68 obs::EventVar evt_comm_overrun;
69
71 obs::EventVar evt_driver_stats;
72
77 obs::EventVar evt_dropped_msg;
78
85 obs::EventVar evt_driver_msg;
86
87private:
88 CommDriverRegistry() = default;
90 CommDriverRegistry& operator=(const CommDriverRegistry&) = delete;
91
92 std::vector<DriverPtr> drivers;
93};
94
103DriverPtr& FindDriver(const std::vector<DriverPtr>& drivers,
104 const std::string& iface,
105 const NavAddr::Bus _bus = NavAddr::Bus::Undef);
106
107#endif // COMMDRIVERREGISTRY_H_
The global driver registry, a singleton.
obs::EventVar evt_dump_stats
Notified when receiving –remote –dump_stat on local API.
obs::EventVar evt_driverlist_change
Notified by all driverlist updates.
obs::EventVar evt_dropped_msg
Updated by drivers with a shared Navmsg pointer when receiving data otherwise dropped,...
obs::EventVar evt_driver_stats
Regularly notified by drivers with a DriverStats shared_ptr.
void Deactivate(DriverPtr &driver)
Remove driver from list of active drivers.
obs::EventVar evt_comm_overrun
Notified with a printable message on first detected overrun.
void Activate(DriverPtr driver)
Add driver to list of active drivers.
const std::vector< DriverPtr > & GetDrivers() const
void CloseAllDrivers()
Close and destroy all drivers completely.
obs::EventVar evt_driver_msg
Notified for messages from drivers.
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.