Deepak Kodihalli | 5f031f3 | 2017-07-26 08:25:59 -0500 | [diff] [blame] | 1 | #pragma once |
| 2 | |
Vishwanatha Subbanna | 1ec291f | 2017-08-21 17:07:29 +0530 | [diff] [blame] | 3 | #include <sdbusplus/bus.hpp> |
Gunnar Mills | 94df8c9 | 2018-09-14 14:50:03 -0500 | [diff] [blame] | 4 | #include <string> |
| 5 | #include <vector> |
Deepak Kodihalli | 5f031f3 | 2017-07-26 08:25:59 -0500 | [diff] [blame] | 6 | |
| 7 | namespace open_power |
| 8 | { |
| 9 | namespace occ |
| 10 | { |
| 11 | namespace finder |
| 12 | { |
| 13 | |
Vishwanatha Subbanna | 3ace757 | 2017-08-22 16:06:11 +0530 | [diff] [blame] | 14 | // Map of property and interface |
| 15 | // This is used to filter the OCCs based on the property value |
| 16 | using Interface = std::string; |
| 17 | using Property = std::string; |
| 18 | |
| 19 | using Value = bool; |
| 20 | using Match = std::tuple<Interface, Property, Value>; |
| 21 | using Criteria = std::vector<Match>; |
| 22 | |
Deepak Kodihalli | 5f031f3 | 2017-07-26 08:25:59 -0500 | [diff] [blame] | 23 | /** @brief Get OCC objects on the system by mapping them to CPU inventory |
Gunnar Mills | 94df8c9 | 2018-09-14 14:50:03 -0500 | [diff] [blame] | 24 | * @returns vector of occ objects, such as occ0, occ1, and so on. |
| 25 | * |
| 26 | * @param[in] bus - sdbusplus handler |
| 27 | */ |
Vishwanatha Subbanna | 1ec291f | 2017-08-21 17:07:29 +0530 | [diff] [blame] | 28 | std::vector<std::string> get(sdbusplus::bus::bus& bus); |
Deepak Kodihalli | 5f031f3 | 2017-07-26 08:25:59 -0500 | [diff] [blame] | 29 | |
Vishwanatha Subbanna | 3ace757 | 2017-08-22 16:06:11 +0530 | [diff] [blame] | 30 | /** @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 Mills | 94df8c9 | 2018-09-14 14:50:03 -0500 | [diff] [blame] | 39 | bool matchCriteria(sdbusplus::bus::bus& bus, const std::string& path, |
| 40 | const std::string& service, const Criteria& match); |
Vishwanatha Subbanna | 3ace757 | 2017-08-22 16:06:11 +0530 | [diff] [blame] | 41 | |
| 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 | |
| 54 | template <typename T> |
Gunnar Mills | 94df8c9 | 2018-09-14 14:50:03 -0500 | [diff] [blame] | 55 | T getDbusProperty(sdbusplus::bus::bus& bus, const std::string& service, |
| 56 | const std::string& objPath, const std::string& interface, |
Vishwanatha Subbanna | 3ace757 | 2017-08-22 16:06:11 +0530 | [diff] [blame] | 57 | const std::string& property); |
| 58 | |
Deepak Kodihalli | 5f031f3 | 2017-07-26 08:25:59 -0500 | [diff] [blame] | 59 | } // namespace finder |
| 60 | } // namespace occ |
| 61 | } // namespace open_power |