1 #pragma once
2 
3 #include "types.hpp"
4 
5 constexpr const char* XYZ_ASSOCIATION_INTERFACE =
6     "xyz.openbmc_project.Association";
7 
8 /** @brief Remove input association
9  *
10  * @param[in] sourcePath          - Path of the object that contains the
11  *                                  org.openbmc.Associations
12  * @param[in] owner               - The Dbus service having its associations
13  *                                  removed
14  * @param[in,out] server          - sdbus system object
15  * @param[in,out] assocMaps       - The association maps
16  *
17  * @return Void, server, assocMaps updated if needed
18  */
19 void removeAssociation(const std::string& sourcePath, const std::string& owner,
20                        sdbusplus::asio::object_server& server,
21                        AssociationMaps& assocMaps);
22 
23 /** @brief Remove input paths from endpoints of an association
24  *
25  * If the last endpoint was removed, then remove the whole
26  * association object, otherwise just set the property
27  *
28  * @param[in] objectServer        - sdbus system object
29  * @param[in] assocPath           - Path of the object that contains the
30  *                                  org.openbmc.Associations
31  * @param[in] endpointsToRemove   - Endpoints to remove
32  * @param[in,out] assocMaps       - The association maps
33  *
34  * @return Void, objectServer and assocMaps updated if needed
35  */
36 void removeAssociationEndpoints(
37     sdbusplus::asio::object_server& objectServer, const std::string& assocPath,
38     const boost::container::flat_set<std::string>& endpointsToRemove,
39     AssociationMaps& assocMaps);
40 
41 /** @brief Check and remove any changed associations
42  *
43  * Based on the latest values of the org.openbmc.Associations.associations
44  * property, passed in via the newAssociations param, check if any of the
45  * paths in the xyz.openbmc_project.Association.endpoints D-Bus property
46  * for that association need to be removed.  If the last path is removed
47  * from the endpoints property, remove that whole association object from
48  * D-Bus.
49  *
50  * @param[in] sourcePath         - Path of the object that contains the
51  *                                 org.openbmc.Associations
52  * @param[in] owner              - The Dbus service having it's associatons
53  *                                 changed
54  * @param[in] newAssociations    - New associations to look at for change
55  * @param[in,out] objectServer   - sdbus system object
56  * @param[in,out] assocMaps      - The association maps
57  *
58  * @return Void, objectServer and assocMaps updated if needed
59  */
60 void checkAssociationEndpointRemoves(
61     const std::string& sourcePath, const std::string& owner,
62     const AssociationPaths& newAssociations,
63     sdbusplus::asio::object_server& objectServer, AssociationMaps& assocMaps);
64 
65 /** @brief Handle new or changed association interfaces
66  *
67  * Called when either a new org.openbmc.Associations interface was
68  * created, or the associations property on that interface changed
69  *
70  * @param[in,out] objectServer    - sdbus system object
71  * @param[in] associations        - New associations to look at for change
72  * @param[in] path                - Path of the object that contains the
73  *                                  org.openbmc.Associations
74  * @param[in] owner               - The Dbus service having it's associatons
75  *                                  changed
76  * @param[in,out] assocMaps       - The association maps
77  *
78  * @return Void, objectServer and assocMaps updated if needed
79  */
80 void associationChanged(sdbusplus::asio::object_server& objectServer,
81                         const std::vector<Association>& associations,
82                         const std::string& path, const std::string& owner,
83                         AssociationMaps& assocMaps);
84