OpenCPN Partial API docs
comm_drv_registry.h
1 /***************************************************************************
2  *
3  * Project: OpenCPN
4  * Purpose: Driver registration container, a singleton.
5  * Author: David Register, Alec Leamas
6  *
7  ***************************************************************************
8  * Copyright (C) 2022 by David Register, Alec Leamas *
9  * *
10  * This program is free software; you can redistribute it and/or modify *
11  * it under the terms of the GNU General Public License as published by *
12  * the Free Software Foundation; either version 2 of the License, or *
13  * (at your option) any later version. *
14  * *
15  * This program is distributed in the hope that it will be useful, *
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
18  * GNU General Public License for more details. *
19  * *
20  * You should have received a copy of the GNU General Public License *
21  * along with this program; if not, write to the *
22  * Free Software Foundation, Inc., *
23  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
24  **************************************************************************/
25 
26 #ifndef _COMMDRIVERREGISTRY_H__
27 #define _COMMDRIVERREGISTRY_H__
28 
29 #include "model/comm_driver.h"
30 #include "observable_evtvar.h"
31 
32 typedef std::shared_ptr<AbstractCommDriver> DriverPtr;
33 
40 class CommDriverRegistry final {
41 public:
42  static CommDriverRegistry& GetInstance();
43 
45  void Activate(DriverPtr driver);
46 
48  void Deactivate(DriverPtr driver);
49 
51  void CloseAllDrivers();
52 
54  const std::vector<DriverPtr>& GetDrivers();
55 
58 
61 
64 
72 
73 private:
74  CommDriverRegistry() = default;
75  CommDriverRegistry(const CommDriverRegistry&) = delete;
76  CommDriverRegistry& operator=(const CommDriverRegistry&) = delete;
77 
78  std::vector<DriverPtr> drivers;
79 };
80 
85 const DriverPtr FindDriver(const std::vector<DriverPtr>& drivers,
86  const std::string& iface,
87  const NavAddr::Bus _bus = NavAddr::Bus::Undef);
88 
89 #endif // guard
The global driver registry, a singleton.
EventVar evt_driver_msg
Notified for messages from drivers.
void Activate(DriverPtr driver)
Add driver to list of active drivers.
EventVar evt_driverlist_change
Notified by all driverlist updates.
void Deactivate(DriverPtr driver)
Remove driver from list of active drivers.
void CloseAllDrivers()
Close and destroy all drivers completely.
EventVar evt_dump_stats
Notified when receiving –remote –dump_stat on local API.
const std::vector< DriverPtr > & GetDrivers()
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.