xref: /openbmc/phosphor-networkd/src/system_configuration.hpp (revision b03a760fa265a2f583719d542a617de3e5dfe3e2)
1 #pragma once
2 
3 #include <sdbusplus/bus.hpp>
4 #include <sdbusplus/bus/match.hpp>
5 #include <sdbusplus/server/object.hpp>
6 #include <stdplus/pinned.hpp>
7 #include <stdplus/zstring.hpp>
8 #include <string>
9 #include <xyz/openbmc_project/Network/SystemConfiguration/server.hpp>
10 
11 namespace phosphor
12 {
13 namespace network
14 {
15 
16 using SystemConfigIntf =
17     sdbusplus::xyz::openbmc_project::Network::server::SystemConfiguration;
18 
19 using Iface = sdbusplus::server::object_t<SystemConfigIntf>;
20 
21 class Manager; // forward declaration of network manager.
22 
23 /** @class SystemConfiguration
24  *  @brief Network system configuration.
25  *  @details A concrete implementation for the
26  *  xyz.openbmc_project.Network.SystemConfiguration DBus API.
27  */
28 class SystemConfiguration : public Iface
29 {
30   public:
31     SystemConfiguration(SystemConfiguration&&) = delete;
32     SystemConfiguration& operator=(SystemConfiguration&&) = delete;
33 
34     /** @brief Constructor to put object onto bus at a dbus path.
35      *  @param[in] bus - Bus to attach to.
36      *  @param[in] objPath - Path to attach at.
37      *  @param[in] parent - Parent object.
38      */
39     SystemConfiguration(stdplus::PinnedRef<sdbusplus::bus_t> bus,
40                         stdplus::const_zstring objPath);
41 
42     /** @brief set the hostname of the system.
43      *  @param[in] name - host name of the system.
44      */
45     std::string hostName(std::string name) override;
46 
47   private:
48     /** @brief Persistent sdbusplus DBus bus connection. */
49     stdplus::PinnedRef<sdbusplus::bus_t> bus;
50 
51     /** @brief Monitor for hostname changes */
52     sdbusplus::bus::match_t hostnamePropMatch;
53 };
54 
55 } // namespace network
56 } // namespace phosphor
57