blob: 37ff9bcb57480f8d31e4a2e29add9c01e99a5fda [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 Venture0df7c0f2018-06-13 09:02:13 -07006#include <sdbusplus/bus.hpp>
Patrick Venturea83a3ec2020-08-04 09:52:05 -07007
8#include <memory>
Patrick Venture863b9242018-03-08 08:29:23 -08009#include <string>
10
Patrick Venture863b9242018-03-08 08:29:23 -080011/*
12 * This ReadInterface will actively reach out over dbus upon calling read to
13 * get the value from whomever owns the associated dbus path.
14 */
Patrick Ventureda4a5dd2018-08-31 09:42:48 -070015class DbusActiveRead : public ReadInterface
Patrick Venture863b9242018-03-08 08:29:23 -080016{
Patrick Ventureda4a5dd2018-08-31 09:42:48 -070017 public:
18 DbusActiveRead(sdbusplus::bus::bus& bus, const std::string& path,
19 const std::string& service, DbusHelperInterface* helper) :
20 ReadInterface(),
21 _bus(bus), _path(path), _service(service), _helper(helper)
Patrick Venturea83a3ec2020-08-04 09:52:05 -070022 {}
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};