DevMgr: attachAllUnattachedDevsFrom: now takes sh_ptr<vector<Spec>>
This method now accepts a sh_ptr<vector<DeviceAttachmentSpec>> to tell it specifically which specs to attempt to attach. This enables us to implement different frontends that supply it with collections of devices from different sources (GUI, cmdline, previously failed-to-attach/hot-removed devices, etc). SMO temporarily initializes none of the devices from the cmdline during this commit as we transition to implementing the cmdline collection frontend.
This commit is contained in:
@@ -490,11 +490,12 @@ class DeviceManager::AttachAllUnattachedDevicesFromReq
|
||||
public:
|
||||
AttachAllUnattachedDevicesFromReq(
|
||||
const unsigned int totalNSpecs,
|
||||
const std::shared_ptr<std::vector<DeviceAttachmentSpec>>& specs,
|
||||
const std::shared_ptr<ComponentThread>& caller,
|
||||
Callback<attachAllUnattachedDevicesFromReqCbFn> cb)
|
||||
: PostedAsynchronousContinuation<attachAllUnattachedDevicesFromReqCbFn>(
|
||||
caller, cb),
|
||||
loop(totalNSpecs)
|
||||
loop(totalNSpecs), specs(specs)
|
||||
{}
|
||||
|
||||
public:
|
||||
@@ -503,10 +504,10 @@ public:
|
||||
context
|
||||
)
|
||||
{
|
||||
for (const auto& spec : DeviceManager::deviceAttachmentSpecs)
|
||||
for (const auto& spec : *specs)
|
||||
{
|
||||
DeviceManager::getInstance().newDeviceAttachmentSpecInd(
|
||||
*spec,
|
||||
spec,
|
||||
{context, std::bind(
|
||||
&AttachAllUnattachedDevicesFromReq::attachAllUnattachedDevicesFromReq2,
|
||||
context.get(), context,
|
||||
@@ -518,7 +519,7 @@ public:
|
||||
// Callback methods for the attachment sequence
|
||||
void attachAllUnattachedDevicesFromReq2(
|
||||
std::shared_ptr<AttachAllUnattachedDevicesFromReq> context,
|
||||
bool success, std::shared_ptr<DeviceRole> deviceRole,
|
||||
bool success, [[maybe_unused]] std::shared_ptr<DeviceRole> deviceRole,
|
||||
std::shared_ptr<DeviceAttachmentSpec> spec
|
||||
)
|
||||
{
|
||||
@@ -547,13 +548,15 @@ public:
|
||||
|
||||
public:
|
||||
AsynchronousLoop loop;
|
||||
std::shared_ptr<std::vector<DeviceAttachmentSpec>> specs;
|
||||
};
|
||||
|
||||
void DeviceManager::attachAllUnattachedDevicesFromReq(
|
||||
const std::shared_ptr<std::vector<DeviceAttachmentSpec>> &specs,
|
||||
Callback<attachAllUnattachedDevicesFromReqCbFn> cb
|
||||
)
|
||||
{
|
||||
if (DeviceManager::getInstance().deviceAttachmentSpecs.size() == 0)
|
||||
if (specs->size() == 0)
|
||||
{
|
||||
AsynchronousLoop tmp(0);
|
||||
cb.callbackFn(tmp);
|
||||
@@ -562,8 +565,7 @@ void DeviceManager::attachAllUnattachedDevicesFromReq(
|
||||
|
||||
const auto& caller = ComponentThread::getSelf();
|
||||
auto request = std::make_shared<AttachAllUnattachedDevicesFromReq>(
|
||||
DeviceManager::getInstance().deviceAttachmentSpecs.size(),
|
||||
caller, std::move(cb));
|
||||
specs->size(), specs, caller, std::move(cb));
|
||||
|
||||
mrntt::mrntt.thread->getIoService().post(
|
||||
std::bind(
|
||||
@@ -572,10 +574,18 @@ void DeviceManager::attachAllUnattachedDevicesFromReq(
|
||||
}
|
||||
|
||||
class DeviceManager::DetachAllAttachedDeviceRoles
|
||||
: public AttachAllUnattachedDevicesFromReq
|
||||
: public PostedAsynchronousContinuation<
|
||||
detachAllAttachedDeviceRolesCbFn>
|
||||
{
|
||||
public:
|
||||
using AttachAllUnattachedDevicesFromReq::AttachAllUnattachedDevicesFromReq;
|
||||
DetachAllAttachedDeviceRoles(
|
||||
const unsigned int totalNSpecs,
|
||||
const std::shared_ptr<ComponentThread>& caller,
|
||||
Callback<detachAllAttachedDeviceRolesCbFn> cb)
|
||||
: PostedAsynchronousContinuation<detachAllAttachedDeviceRolesCbFn>(
|
||||
caller, cb),
|
||||
loop(totalNSpecs)
|
||||
{}
|
||||
|
||||
void detachAllAttachedDeviceRoles1_posted(
|
||||
[[maybe_unused]] std::shared_ptr<DetachAllAttachedDeviceRoles> context
|
||||
@@ -619,6 +629,9 @@ public:
|
||||
|
||||
context->callOriginalCb(loop);
|
||||
}
|
||||
|
||||
public:
|
||||
AsynchronousLoop loop;
|
||||
};
|
||||
|
||||
void DeviceManager::detachAllAttachedDeviceRoles(
|
||||
|
||||
Reference in New Issue
Block a user