ControllerInterface: Add RemoveDevice()

This adds RemoveDevice() to ControllerInterface, fixes ExpressionParser
and some other code to support device removals without crashing,
and adds an IsValid() method to Device, to prepare for hotplugging.
This commit is contained in:
Léo Lam committed 2016-07-29 17:18:37 +02:00
1 parent 0d783f0869
commit 93f5df4195
13 files changed
+69 -19

No files matched your search

@@ -160,6 +160,14 @@ void ControllerInterface::AddDevice(std::shared_ptr<ciface::Core::Device> device
m_devices.emplace_back(std::move(device));
}
void ControllerInterface::RemoveDevice(std::function<bool(const ciface::Core::Device*)> callback)
{
std::lock_guard<std::mutex> lk(m_devices_mutex);
m_devices.erase(std::remove_if(m_devices.begin(), m_devices.end(),
[&callback](const auto& dev) { return callback(dev.get()); }),
m_devices.end());
}
//
// UpdateInput
//