Matt Spinler | 852db67 | 2019-03-06 13:46:14 -0600 | [diff] [blame^] | 1 | #pragma once |
| 2 | |
| 3 | #include "config.h" |
| 4 | |
| 5 | #include <sdbusplus/bus.hpp> |
| 6 | |
| 7 | namespace phosphor |
| 8 | { |
| 9 | namespace inventory |
| 10 | { |
| 11 | namespace manager |
| 12 | { |
| 13 | namespace associations |
| 14 | { |
| 15 | |
| 16 | /** |
| 17 | * @class Manager |
| 18 | * |
| 19 | * @brief This class provides the ability to add org.openbmc.Associations |
| 20 | * interfaces on inventory D-Bus objects, based on a definition in a |
| 21 | * JSON file. |
| 22 | * |
| 23 | * The purpose for this is to be able to associate other D-Bus paths |
| 24 | * with the inventory items they relate to. |
| 25 | * |
| 26 | * For example, a card temperature sensor D-Bus object can be associated |
| 27 | * with the D-Bus object for that card's inventory entry so that some |
| 28 | * code can tie them together. |
| 29 | */ |
| 30 | class Manager |
| 31 | { |
| 32 | public: |
| 33 | Manager() = delete; |
| 34 | ~Manager() = default; |
| 35 | Manager(const Manager&) = delete; |
| 36 | Manager& operator=(const Manager&) = delete; |
| 37 | Manager(Manager&&) = delete; |
| 38 | Manager& operator=(Manager&&) = delete; |
| 39 | |
| 40 | /** |
| 41 | * @brief Constructor |
| 42 | * |
| 43 | * @param[in] bus - sdbusplus object |
| 44 | * @param[in] jsonPath - path to the JSON File that contains associations |
| 45 | */ |
| 46 | Manager(sdbusplus::bus::bus& bus, const std::string& jsonPath); |
| 47 | |
| 48 | /** |
| 49 | * @brief Constructor |
| 50 | * |
| 51 | * @param[in] bus - sdbusplus object |
| 52 | */ |
| 53 | explicit Manager(sdbusplus::bus::bus& bus) : |
| 54 | Manager(bus, ASSOCIATIONS_FILE_PATH) |
| 55 | { |
| 56 | } |
| 57 | |
| 58 | /** |
| 59 | * @brief Creates any association D-Bus interfaces required based on |
| 60 | * the JSON associations definition for the object path passed |
| 61 | * in. |
| 62 | * |
| 63 | * Called after PIM creates a new inventory D-Bus interface on objectPath. |
| 64 | * |
| 65 | * @param[in] objectPath - the D-Bus object path to check for associations |
| 66 | */ |
| 67 | void createAssociations(const std::string& objectPath); |
| 68 | |
| 69 | private: |
| 70 | /** |
| 71 | * @brief The sdbusplus bus object. |
| 72 | */ |
| 73 | sdbusplus::bus::bus& _bus; |
| 74 | |
| 75 | /** |
| 76 | * @brief The path to the associations JSON File. |
| 77 | */ |
| 78 | const std::string _jsonFile; |
| 79 | }; |
| 80 | |
| 81 | } // namespace associations |
| 82 | } // namespace manager |
| 83 | } // namespace inventory |
| 84 | } // namespace phosphor |