blob: 59b59842a85e6ae7a68cabcbad8488250d082262 [file] [log] [blame]
Deepak Kodihalli5f031f32017-07-26 08:25:59 -05001#pragma once
2
Vishwanatha Subbanna1ec291f2017-08-21 17:07:29 +05303#include <sdbusplus/bus.hpp>
Gunnar Mills94df8c92018-09-14 14:50:03 -05004#include <string>
5#include <vector>
Deepak Kodihalli5f031f32017-07-26 08:25:59 -05006
7namespace open_power
8{
9namespace occ
10{
11namespace finder
12{
13
Vishwanatha Subbanna3ace7572017-08-22 16:06:11 +053014// Map of property and interface
15// This is used to filter the OCCs based on the property value
16using Interface = std::string;
17using Property = std::string;
18
19using Value = bool;
20using Match = std::tuple<Interface, Property, Value>;
21using Criteria = std::vector<Match>;
22
Deepak Kodihalli5f031f32017-07-26 08:25:59 -050023/** @brief Get OCC objects on the system by mapping them to CPU inventory
Gunnar Mills94df8c92018-09-14 14:50:03 -050024 * @returns vector of occ objects, such as occ0, occ1, and so on.
25 *
26 * @param[in] bus - sdbusplus handler
27 */
Vishwanatha Subbanna1ec291f2017-08-21 17:07:29 +053028std::vector<std::string> get(sdbusplus::bus::bus& bus);
Deepak Kodihalli5f031f32017-07-26 08:25:59 -050029
Vishwanatha Subbanna3ace7572017-08-22 16:06:11 +053030/** @brief Returns true if the inventory item matches the criteria
31 *
32 * @param[in] bus - sdbusplus handler
33 * @param[in] path - D-Bus path
34 * @param[in] service - D-Bus service name
35 * @param[in] match - Criteria match vector
36 *
37 * @return true on match, false otherwise
38 */
Gunnar Mills94df8c92018-09-14 14:50:03 -050039bool matchCriteria(sdbusplus::bus::bus& bus, const std::string& path,
40 const std::string& service, const Criteria& match);
Vishwanatha Subbanna3ace7572017-08-22 16:06:11 +053041
42/** @brief Gets the value associated with the given object
43 * and the interface.
44 *
45 * @param[in] bus - sdbusplus handler
46 * @param[in] service - D-Bus service name.
47 * @param[in] objPath - D-Bus object path.
48 * @param[in] interface - D-Bus interface.
49 * @param[in] property - Name of the property.
50 *
51 * @return Value of the property
52 */
53
54template <typename T>
Gunnar Mills94df8c92018-09-14 14:50:03 -050055T getDbusProperty(sdbusplus::bus::bus& bus, const std::string& service,
56 const std::string& objPath, const std::string& interface,
Vishwanatha Subbanna3ace7572017-08-22 16:06:11 +053057 const std::string& property);
58
Deepak Kodihalli5f031f32017-07-26 08:25:59 -050059} // namespace finder
60} // namespace occ
61} // namespace open_power