diff options
Diffstat (limited to 'src/associations.cpp')
-rw-r--r-- | src/associations.cpp | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/src/associations.cpp b/src/associations.cpp index 3ae7db4..9bb7a34 100644 --- a/src/associations.cpp +++ b/src/associations.cpp @@ -74,3 +74,40 @@ void removeAssociation(const std::string& sourcePath, const std::string& owner, assocOwners.erase(owners); } } + +void removeAssociationEndpoints( + sdbusplus::asio::object_server& objectServer, const std::string& assocPath, + const boost::container::flat_set<std::string>& endpointsToRemove, + AssociationInterfaces& assocInterfaces) +{ + auto assoc = assocInterfaces.find(assocPath); + if (assoc == assocInterfaces.end()) + { + return; + } + + auto& endpointsInDBus = std::get<endpointsPos>(assoc->second); + + for (const auto& endpointToRemove : endpointsToRemove) + { + auto e = std::find(endpointsInDBus.begin(), endpointsInDBus.end(), + endpointToRemove); + + if (e != endpointsInDBus.end()) + { + endpointsInDBus.erase(e); + } + } + + if (endpointsInDBus.empty()) + { + objectServer.remove_interface(std::get<ifacePos>(assoc->second)); + std::get<ifacePos>(assoc->second) = nullptr; + std::get<endpointsPos>(assoc->second).clear(); + } + else + { + std::get<ifacePos>(assoc->second) + ->set_property("endpoints", endpointsInDBus); + } +} |