1 #pragma once
2 
3 #include <sdbusplus/bus.hpp>
4 #include <xyz/openbmc_project/Control/Boot/RebootPolicy/client.hpp>
5 #include <xyz/openbmc_project/Control/Power/RestorePolicy/client.hpp>
6 
7 #include <string>
8 
9 namespace settings
10 {
11 
12 using Path = std::string;
13 using Service = std::string;
14 using Interface = std::string;
15 
16 constexpr auto defaultRoot = "/";
17 constexpr auto autoRebootIntf = sdbusplus::client::xyz::openbmc_project::
18     control::boot::RebootPolicy<>::interface;
19 constexpr auto powerRestoreIntf = sdbusplus::client::xyz::openbmc_project::
20     control::power::RestorePolicy<>::interface;
21 
22 /** @class Objects
23  *  @brief Fetch paths of settings d-bus objects of interest, upon construction
24  */
25 struct Objects
26 {
27   public:
28     /** @brief Constructor - fetch settings objects
29      *
30      * @param[in] bus  - The Dbus bus object
31      * @param[in] root - The root object path
32      */
33     explicit Objects(sdbusplus::bus_t& bus, const Path& root = defaultRoot);
34     Objects(const Objects&) = delete;
35     Objects& operator=(const Objects&) = delete;
36     Objects(Objects&&) = delete;
37     Objects& operator=(Objects&&) = delete;
38     ~Objects() = default;
39 
40     /** @brief Fetch d-bus service, given a path and an interface. The
41      *         service can't be cached because mapper returns unique
42      *         service names.
43      *
44      * @param[in] path - The Dbus object
45      * @param[in] interface - The Dbus interface
46      *
47      * @return std::string - the dbus service name
48      */
49     Service service(const Path& path, const Interface& interface) const;
50 
51     /** @brief host auto_reboot user settings object */
52     Path autoReboot;
53 
54     /** @brief host auto_reboot one-time settings object */
55     Path autoRebootOneTime;
56 
57     /** @brief host power_restore_policy settings object */
58     Path powerRestorePolicy;
59 
60     /** @brief host power_restore_policy one-time settings object */
61     Path powerRestorePolicyOneTime;
62 
63     /** @brief The Dbus bus object */
64     sdbusplus::bus_t& bus;
65 };
66 
67 /** @class HostObjects
68  *  @brief Fetch paths of settings d-bus objects of Host
69  *  @note  IMPORTANT: This class only supports settings under the
70  *         /xyz/openbmc_project/control/hostX object paths
71  */
72 struct HostObjects : public Objects
73 {
74   public:
75     /** @brief Constructor - fetch settings objects of Host
76      *
77      * @param[in] bus - The Dbus bus object
78      * @param[in] id  - The Host id
79      */
80     HostObjects(sdbusplus::bus_t& bus, size_t id);
81 };
82 
83 } // namespace settings
84