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, write to the *
17 * Free Software Foundation, Inc., *
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
19 **************************************************************************/
20
26#ifndef _COMMDRIVERREGISTRY_H__
27#define _COMMDRIVERREGISTRY_H__
28
29#include "model/comm_driver.h"
30#include "observable_evtvar.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
63
66
69
72
80
81private:
82 CommDriverRegistry() = default;
84 CommDriverRegistry& operator=(const CommDriverRegistry&) = delete;
85
86 std::vector<DriverPtr> drivers;
87};
88
97DriverPtr& FindDriver(const std::vector<DriverPtr>& drivers,
98 const std::string& iface,
99 const NavAddr::Bus _bus = NavAddr::Bus::Undef);
100
101#endif // guard
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.
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.