NVMeContext: Add the ability to remove NVMeSensors
Sometimes sensors go away, e.g. with drive hot-unplug. Make sure we have
the ability to remove them from the set of monitored sensors.
Change-Id: Ifdd51aebfc1c0be964b98db1bde534f539c3f911
Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
diff --git a/include/NVMeContext.hpp b/include/NVMeContext.hpp
index f7216f1..96157e3 100644
--- a/include/NVMeContext.hpp
+++ b/include/NVMeContext.hpp
@@ -24,6 +24,25 @@
sensors.emplace_back(sensor);
}
+ std::optional<std::shared_ptr<NVMeSensor>>
+ getSensorAtPath(const std::string& path)
+ {
+ for (auto& sensor : sensors)
+ {
+ if (sensor->configurationPath == path)
+ {
+ return sensor;
+ }
+ }
+
+ return std::nullopt;
+ }
+
+ void removeSensor(std::shared_ptr<NVMeSensor> sensor)
+ {
+ sensors.remove(sensor);
+ }
+
virtual void pollNVMeDevices()
{}