blob: 235f038afac7ae03186a6b023e210e81e9dab4c7 [file] [log] [blame]
Patrick Venture863b9242018-03-08 08:29:23 -08001#pragma once
2
Patrick Ventureda4a5dd2018-08-31 09:42:48 -07003#include "interfaces.hpp"
James Feist0c8223b2019-05-08 15:33:33 -07004#include "util.hpp"
Patrick Ventureda4a5dd2018-08-31 09:42:48 -07005
Patrick Venture863b9242018-03-08 08:29:23 -08006#include <memory>
Patrick Venture0df7c0f2018-06-13 09:02:13 -07007#include <sdbusplus/bus.hpp>
Patrick Venture863b9242018-03-08 08:29:23 -08008#include <string>
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 */
Patrick Ventureda4a5dd2018-08-31 09:42:48 -070014class DbusActiveRead : public ReadInterface
Patrick Venture863b9242018-03-08 08:29:23 -080015{
Patrick Ventureda4a5dd2018-08-31 09:42:48 -070016 public:
17 DbusActiveRead(sdbusplus::bus::bus& bus, const std::string& path,
18 const std::string& service, DbusHelperInterface* helper) :
19 ReadInterface(),
20 _bus(bus), _path(path), _service(service), _helper(helper)
21 {
22 }
Patrick Venture863b9242018-03-08 08:29:23 -080023
Patrick Ventureda4a5dd2018-08-31 09:42:48 -070024 ReadReturn read(void) override;
Patrick Venture863b9242018-03-08 08:29:23 -080025
Patrick Ventureda4a5dd2018-08-31 09:42:48 -070026 private:
27 sdbusplus::bus::bus& _bus;
28 const std::string _path;
29 const std::string _service; // the sensor service.
30 DbusHelperInterface* _helper;
Patrick Venture863b9242018-03-08 08:29:23 -080031};