OpenCPN Partial API docs
Loading...
Searching...
No Matches
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 "comm_driver.h"
30#include "observable_evtvar.h"
31
33
39typedef std::shared_ptr<AbstractCommDriver> DriverPtr;
40
42class CommDriverRegistry final {
43public:
44 static CommDriverRegistry& GetInstance();
45
47 void Activate(DriverPtr driver);
48
50 void Deactivate(DriverPtr driver);
51
53 void CloseAllDrivers();
54
56 const std::vector<DriverPtr>& GetDrivers();
57
58
59 // FIXME (Dave)
60 // Stub method, to pretest drivers.
61 // Goes away for production
62 void TestDriver(ConnectionParams* params);
63
66
74
75private:
76 CommDriverRegistry() = default;
78 CommDriverRegistry& operator=(const CommDriverRegistry&) = delete;
79
80 std::vector<DriverPtr> drivers;
81};
82
87const DriverPtr FindDriver(const std::vector<DriverPtr>& drivers,
88 const std::string& iface,
89 const NavAddr::Bus _bus = NavAddr::Bus::Undef);
90
91#endif // guard
Registry for active, running drivers.
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.
const std::vector< DriverPtr > & GetDrivers()
Generic event handling between between two parties like MVC Model and Controller using a shared Event...