blob: 85380fb7302869edd5297eab4d2e7d71f1ddf2e0 [file] [log] [blame]
Patrick Venture863b9242018-03-08 08:29:23 -08001#pragma once
2
3#include <memory>
Patrick Venture0df7c0f2018-06-13 09:02:13 -07004#include <sdbusplus/bus.hpp>
Patrick Venture863b9242018-03-08 08:29:23 -08005#include <string>
6
Patrick Venture0df7c0f2018-06-13 09:02:13 -07007#include "dbus/util.hpp"
Patrick Venture863b9242018-03-08 08:29:23 -08008#include "interfaces.hpp"
9
Patrick Venture863b9242018-03-08 08:29:23 -080010/*
11 * This ReadInterface will actively reach out over dbus upon calling read to
12 * get the value from whomever owns the associated dbus path.
13 */
14class DbusActiveRead: public ReadInterface
15{
16 public:
17 DbusActiveRead(sdbusplus::bus::bus& bus,
18 const std::string& path,
Patrick Venture0df7c0f2018-06-13 09:02:13 -070019 const std::string& service,
20 DbusHelperInterface *helper)
Patrick Venture863b9242018-03-08 08:29:23 -080021 : ReadInterface(),
22 _bus(bus),
23 _path(path),
Patrick Venture0df7c0f2018-06-13 09:02:13 -070024 _service(service),
25 _helper(helper)
Patrick Venture863b9242018-03-08 08:29:23 -080026 { }
27
28 ReadReturn read(void) override;
29
30 private:
31 sdbusplus::bus::bus& _bus;
32 const std::string _path;
33 const std::string _service; // the sensor service.
Patrick Venture0df7c0f2018-06-13 09:02:13 -070034 DbusHelperInterface *_helper;
Patrick Venture863b9242018-03-08 08:29:23 -080035};