blob: 9a80e0e1fbf7690a1bae467c57d058bd7687a7ff [file] [log] [blame]
Patrick Venture863b9242018-03-08 08:29:23 -08001#pragma once
2
Patrick Ventureaadb30d2020-08-10 09:17:11 -07003#include "dbushelper_interface.hpp"
Patrick Ventureda4a5dd2018-08-31 09:42:48 -07004#include "interfaces.hpp"
James Feist0c8223b2019-05-08 15:33:33 -07005#include "util.hpp"
Patrick Ventureda4a5dd2018-08-31 09:42:48 -07006
Patrick Venture0df7c0f2018-06-13 09:02:13 -07007#include <sdbusplus/bus.hpp>
Patrick Venturea83a3ec2020-08-04 09:52:05 -07008
9#include <memory>
Patrick Venture863b9242018-03-08 08:29:23 -080010#include <string>
11
Patrick Venturea0764872020-08-08 07:48:43 -070012namespace pid_control
13{
14
Patrick Venture863b9242018-03-08 08:29:23 -080015/*
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 */
Patrick Ventureda4a5dd2018-08-31 09:42:48 -070019class DbusActiveRead : public ReadInterface
Patrick Venture863b9242018-03-08 08:29:23 -080020{
Patrick Ventureda4a5dd2018-08-31 09:42:48 -070021 public:
Patrick Williamsb228bc32022-07-22 19:26:56 -050022 DbusActiveRead(sdbusplus::bus_t& bus, const std::string& path,
Patrick Venture8729eb92020-08-10 10:38:44 -070023 const std::string& service,
24 std::unique_ptr<DbusHelperInterface> helper) :
Patrick Williamsbd63bca2024-08-16 15:21:10 -040025 ReadInterface(), _bus(bus), _path(path), _service(service),
26 _helper(std::move(helper))
Patrick Venturea83a3ec2020-08-04 09:52:05 -070027 {}
Patrick Venture863b9242018-03-08 08:29:23 -080028
Patrick Ventureda4a5dd2018-08-31 09:42:48 -070029 ReadReturn read(void) override;
Patrick Venture863b9242018-03-08 08:29:23 -080030
Patrick Ventureda4a5dd2018-08-31 09:42:48 -070031 private:
Jayanth Othayoth9bfba132024-12-08 08:04:57 -060032 // 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;
Patrick Ventureda4a5dd2018-08-31 09:42:48 -070035 const std::string _path;
36 const std::string _service; // the sensor service.
Patrick Venture8729eb92020-08-10 10:38:44 -070037 std::unique_ptr<DbusHelperInterface> _helper;
Patrick Venture863b9242018-03-08 08:29:23 -080038};
Patrick Venturea0764872020-08-08 07:48:43 -070039
40} // namespace pid_control