blob: 6f4abe0c8d0d6c3cf68567e7469686c4f35efaf3 [file] [log] [blame]
Matthew Barth37d73ec2020-03-30 16:10:39 -05001#pragma once
2
3#include <systemd/sd-bus.h>
4
5#include <sdbusplus/sdbus.hpp>
6#include <sdbusplus/server/interface.hpp>
7#include <sdbusplus/vtable.hpp>
8
9#include <string>
10
11namespace phosphor
12{
13namespace power
14{
15namespace regulators
16{
17namespace interface
18{
19
20class ManagerInterface
21{
22 public:
23 /* Define all of the basic class operations:
24 * Not allowed:
25 * - Default constructor to avoid nullptrs.
26 * - Copy operations due to internal unique_ptr.
27 * - Move operations due to 'this' being registered as the
28 * 'context' with sdbus.
29 * Allowed:
30 * - Destructor.
31 */
32 ManagerInterface() = delete;
33 ManagerInterface(const ManagerInterface&) = delete;
34 ManagerInterface& operator=(const ManagerInterface&) = delete;
35 ManagerInterface(ManagerInterface&&) = delete;
36 ManagerInterface& operator=(ManagerInterface&&) = delete;
37 virtual ~ManagerInterface() = default;
38
39 /**
40 * @brief Constructor to put object onto bus at a dbus path.
41 * @param[in] bus - Bus to attach to.
42 * @param[in] path - Path to attach at.
43 */
Patrick Williams7354ce62022-07-22 19:26:56 -050044 ManagerInterface(sdbusplus::bus_t& bus, const char* path);
Matthew Barth37d73ec2020-03-30 16:10:39 -050045
46 /**
47 * @brief Implementation for the configure method
48 * Request to configure the regulators according to the
49 * machine's regulators configuration file.
50 */
51 virtual void configure() = 0;
52
53 /**
54 * @brief Implementation for the monitor method
55 * Begin to monitor the regulators according to the
56 * machine's regulators configuration file.
57 *
58 * @param[in] enable - Enable or disable monitoring of the regulators.
59 */
60 virtual void monitor(bool enable) = 0;
61
62 /**
63 * @brief This dbus interface's name
64 */
65 static constexpr auto interface =
66 "xyz.openbmc_project.Power.Regulators.Manager";
67
68 private:
69 /**
70 * @brief Systemd bus callback for the configure method
71 */
72 static int callbackConfigure(sd_bus_message* msg, void* context,
73 sd_bus_error* error);
74
75 /**
76 * @brief Systemd bus callback for the monitor method
77 */
78 static int callbackMonitor(sd_bus_message* msg, void* context,
79 sd_bus_error* error);
80
81 /**
82 * @brief Systemd vtable structure that contains all the
83 * methods, signals, and properties of this interface with their
84 * respective systemd attributes
85 */
86 static const sdbusplus::vtable::vtable_t _vtable[];
87
88 /**
89 * @brief Holder for the instance of this interface to be
90 * on dbus
91 */
92 sdbusplus::server::interface::interface _serverInterface;
93};
94
95} // namespace interface
96} // namespace regulators
97} // namespace power
98} // namespace phosphor