Review fixes for 'Created metric class'
- Changed metric to_json to dumpConfiguration returning LabeledTuple
- LabeledTuple can be created and assigned directly to json
- LabeledTuple can be readed from json using json.get<LabeledTuple>
- Added PrintTo for LabeledMetricParams, LabeledSensorParams
- Added helper method expectMake to ReportFactoryMock
- sensorPaths are serialized to tuple<service, path> instead of single
field with service and path separated via ':'
- Changed configuration version from 1 to 2
Change-Id: I7c45fb584687172f88fd549a93329264793b0b8e
Signed-off-by: Krzysztof Grobelny <krzysztof.grobelny@intel.com>
diff --git a/src/sensor.cpp b/src/sensor.cpp
index c4973cd..8a6f673 100644
--- a/src/sensor.cpp
+++ b/src/sensor.cpp
@@ -53,6 +53,11 @@
void Sensor::registerForUpdates(
const std::weak_ptr<interfaces::SensorListener>& weakListener)
{
+ listeners.erase(
+ std::remove_if(listeners.begin(), listeners.end(),
+ [](const auto& listener) { return listener.expired(); }),
+ listeners.end());
+
if (auto listener = weakListener.lock())
{
listeners.emplace_back(weakListener);