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