DevMgr: Add attachAllUnattachedDevicesFromKnownListReq
This function is the backbone for the DeviceReattacher daemon. It assembles a list of all DA specs which are known to Mrntt, but which haven't been successfully attached as yet, and attempts to attach them.
This commit is contained in:
@@ -584,6 +584,38 @@ void DeviceManager::attachAllUnattachedDevicesFromCmdlineReq(
|
|||||||
attachAllUnattachedDevicesFromReq(specs, std::move(cb));
|
attachAllUnattachedDevicesFromReq(specs, std::move(cb));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DeviceManager::attachAllUnattachedDevicesFromKnownListReq(
|
||||||
|
Callback<attachAllUnattachedDevicesFromReqCbFn> cb
|
||||||
|
)
|
||||||
|
{
|
||||||
|
// Create a vector to hold unattached device specs
|
||||||
|
auto unattachedSpecs = std::make_shared<std::vector<DeviceAttachmentSpec>>();
|
||||||
|
|
||||||
|
// 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
|
class DeviceManager::DetachAllAttachedDeviceRoles
|
||||||
: public PostedAsynchronousContinuation<
|
: public PostedAsynchronousContinuation<
|
||||||
detachAllAttachedDeviceRolesCbFn>
|
detachAllAttachedDeviceRolesCbFn>
|
||||||
|
|||||||
@@ -73,6 +73,8 @@ public:
|
|||||||
void attachAllUnattachedDevicesFromReq(
|
void attachAllUnattachedDevicesFromReq(
|
||||||
const std::shared_ptr<std::vector<DeviceAttachmentSpec>> &specs,
|
const std::shared_ptr<std::vector<DeviceAttachmentSpec>> &specs,
|
||||||
Callback<attachAllUnattachedDevicesFromReqCbFn> cb);
|
Callback<attachAllUnattachedDevicesFromReqCbFn> cb);
|
||||||
|
void attachAllUnattachedDevicesFromKnownListReq(
|
||||||
|
Callback<attachAllUnattachedDevicesFromReqCbFn> cb);
|
||||||
void attachAllUnattachedDevicesFromCmdlineReq(
|
void attachAllUnattachedDevicesFromCmdlineReq(
|
||||||
Callback<attachAllUnattachedDevicesFromReqCbFn> cb);
|
Callback<attachAllUnattachedDevicesFromReqCbFn> cb);
|
||||||
void detachAllAttachedDeviceRoles(
|
void detachAllAttachedDeviceRoles(
|
||||||
|
|||||||
Reference in New Issue
Block a user