1 #pragma once 2 3 #include <boost/container/flat_map.hpp> 4 #include <boost/container/flat_set.hpp> 5 #include <sdbusplus/asio/object_server.hpp> 6 7 #include <memory> 8 #include <string> 9 #include <tuple> 10 #include <vector> 11 12 /** @brief interface_map_type is the underlying datastructure the mapper uses. 13 * 14 * The 3 levels of map are 15 * object paths 16 * connection names 17 * interface names 18 */ 19 using interface_map_type = boost::container::flat_map< 20 std::string, boost::container::flat_map< 21 std::string, boost::container::flat_set<std::string>>>; 22 23 /** 24 * Associations and some metadata are stored in associationInterfaces. 25 * The fields are: 26 * * ifacePos - holds the D-Bus interface object 27 * * endpointsPos - holds the endpoints array that shadows the property 28 */ 29 static constexpr auto ifacePos = 0; 30 static constexpr auto endpointsPos = 1; 31 using Endpoints = std::vector<std::string>; 32 33 // map[interface path: tuple[dbus_interface,vector[endpoint paths]]] 34 using AssociationInterfaces = boost::container::flat_map< 35 std::string, 36 std::tuple<std::shared_ptr<sdbusplus::asio::dbus_interface>, Endpoints>>; 37 38 /** 39 * The associationOwners map contains information about creators of 40 * associations, so that when a org.openbmc.Association interface is 41 * removed or its 'associations' property is changed, the mapper owned 42 * association objects can be correctly handled. It is a map of the 43 * object path of the org.openbmc.Association owner to a map of the 44 * service the path is owned by, to a map of the association objects to 45 * their endpoint paths: 46 * map[ownerPath : map[service : map[assocPath : [endpoint paths]]] 47 * For example: 48 * [/logging/entry/1 : 49 * [xyz.openbmc_project.Logging : 50 * [/logging/entry/1/callout : [/system/cpu0], 51 * /system/cpu0/fault : [/logging/entry/1]]]] 52 */ 53 using AssociationPaths = 54 boost::container::flat_map<std::string, 55 boost::container::flat_set<std::string>>; 56 57 using AssociationOwnersType = boost::container::flat_map< 58 std::string, boost::container::flat_map<std::string, AssociationPaths>>; 59 60 /** 61 * Store the contents of the associations property on the interface 62 * For example: 63 * ["inventory", "activation", "/xyz/openbmc_project/inventory/system/chassis"] 64 */ 65 constexpr auto forwardTypePos = 0; 66 constexpr auto reverseTypePos = 1; 67 constexpr auto reversePathPos = 2; 68 using Association = std::tuple<std::string, std::string, std::string>; 69 70 /** 71 * PendingAssociations tracks associations that cannot be created because 72 * the endpoint (the last element of the Association tuple) doesn't exist. 73 * When that endpoint shows up on D-Bus, both association paths can then 74 * be created. Also, if a valid association has an endpoint removed from 75 * D-Bus, then a new PendingAssociations entry will be created until it 76 * reappears. It has all of the information it needs to recreate the 77 * association. 78 */ 79 constexpr auto ownerPos = 0; 80 constexpr auto assocPos = 1; 81 using ExistingEndpoint = std::tuple<std::string, Association>; 82 using ExistingEndpoints = std::vector<ExistingEndpoint>; 83 using PendingAssociations = std::map<std::string, ExistingEndpoints>; 84 85 /** 86 * The return type of findAssociations(). 87 * The string in the tuple is the association owner. 88 */ 89 using FindAssocResults = std::vector<std::tuple<std::string, Association>>; 90 91 /** 92 * Keeps all association related maps together. 93 */ 94 struct AssociationMaps 95 { 96 AssociationInterfaces ifaces; 97 AssociationOwnersType owners; 98 PendingAssociations pending; 99 }; 100