blob: 392dd8a19683879a173753d6a59ff8e7f4d7f554 [file] [log] [blame]
Matt Spinlere0017eb2018-03-27 11:17:38 -05001#pragma once
2
3#include <map>
4#include <sdbusplus/server.hpp>
5#include <string>
6#include <vector>
7
8namespace ibm
9{
10namespace logging
11{
12
13using DbusInterface = std::string;
14using DbusProperty = std::string;
Matt Spinlerd82a6dd2018-05-23 11:31:22 -050015using DbusService = std::string;
16using DbusPath = std::string;
Matt Spinler259e7272018-03-29 10:57:17 -050017using Value = sdbusplus::message::variant<bool, uint32_t, uint64_t, std::string,
Matt Spinlere0017eb2018-03-27 11:17:38 -050018 std::vector<std::string>>;
19
20using DbusPropertyMap = std::map<DbusProperty, Value>;
21using DbusInterfaceMap = std::map<DbusInterface, DbusPropertyMap>;
22using DbusInterfaceList = std::vector<DbusInterface>;
23
Matt Spinlerbc997492018-03-27 11:24:45 -050024using ObjectValueTree =
25 std::map<sdbusplus::message::object_path, DbusInterfaceMap>;
26
Matt Spinlerd82a6dd2018-05-23 11:31:22 -050027using DbusSubtree =
28 std::map<DbusPath, std::map<DbusService, DbusInterfaceList>>;
29
Matt Spinler32219be2018-05-23 11:29:41 -050030/**
31 * Returns the managed objects for an object path and service
32 *
33 * Returns an empty map if there are any failures.
34 *
35 * @param[in] bus - the D-Bus object
36 * @param[in] service - the D-Bus service name
37 * @param[in] objPath - the D-Bus object path
38 *
39 * @return ObjectValueTree - A map of object paths to their
40 * interfaces and properties.
41 */
Matt Spinler259e7272018-03-29 10:57:17 -050042ObjectValueTree getManagedObjects(sdbusplus::bus::bus& bus,
43 const std::string& service,
44 const std::string& objPath);
Matt Spinlerd82a6dd2018-05-23 11:31:22 -050045
46/**
47 * Returns the subtree for a root, depth, and interface.
48 *
49 * Returns an empty map if there are any failures.
50 *
51 * @param[in] bus - the D-Bus object
52 * @param[in] root - the point from which to provide results
53 * @param[in] depth - the number of path elements to descend
54 *
55 * @return DbusSubtree - A map of object paths to their
56 * services and interfaces.
57 */
58DbusSubtree getSubtree(sdbusplus::bus::bus& bus, const std::string& root,
59 size_t depth, const std::string& interface);
60
61/**
62 * Get the D-Bus service name for the object path and interface from
63 * the data returned from a GetSubTree call.
64 *
65 * Returns an empty string if the service can't be found.
66 *
67 * @param[in] objPath - the D-Bus object path
68 * @param[in] interface - the D-Bus interface name
69 * @param[in] tree - the D-Bus GetSubTree response
70 *
71 * @return string - the service name
72 */
73DbusService getService(const std::string& objPath, const std::string& interface,
74 const DbusSubtree& tree);
75
76/**
77 * Returns all properties on a particular interface on a
78 * particular D-Bus object.
79 *
80 * Returns an empty map if there are any failures.
81 *
82 * @param[in] bus - the D-Bus object
83 * @param[in] service - the D-Bus service name
84 * @param[in] objPath - the D-Bus object path
85 * @param[in] interface - the D-Bus interface name
86 *
87 * @return DbusPropertyMap - The map of property names to values
88 */
89DbusPropertyMap getAllProperties(sdbusplus::bus::bus& bus,
90 const std::string& service,
91 const std::string& objPath,
92 const std::string& interface);
Matt Spinlere0017eb2018-03-27 11:17:38 -050093}
94}