blob: 557d468d10f6f769d40a29d1505abbbff222067a [file] [log] [blame]
Deepak Kodihalli5f031f32017-07-26 08:25:59 -05001#pragma once
2
3#include <vector>
4#include <string>
Vishwanatha Subbanna1ec291f2017-08-21 17:07:29 +05305#include <sdbusplus/bus.hpp>
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
24 * @returns vector of occ objects, such as occ0, occ1, and so on.
Vishwanatha Subbanna1ec291f2017-08-21 17:07:29 +053025 *
26 * @param[in] bus - sdbusplus handler
Deepak Kodihalli5f031f32017-07-26 08:25:59 -050027 */
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 */
39bool matchCriteria(sdbusplus::bus::bus& bus,
40 const std::string& path,
41 const std::string& service,
42 const Criteria& match);
43
44/** @brief Gets the value associated with the given object
45 * and the interface.
46 *
47 * @param[in] bus - sdbusplus handler
48 * @param[in] service - D-Bus service name.
49 * @param[in] objPath - D-Bus object path.
50 * @param[in] interface - D-Bus interface.
51 * @param[in] property - Name of the property.
52 *
53 * @return Value of the property
54 */
55
56template <typename T>
57T getDbusProperty(sdbusplus::bus::bus& bus,
58 const std::string& service,
59 const std::string& objPath,
60 const std::string& interface,
61 const std::string& property);
62
Deepak Kodihalli5f031f32017-07-26 08:25:59 -050063} // namespace finder
64} // namespace occ
65} // namespace open_power