1 #pragma once
2 
3 #include "dbushelper_interface.hpp"
4 #include "interfaces.hpp"
5 #include "util.hpp"
6 
7 #include <sdbusplus/bus.hpp>
8 
9 #include <memory>
10 #include <string>
11 
12 namespace pid_control
13 {
14 
15 /*
16  * This ReadInterface will actively reach out over dbus upon calling read to
17  * get the value from whomever owns the associated dbus path.
18  */
19 class DbusActiveRead : public ReadInterface
20 {
21   public:
22     DbusActiveRead(sdbusplus::bus_t& bus, const std::string& path,
23                    const std::string& service,
24                    std::unique_ptr<DbusHelperInterface> helper) :
25         ReadInterface(), _bus(bus), _path(path), _service(service),
26         _helper(std::move(helper))
27     {}
28 
29     ReadReturn read(void) override;
30 
31   private:
32     // Inform the compiler that this variable might not be used,
33     // which suppresses the warning "private field '_bus' is not used"
34     [[maybe_unused]] sdbusplus::bus_t& _bus;
35     const std::string _path;
36     const std::string _service; // the sensor service.
37     std::unique_ptr<DbusHelperInterface> _helper;
38 };
39 
40 } // namespace pid_control
41