blob: 03fb5bebd5432728fc62fdd1711ac8ed40ef84a5 [file] [log] [blame]
Ben Tyner324234b2021-06-28 17:01:17 -05001#pragma once
2
3#include <sdbusplus/bus.hpp>
4
5#include <string>
6#include <variant>
7#include <vector>
8
9namespace util
10{
11
12namespace dbus
13{
14
15using DBusValue = std::variant<std::string, bool, std::vector<uint8_t>,
16 std::vector<std::string>>;
17using DBusProperty = std::string;
18using DBusInterface = std::string;
19using DBusService = std::string;
20using DBusPath = std::string;
21using DBusInterfaceList = std::vector<DBusInterface>;
22using DBusSubTree =
23 std::map<DBusPath, std::map<DBusService, DBusInterfaceList>>;
24
25/**
26 * Find the dbus object path and service that implements the given interface
27 *
28 * @param[in] i_interface Interface to search for
29 * @param[out] o_path Path of dbus object implementing the interface
30 * @param[out] o_service Service implementing the dbus object path
31 * @return non-zero on error
32 */
33int find(const std::string& i_interface, std::string& o_path,
34 std::string& o_service);
35
36/**
37 * Find the dbus service that implements the given dbus object and interface
38 *
39 * @param[in] i_interface Interface that maps to the service
40 * @param[in] i_path Path that maps to the service
41 * @param[out] o_service Service implementing the dbus object and interface
42 * @return non-zer on error
43 */
44int findService(const std::string& i_interface, const std::string& i_path,
45 std::string& o_service);
46
47/**
48 * Read a property from a dbus object interface
49 *
50 * @param[in] i_interface Interface implementing the property
51 * @param[in] i_path Path of the dbus object
52 * @param[in] i_service Service implementing the dbus object and interface
53 * @param[in] i_property Property to read
54 * @return non-zero on error
55 */
56int getProperty(const std::string& i_interface, const std::string& i_path,
57 const std::string& i_service, const std::string& i_property,
58 DBusValue& o_response);
59
60/**
61 * Get the IBM compatible names defined for this system
62 *
63 * @return A vector of strings containing the system names
64 */
65std::vector<std::string> systemNames();
66
67} // namespace dbus
68
69} // namespace util