1a80a3af0SAndrew Geissler #pragma once
2a80a3af0SAndrew Geissler 
335396c10SMatt Spinler #include "types.hpp"
4a80a3af0SAndrew Geissler 
54511b33fSAndrew Geissler constexpr const char* XYZ_ASSOCIATION_INTERFACE =
64511b33fSAndrew Geissler     "xyz.openbmc_project.Association";
74511b33fSAndrew Geissler 
8a80a3af0SAndrew Geissler /** @brief Remove input association
9a80a3af0SAndrew Geissler  *
10a80a3af0SAndrew Geissler  * @param[in] sourcePath          - Path of the object that contains the
11a80a3af0SAndrew Geissler  *                                  org.openbmc.Associations
12a80a3af0SAndrew Geissler  * @param[in] owner               - The Dbus service having its associations
13a80a3af0SAndrew Geissler  *                                  removed
14a80a3af0SAndrew Geissler  * @param[in,out] server          - sdbus system object
15*e2359fb7SMatt Spinler  * @param[in,out] assocMaps       - The association maps
16a80a3af0SAndrew Geissler  *
17*e2359fb7SMatt Spinler  * @return Void, server, assocMaps updated if needed
18a80a3af0SAndrew Geissler  */
19a80a3af0SAndrew Geissler void removeAssociation(const std::string& sourcePath, const std::string& owner,
20a80a3af0SAndrew Geissler                        sdbusplus::asio::object_server& server,
21*e2359fb7SMatt Spinler                        AssociationMaps& assocMaps);
22ff5ce924SAndrew Geissler 
23ff5ce924SAndrew Geissler /** @brief Remove input paths from endpoints of an association
24ff5ce924SAndrew Geissler  *
25ff5ce924SAndrew Geissler  * If the last endpoint was removed, then remove the whole
26ff5ce924SAndrew Geissler  * association object, otherwise just set the property
27ff5ce924SAndrew Geissler  *
28ff5ce924SAndrew Geissler  * @param[in] objectServer        - sdbus system object
29ff5ce924SAndrew Geissler  * @param[in] assocPath           - Path of the object that contains the
30ff5ce924SAndrew Geissler  *                                  org.openbmc.Associations
31ff5ce924SAndrew Geissler  * @param[in] endpointsToRemove   - Endpoints to remove
32*e2359fb7SMatt Spinler  * @param[in,out] assocMaps       - The association maps
33ff5ce924SAndrew Geissler  *
34*e2359fb7SMatt Spinler  * @return Void, objectServer and assocMaps updated if needed
35ff5ce924SAndrew Geissler  */
36ff5ce924SAndrew Geissler void removeAssociationEndpoints(
37ff5ce924SAndrew Geissler     sdbusplus::asio::object_server& objectServer, const std::string& assocPath,
38ff5ce924SAndrew Geissler     const boost::container::flat_set<std::string>& endpointsToRemove,
39*e2359fb7SMatt Spinler     AssociationMaps& assocMaps);
407f1c44dcSAndrew Geissler 
417f1c44dcSAndrew Geissler /** @brief Check and remove any changed associations
427f1c44dcSAndrew Geissler  *
437f1c44dcSAndrew Geissler  * Based on the latest values of the org.openbmc.Associations.associations
447f1c44dcSAndrew Geissler  * property, passed in via the newAssociations param, check if any of the
457f1c44dcSAndrew Geissler  * paths in the xyz.openbmc_project.Association.endpoints D-Bus property
467f1c44dcSAndrew Geissler  * for that association need to be removed.  If the last path is removed
477f1c44dcSAndrew Geissler  * from the endpoints property, remove that whole association object from
487f1c44dcSAndrew Geissler  * D-Bus.
497f1c44dcSAndrew Geissler  *
507f1c44dcSAndrew Geissler  * @param[in] sourcePath         - Path of the object that contains the
517f1c44dcSAndrew Geissler  *                                 org.openbmc.Associations
527f1c44dcSAndrew Geissler  * @param[in] owner              - The Dbus service having it's associatons
537f1c44dcSAndrew Geissler  *                                 changed
547f1c44dcSAndrew Geissler  * @param[in] newAssociations    - New associations to look at for change
557f1c44dcSAndrew Geissler  * @param[in,out] objectServer   - sdbus system object
56*e2359fb7SMatt Spinler  * @param[in,out] assocMaps      - The association maps
577f1c44dcSAndrew Geissler  *
58*e2359fb7SMatt Spinler  * @return Void, objectServer and assocMaps updated if needed
597f1c44dcSAndrew Geissler  */
607f1c44dcSAndrew Geissler void checkAssociationEndpointRemoves(
617f1c44dcSAndrew Geissler     const std::string& sourcePath, const std::string& owner,
627f1c44dcSAndrew Geissler     const AssociationPaths& newAssociations,
63*e2359fb7SMatt Spinler     sdbusplus::asio::object_server& objectServer, AssociationMaps& assocMaps);
644511b33fSAndrew Geissler 
654511b33fSAndrew Geissler /** @brief Handle new or changed association interfaces
664511b33fSAndrew Geissler  *
674511b33fSAndrew Geissler  * Called when either a new org.openbmc.Associations interface was
684511b33fSAndrew Geissler  * created, or the associations property on that interface changed
694511b33fSAndrew Geissler  *
704511b33fSAndrew Geissler  * @param[in,out] objectServer    - sdbus system object
714511b33fSAndrew Geissler  * @param[in] associations        - New associations to look at for change
724511b33fSAndrew Geissler  * @param[in] path                - Path of the object that contains the
734511b33fSAndrew Geissler  *                                  org.openbmc.Associations
744511b33fSAndrew Geissler  * @param[in] owner               - The Dbus service having it's associatons
754511b33fSAndrew Geissler  *                                  changed
76*e2359fb7SMatt Spinler  * @param[in,out] assocMaps       - The association maps
774511b33fSAndrew Geissler  *
78*e2359fb7SMatt Spinler  * @return Void, objectServer and assocMaps updated if needed
794511b33fSAndrew Geissler  */
804511b33fSAndrew Geissler void associationChanged(sdbusplus::asio::object_server& objectServer,
814511b33fSAndrew Geissler                         const std::vector<Association>& associations,
824511b33fSAndrew Geissler                         const std::string& path, const std::string& owner,
83*e2359fb7SMatt Spinler                         AssociationMaps& assocMaps);
84