Implemented sensor class
Sensor class was introduced, it monitors
xyz.openbmc_project.Sensor.Value, for change and notifies all
listeners.
Tested:
- Unit tested with service stub that provides dbus interface
xyz.openbmc_project.Sensor.Value
- All changes are delivered to listeners
- All other unit tests are passing
Change-Id: I8c9d58cc986c1fe2a4d2386815d559814016efa6
Signed-off-by: Krzysztof Grobelny <krzysztof.grobelny@intel.com>
diff --git a/src/interfaces/sensor.hpp b/src/interfaces/sensor.hpp
index dbeb158..07c7897 100644
--- a/src/interfaces/sensor.hpp
+++ b/src/interfaces/sensor.hpp
@@ -1,5 +1,7 @@
#pragma once
+#include <chrono>
+#include <memory>
#include <ostream>
#include <string>
#include <string_view>
@@ -8,6 +10,8 @@
namespace interfaces
{
+class SensorListener;
+
class Sensor
{
public:
@@ -28,11 +32,17 @@
return std::tie(type, service, path) <
std::tie(other.type, other.service, other.path);
}
+
+ inline std::string str() const
+ {
+ return type + ":" + service + ":" + path;
+ }
};
virtual ~Sensor() = default;
virtual Id id() const = 0;
+ virtual void registerForUpdates(const std::weak_ptr<SensorListener>&) = 0;
};
} // namespace interfaces