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