Andrew Geissler | a80a3af | 2019-02-04 14:01:49 -0600 | [diff] [blame] | 1 | #pragma once |
| 2 | |
| 3 | #include <boost/container/flat_map.hpp> |
| 4 | #include <boost/container/flat_set.hpp> |
| 5 | #include <memory> |
| 6 | #include <sdbusplus/asio/object_server.hpp> |
| 7 | #include <string> |
Andrew Geissler | 271b7dd | 2019-02-05 11:23:30 -0600 | [diff] [blame] | 8 | #include <tuple> |
Andrew Geissler | a80a3af | 2019-02-04 14:01:49 -0600 | [diff] [blame] | 9 | #include <vector> |
| 10 | |
| 11 | // Associations and some metadata are stored in associationInterfaces. |
| 12 | // The fields are: |
| 13 | // * ifacePos - holds the D-Bus interface object |
| 14 | // * endpointsPos - holds the endpoints array that shadows the property |
| 15 | static constexpr auto ifacePos = 0; |
| 16 | static constexpr auto endpointsPos = 1; |
| 17 | using Endpoints = std::vector<std::string>; |
| 18 | |
Andrew Geissler | 271b7dd | 2019-02-05 11:23:30 -0600 | [diff] [blame] | 19 | // map[interface path: tuple[dbus_interface,vector[endpoint paths]]] |
Andrew Geissler | a80a3af | 2019-02-04 14:01:49 -0600 | [diff] [blame] | 20 | using AssociationInterfaces = boost::container::flat_map< |
| 21 | std::string, |
| 22 | std::tuple<std::shared_ptr<sdbusplus::asio::dbus_interface>, Endpoints>>; |
| 23 | |
| 24 | // The associationOwners map contains information about creators of |
| 25 | // associations, so that when a org.openbmc.Association interface is |
| 26 | // removed or its 'associations' property is changed, the mapper owned |
| 27 | // association objects can be correctly handled. It is a map of the |
| 28 | // object path of the org.openbmc.Association owner to a map of the |
| 29 | // service the path is owned by, to a map of the association objects to |
| 30 | // their endpoint paths: |
| 31 | // map[ownerPath : map[service : map[assocPath : [endpoint paths]]] |
| 32 | // For example: |
| 33 | // [/logging/entry/1 : |
| 34 | // [xyz.openbmc_project.Logging : |
| 35 | // [/logging/entry/1/callout : [/system/cpu0], |
| 36 | // /system/cpu0/fault : [/logging/entry/1]]]] |
| 37 | |
| 38 | using AssociationPaths = |
| 39 | boost::container::flat_map<std::string, |
| 40 | boost::container::flat_set<std::string>>; |
| 41 | |
| 42 | using AssociationOwnersType = boost::container::flat_map< |
| 43 | std::string, boost::container::flat_map<std::string, AssociationPaths>>; |
| 44 | |
| 45 | /** @brief Remove input association |
| 46 | * |
| 47 | * @param[in] sourcePath - Path of the object that contains the |
| 48 | * org.openbmc.Associations |
| 49 | * @param[in] owner - The Dbus service having its associations |
| 50 | * removed |
| 51 | * @param[in,out] server - sdbus system object |
| 52 | * @param[in,out] assocOwners - Owners of associations |
| 53 | * @param[in,out] assocInterfaces - Associations endpoints |
| 54 | * |
| 55 | * @return Void, server, assocOwners, and assocInterfaces updated if needed |
| 56 | */ |
| 57 | void removeAssociation(const std::string& sourcePath, const std::string& owner, |
| 58 | sdbusplus::asio::object_server& server, |
| 59 | AssociationOwnersType& assocOwners, |
| 60 | AssociationInterfaces& assocInterfaces); |