137d73ec3SMatthew Barth #pragma once
237d73ec3SMatthew Barth 
337d73ec3SMatthew Barth #include <systemd/sd-bus.h>
437d73ec3SMatthew Barth 
537d73ec3SMatthew Barth #include <sdbusplus/sdbus.hpp>
637d73ec3SMatthew Barth #include <sdbusplus/server/interface.hpp>
737d73ec3SMatthew Barth #include <sdbusplus/vtable.hpp>
837d73ec3SMatthew Barth 
937d73ec3SMatthew Barth #include <string>
1037d73ec3SMatthew Barth 
1137d73ec3SMatthew Barth namespace phosphor
1237d73ec3SMatthew Barth {
1337d73ec3SMatthew Barth namespace power
1437d73ec3SMatthew Barth {
1537d73ec3SMatthew Barth namespace regulators
1637d73ec3SMatthew Barth {
1737d73ec3SMatthew Barth namespace interface
1837d73ec3SMatthew Barth {
1937d73ec3SMatthew Barth 
2037d73ec3SMatthew Barth class ManagerInterface
2137d73ec3SMatthew Barth {
2237d73ec3SMatthew Barth   public:
2337d73ec3SMatthew Barth     /* Define all of the basic class operations:
2437d73ec3SMatthew Barth      *     Not allowed:
2537d73ec3SMatthew Barth      *         - Default constructor to avoid nullptrs.
2637d73ec3SMatthew Barth      *         - Copy operations due to internal unique_ptr.
2737d73ec3SMatthew Barth      *         - Move operations due to 'this' being registered as the
2837d73ec3SMatthew Barth      *           'context' with sdbus.
2937d73ec3SMatthew Barth      *     Allowed:
3037d73ec3SMatthew Barth      *         - Destructor.
3137d73ec3SMatthew Barth      */
3237d73ec3SMatthew Barth     ManagerInterface() = delete;
3337d73ec3SMatthew Barth     ManagerInterface(const ManagerInterface&) = delete;
3437d73ec3SMatthew Barth     ManagerInterface& operator=(const ManagerInterface&) = delete;
3537d73ec3SMatthew Barth     ManagerInterface(ManagerInterface&&) = delete;
3637d73ec3SMatthew Barth     ManagerInterface& operator=(ManagerInterface&&) = delete;
3737d73ec3SMatthew Barth     virtual ~ManagerInterface() = default;
3837d73ec3SMatthew Barth 
3937d73ec3SMatthew Barth     /**
4037d73ec3SMatthew Barth      * @brief Constructor to put object onto bus at a dbus path.
4137d73ec3SMatthew Barth      * @param[in] bus - Bus to attach to.
4237d73ec3SMatthew Barth      * @param[in] path - Path to attach at.
4337d73ec3SMatthew Barth      */
44*7354ce62SPatrick Williams     ManagerInterface(sdbusplus::bus_t& bus, const char* path);
4537d73ec3SMatthew Barth 
4637d73ec3SMatthew Barth     /**
4737d73ec3SMatthew Barth      * @brief Implementation for the configure method
4837d73ec3SMatthew Barth      * Request to configure the regulators according to the
4937d73ec3SMatthew Barth      * machine's regulators configuration file.
5037d73ec3SMatthew Barth      */
5137d73ec3SMatthew Barth     virtual void configure() = 0;
5237d73ec3SMatthew Barth 
5337d73ec3SMatthew Barth     /**
5437d73ec3SMatthew Barth      * @brief Implementation for the monitor method
5537d73ec3SMatthew Barth      * Begin to monitor the regulators according to the
5637d73ec3SMatthew Barth      * machine's regulators configuration file.
5737d73ec3SMatthew Barth      *
5837d73ec3SMatthew Barth      * @param[in] enable - Enable or disable monitoring of the regulators.
5937d73ec3SMatthew Barth      */
6037d73ec3SMatthew Barth     virtual void monitor(bool enable) = 0;
6137d73ec3SMatthew Barth 
6237d73ec3SMatthew Barth     /**
6337d73ec3SMatthew Barth      * @brief This dbus interface's name
6437d73ec3SMatthew Barth      */
6537d73ec3SMatthew Barth     static constexpr auto interface =
6637d73ec3SMatthew Barth         "xyz.openbmc_project.Power.Regulators.Manager";
6737d73ec3SMatthew Barth 
6837d73ec3SMatthew Barth   private:
6937d73ec3SMatthew Barth     /**
7037d73ec3SMatthew Barth      * @brief Systemd bus callback for the configure method
7137d73ec3SMatthew Barth      */
7237d73ec3SMatthew Barth     static int callbackConfigure(sd_bus_message* msg, void* context,
7337d73ec3SMatthew Barth                                  sd_bus_error* error);
7437d73ec3SMatthew Barth 
7537d73ec3SMatthew Barth     /**
7637d73ec3SMatthew Barth      * @brief Systemd bus callback for the monitor method
7737d73ec3SMatthew Barth      */
7837d73ec3SMatthew Barth     static int callbackMonitor(sd_bus_message* msg, void* context,
7937d73ec3SMatthew Barth                                sd_bus_error* error);
8037d73ec3SMatthew Barth 
8137d73ec3SMatthew Barth     /**
8237d73ec3SMatthew Barth      * @brief Systemd vtable structure that contains all the
8337d73ec3SMatthew Barth      * methods, signals, and properties of this interface with their
8437d73ec3SMatthew Barth      * respective systemd attributes
8537d73ec3SMatthew Barth      */
8637d73ec3SMatthew Barth     static const sdbusplus::vtable::vtable_t _vtable[];
8737d73ec3SMatthew Barth 
8837d73ec3SMatthew Barth     /**
8937d73ec3SMatthew Barth      * @brief Holder for the instance of this interface to be
9037d73ec3SMatthew Barth      * on dbus
9137d73ec3SMatthew Barth      */
9237d73ec3SMatthew Barth     sdbusplus::server::interface::interface _serverInterface;
9337d73ec3SMatthew Barth };
9437d73ec3SMatthew Barth 
9537d73ec3SMatthew Barth } // namespace interface
9637d73ec3SMatthew Barth } // namespace regulators
9737d73ec3SMatthew Barth } // namespace power
9837d73ec3SMatthew Barth } // namespace phosphor
99