blob: 8ebef433124ca6446f8b1c6fe42c4c5c2db8f38a [file] [log] [blame]
Andrew Geisslera80a3af2019-02-04 14:01:49 -06001#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 Geissler271b7dd2019-02-05 11:23:30 -06008#include <tuple>
Andrew Geisslera80a3af2019-02-04 14:01:49 -06009#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
15static constexpr auto ifacePos = 0;
16static constexpr auto endpointsPos = 1;
17using Endpoints = std::vector<std::string>;
18
Andrew Geissler271b7dd2019-02-05 11:23:30 -060019// map[interface path: tuple[dbus_interface,vector[endpoint paths]]]
Andrew Geisslera80a3af2019-02-04 14:01:49 -060020using 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
38using AssociationPaths =
39 boost::container::flat_map<std::string,
40 boost::container::flat_set<std::string>>;
41
42using 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 */
57void removeAssociation(const std::string& sourcePath, const std::string& owner,
58 sdbusplus::asio::object_server& server,
59 AssociationOwnersType& assocOwners,
60 AssociationInterfaces& assocInterfaces);