1 #pragma once
2 
3 #include <optional>
4 #include <sdbusplus/bus.hpp>
5 #include <string>
6 #include <tuple>
7 
8 namespace open_power
9 {
10 namespace occ
11 {
12 namespace utils
13 {
14 
15 constexpr auto MAPPER_BUSNAME = "xyz.openbmc_project.ObjectMapper";
16 constexpr auto MAPPER_OBJ_PATH = "/xyz/openbmc_project/object_mapper";
17 constexpr auto MAPPER_IFACE = "xyz.openbmc_project.ObjectMapper";
18 constexpr auto DBUS_PROPERTY_IFACE = "org.freedesktop.DBus.Properties";
19 
20 // The value of the property(type: variant, contains some basic types)
21 using PropertyValue = std::variant<uint32_t, bool>;
22 
23 /** @brief Get the bus connection. */
24 static auto& getBus()
25 {
26     static auto bus = sdbusplus::bus::new_default();
27     return bus;
28 }
29 
30 /**
31  *  @brief Get service name by the path and interface of the DBus.
32  *
33  *  @param[in] path      -  D-Bus object path
34  *  @param[in] interface -  D-Bus Interface
35  *
36  *  @return std::string  -  the D-Bus service name
37  *
38  */
39 const std::string getService(const std::string& path,
40                              const std::string& interface);
41 
42 /** @brief Get property(type: variant)
43  *
44  *  @param[in] objectPath       -   D-Bus object path
45  *  @param[in] interface        -   D-Bus interface
46  *  @param[in] propertyName     -   D-Bus property name
47  *
48  *  @return The value of the property(type: variant)
49  *
50  *  @throw sdbusplus::exception::SdBusError when it fails
51  */
52 const PropertyValue getProperty(const std::string& objectPath,
53                                 const std::string& interface,
54                                 const std::string& propertyName);
55 
56 } // namespace utils
57 } // namespace occ
58 } // namespace open_power
59