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> 8 #include <tuple> 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 19 // map[interface path: tuple[dbus_interface,vector[endpoint paths]]] 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); 61 62 /** @brief Remove input paths from endpoints of an association 63 * 64 * If the last endpoint was removed, then remove the whole 65 * association object, otherwise just set the property 66 * 67 * @param[in] objectServer - sdbus system object 68 * @param[in] assocPath - Path of the object that contains the 69 * org.openbmc.Associations 70 * @param[in] endpointsToRemove - Endpoints to remove 71 * @param[in,out] assocInterfaces - Associations endpoints 72 * 73 * @return Void, objectServer and assocInterfaces updated if needed 74 */ 75 void removeAssociationEndpoints( 76 sdbusplus::asio::object_server& objectServer, const std::string& assocPath, 77 const boost::container::flat_set<std::string>& endpointsToRemove, 78 AssociationInterfaces& assocInterfaces); 79