DevMgr: Rename at/detachAll*Req():
We've renamed these now to better reflect what they do. * attachAllSenseDevicesFromSpecsReq=>attachAllUnattachedDevicesFromReq * detachAllSenseDevicesReq=>detachAllAttachedDeviceRoles This is also the first step in changing attachAllUnattachedDevicesFrom to accept a sh_ptr<> to a collection of DeviceAttachmentSpecs. This will enable us to unify the underlying spec attachment logic and just create several front-ends for attaching specs from multiple sources.
This commit is contained in:
@@ -483,23 +483,23 @@ void DeviceManager::detachSenseDeviceReq(
|
||||
request.get(), request));
|
||||
}
|
||||
|
||||
class DeviceManager::AttachAllSenseDevicesFromSpecsReq
|
||||
class DeviceManager::AttachAllUnattachedDevicesFromReq
|
||||
: public PostedAsynchronousContinuation<
|
||||
attachAllSenseDevicesFromSpecsReqCbFn>
|
||||
attachAllUnattachedDevicesFromReqCbFn>
|
||||
{
|
||||
public:
|
||||
AttachAllSenseDevicesFromSpecsReq(
|
||||
AttachAllUnattachedDevicesFromReq(
|
||||
const unsigned int totalNSpecs,
|
||||
const std::shared_ptr<ComponentThread>& caller,
|
||||
Callback<attachAllSenseDevicesFromSpecsReqCbFn> cb)
|
||||
: PostedAsynchronousContinuation<attachAllSenseDevicesFromSpecsReqCbFn>(
|
||||
Callback<attachAllUnattachedDevicesFromReqCbFn> cb)
|
||||
: PostedAsynchronousContinuation<attachAllUnattachedDevicesFromReqCbFn>(
|
||||
caller, cb),
|
||||
loop(totalNSpecs)
|
||||
{}
|
||||
|
||||
public:
|
||||
void attachAllSenseDevicesFromSpecsReq1_posted(
|
||||
[[maybe_unused]] std::shared_ptr<AttachAllSenseDevicesFromSpecsReq>
|
||||
void attachAllUnattachedDevicesFromReq1_posted(
|
||||
[[maybe_unused]] std::shared_ptr<AttachAllUnattachedDevicesFromReq>
|
||||
context
|
||||
)
|
||||
{
|
||||
@@ -508,7 +508,7 @@ public:
|
||||
DeviceManager::getInstance().newDeviceAttachmentSpecInd(
|
||||
*spec,
|
||||
{context, std::bind(
|
||||
&AttachAllSenseDevicesFromSpecsReq::attachAllSenseDevicesFromSpecsReq2,
|
||||
&AttachAllUnattachedDevicesFromReq::attachAllUnattachedDevicesFromReq2,
|
||||
context.get(), context,
|
||||
std::placeholders::_1, std::placeholders::_2,
|
||||
std::placeholders::_3)});
|
||||
@@ -516,8 +516,8 @@ public:
|
||||
}
|
||||
|
||||
// Callback methods for the attachment sequence
|
||||
void attachAllSenseDevicesFromSpecsReq2(
|
||||
std::shared_ptr<AttachAllSenseDevicesFromSpecsReq> context,
|
||||
void attachAllUnattachedDevicesFromReq2(
|
||||
std::shared_ptr<AttachAllUnattachedDevicesFromReq> context,
|
||||
bool success, std::shared_ptr<DeviceRole> deviceRole,
|
||||
std::shared_ptr<DeviceAttachmentSpec> spec
|
||||
)
|
||||
@@ -549,8 +549,8 @@ public:
|
||||
AsynchronousLoop loop;
|
||||
};
|
||||
|
||||
void DeviceManager::attachAllSenseDevicesFromSpecsReq(
|
||||
Callback<attachAllSenseDevicesFromSpecsReqCbFn> cb
|
||||
void DeviceManager::attachAllUnattachedDevicesFromReq(
|
||||
Callback<attachAllUnattachedDevicesFromReqCbFn> cb
|
||||
)
|
||||
{
|
||||
if (DeviceManager::getInstance().deviceAttachmentSpecs.size() == 0)
|
||||
@@ -561,24 +561,24 @@ void DeviceManager::attachAllSenseDevicesFromSpecsReq(
|
||||
}
|
||||
|
||||
const auto& caller = ComponentThread::getSelf();
|
||||
auto request = std::make_shared<AttachAllSenseDevicesFromSpecsReq>(
|
||||
auto request = std::make_shared<AttachAllUnattachedDevicesFromReq>(
|
||||
DeviceManager::getInstance().deviceAttachmentSpecs.size(),
|
||||
caller, std::move(cb));
|
||||
|
||||
mrntt::mrntt.thread->getIoService().post(
|
||||
std::bind(
|
||||
&AttachAllSenseDevicesFromSpecsReq::attachAllSenseDevicesFromSpecsReq1_posted,
|
||||
&AttachAllUnattachedDevicesFromReq::attachAllUnattachedDevicesFromReq1_posted,
|
||||
request.get(), request));
|
||||
}
|
||||
|
||||
class DeviceManager::DetachAllSenseDevicesReq
|
||||
: public AttachAllSenseDevicesFromSpecsReq
|
||||
class DeviceManager::DetachAllAttachedDeviceRoles
|
||||
: public AttachAllUnattachedDevicesFromReq
|
||||
{
|
||||
public:
|
||||
using AttachAllSenseDevicesFromSpecsReq::AttachAllSenseDevicesFromSpecsReq;
|
||||
using AttachAllUnattachedDevicesFromReq::AttachAllUnattachedDevicesFromReq;
|
||||
|
||||
void detachAllSenseDevicesReq1_posted(
|
||||
[[maybe_unused]] std::shared_ptr<DetachAllSenseDevicesReq> context
|
||||
void detachAllAttachedDeviceRoles1_posted(
|
||||
[[maybe_unused]] std::shared_ptr<DetachAllAttachedDeviceRoles> context
|
||||
)
|
||||
{
|
||||
for (const auto& spec : DeviceManager::deviceAttachmentSpecs)
|
||||
@@ -586,14 +586,14 @@ public:
|
||||
DeviceManager::getInstance().detachSenseDeviceReq(
|
||||
spec,
|
||||
{context, std::bind(
|
||||
&DetachAllSenseDevicesReq::detachAllSenseDevicesReq2,
|
||||
&DetachAllAttachedDeviceRoles::detachAllAttachedDeviceRoles2,
|
||||
context.get(), context,
|
||||
std::placeholders::_1, std::placeholders::_2)});
|
||||
}
|
||||
}
|
||||
|
||||
void detachAllSenseDevicesReq2(
|
||||
std::shared_ptr<DetachAllSenseDevicesReq> context,
|
||||
void detachAllAttachedDeviceRoles2(
|
||||
std::shared_ptr<DetachAllAttachedDeviceRoles> context,
|
||||
bool success, std::shared_ptr<DeviceAttachmentSpec> spec
|
||||
)
|
||||
{
|
||||
@@ -621,8 +621,8 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
void DeviceManager::detachAllSenseDevicesReq(
|
||||
Callback<detachAllSenseDevicesReqCbFn> cb
|
||||
void DeviceManager::detachAllAttachedDeviceRoles(
|
||||
Callback<detachAllAttachedDeviceRolesCbFn> cb
|
||||
)
|
||||
{
|
||||
if (DeviceManager::getInstance().deviceAttachmentSpecs.size() == 0)
|
||||
@@ -633,13 +633,13 @@ void DeviceManager::detachAllSenseDevicesReq(
|
||||
}
|
||||
|
||||
const auto& caller = ComponentThread::getSelf();
|
||||
auto request = std::make_shared<DetachAllSenseDevicesReq>(
|
||||
auto request = std::make_shared<DetachAllAttachedDeviceRoles>(
|
||||
DeviceManager::getInstance().deviceAttachmentSpecs.size(),
|
||||
caller, std::move(cb));
|
||||
|
||||
mrntt::mrntt.thread->getIoService().post(
|
||||
std::bind(
|
||||
&DetachAllSenseDevicesReq::detachAllSenseDevicesReq1_posted,
|
||||
&DetachAllAttachedDeviceRoles::detachAllAttachedDeviceRoles1_posted,
|
||||
request.get(), request));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user