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