26 #include <wx/wxprec.h>
35 #include "model/comm_driver.h"
36 #include "model/comm_drv_registry.h"
39 auto found = std::find(drivers.begin(), drivers.end(), driver);
40 if (found != drivers.end())
return;
41 drivers.push_back(driver);
46 auto found = std::find(drivers.begin(), drivers.end(), driver);
47 if (found == drivers.end())
return;
57 while (drivers.size()) {
67 const std::shared_ptr<AbstractCommDriver> kNoDriver(
nullptr);
69 const DriverPtr FindDriver(
const std::vector<DriverPtr>& drivers,
70 const std::string& iface,
const NavAddr::Bus _bus) {
71 if (_bus != NavAddr::Bus::Undef){
72 auto func = [iface, _bus](
const DriverPtr d) {
73 return ((d->iface == iface) && (d->bus == _bus));
75 auto found = std::find_if(drivers.begin(), drivers.end(), func);
76 return found != drivers.end() ? *found : kNoDriver;
79 auto func = [iface](
const DriverPtr d) {
return d->iface == iface; };
80 auto found = std::find_if(drivers.begin(), drivers.end(), func);
81 return found != drivers.end() ? *found : kNoDriver;
85 const DriverPtr FindDriver(
const std::vector<DriverPtr>& drivers,
86 const std::string& key) {
87 auto func = [key](
const DriverPtr d) {
return d->Key() == key; };
88 auto found = std::find_if(drivers.begin(), drivers.end(), func);
89 return found != drivers.end() ? *found : kNoDriver;
The global driver registry, a singleton.
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()
const void Notify()
Notify all listeners, no data supplied.