diff --git a/smocore/deviceManager/deviceManager.cpp b/smocore/deviceManager/deviceManager.cpp index b4100be..92c4530 100644 --- a/smocore/deviceManager/deviceManager.cpp +++ b/smocore/deviceManager/deviceManager.cpp @@ -584,6 +584,38 @@ void DeviceManager::attachAllUnattachedDevicesFromCmdlineReq( attachAllUnattachedDevicesFromReq(specs, std::move(cb)); } +void DeviceManager::attachAllUnattachedDevicesFromKnownListReq( + Callback cb + ) +{ + // Create a vector to hold unattached device specs + auto unattachedSpecs = std::make_shared>(); + + // Cycle through all DA specs in deviceAttachmentSpecs + for (const auto& spec : deviceAttachmentSpecs) + { + bool isAttached = false; + + // Cross reference with attachedDeviceRoles + for (const auto& role : attachedDeviceRoles) + { + if (*role->deviceAttachmentSpec == *spec) + { + isAttached = true; + break; + } + } + + // If spec doesn't appear in attachedDeviceRoles, add it to the vector + if (!isAttached) { + unattachedSpecs->push_back(*spec); + } + } + + // Pass the vector to the existing function + attachAllUnattachedDevicesFromReq(unattachedSpecs, std::move(cb)); +} + class DeviceManager::DetachAllAttachedDeviceRoles : public PostedAsynchronousContinuation< detachAllAttachedDeviceRolesCbFn> diff --git a/smocore/include/deviceManager/deviceManager.h b/smocore/include/deviceManager/deviceManager.h index ae80260..18f7db5 100644 --- a/smocore/include/deviceManager/deviceManager.h +++ b/smocore/include/deviceManager/deviceManager.h @@ -73,6 +73,8 @@ public: void attachAllUnattachedDevicesFromReq( const std::shared_ptr> &specs, Callback cb); + void attachAllUnattachedDevicesFromKnownListReq( + Callback cb); void attachAllUnattachedDevicesFromCmdlineReq( Callback cb); void detachAllAttachedDeviceRoles(