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:
2025-09-28 12:19:56 -04:00
parent 993bf568fc
commit 2c60248127
3 changed files with 36 additions and 36 deletions
+2 -2
View File
@@ -78,7 +78,7 @@ public:
std::cout << __func__ << ": About to attachAllSenseDevicesFromSpecs" std::cout << __func__ << ": About to attachAllSenseDevicesFromSpecs"
<< '\n'; << '\n';
} }
device::DeviceManager::getInstance().attachAllSenseDevicesFromSpecsReq( device::DeviceManager::getInstance().attachAllUnattachedDevicesFromReq(
{context, std::bind( {context, std::bind(
&InitializeReq::initializeReq2, &InitializeReq::initializeReq2,
context.get(), context, context.get(), context,
@@ -117,7 +117,7 @@ public:
} }
std::cout << "Mrntt: About to detach all sense devices." << "\n"; std::cout << "Mrntt: About to detach all sense devices." << "\n";
device::DeviceManager::getInstance().detachAllSenseDevicesReq( device::DeviceManager::getInstance().detachAllAttachedDeviceRoles(
{context, std::bind( {context, std::bind(
&FinalizeReq::finalizeReq2, &FinalizeReq::finalizeReq2,
context.get(), context, context.get(), context,
+26 -26
View File
@@ -483,23 +483,23 @@ void DeviceManager::detachSenseDeviceReq(
request.get(), request)); request.get(), request));
} }
class DeviceManager::AttachAllSenseDevicesFromSpecsReq class DeviceManager::AttachAllUnattachedDevicesFromReq
: public PostedAsynchronousContinuation< : public PostedAsynchronousContinuation<
attachAllSenseDevicesFromSpecsReqCbFn> attachAllUnattachedDevicesFromReqCbFn>
{ {
public: public:
AttachAllSenseDevicesFromSpecsReq( AttachAllUnattachedDevicesFromReq(
const unsigned int totalNSpecs, const unsigned int totalNSpecs,
const std::shared_ptr<ComponentThread>& caller, const std::shared_ptr<ComponentThread>& caller,
Callback<attachAllSenseDevicesFromSpecsReqCbFn> cb) Callback<attachAllUnattachedDevicesFromReqCbFn> cb)
: PostedAsynchronousContinuation<attachAllSenseDevicesFromSpecsReqCbFn>( : PostedAsynchronousContinuation<attachAllUnattachedDevicesFromReqCbFn>(
caller, cb), caller, cb),
loop(totalNSpecs) loop(totalNSpecs)
{} {}
public: public:
void attachAllSenseDevicesFromSpecsReq1_posted( void attachAllUnattachedDevicesFromReq1_posted(
[[maybe_unused]] std::shared_ptr<AttachAllSenseDevicesFromSpecsReq> [[maybe_unused]] std::shared_ptr<AttachAllUnattachedDevicesFromReq>
context context
) )
{ {
@@ -508,7 +508,7 @@ public:
DeviceManager::getInstance().newDeviceAttachmentSpecInd( DeviceManager::getInstance().newDeviceAttachmentSpecInd(
*spec, *spec,
{context, std::bind( {context, std::bind(
&AttachAllSenseDevicesFromSpecsReq::attachAllSenseDevicesFromSpecsReq2, &AttachAllUnattachedDevicesFromReq::attachAllUnattachedDevicesFromReq2,
context.get(), context, context.get(), context,
std::placeholders::_1, std::placeholders::_2, std::placeholders::_1, std::placeholders::_2,
std::placeholders::_3)}); std::placeholders::_3)});
@@ -516,8 +516,8 @@ public:
} }
// Callback methods for the attachment sequence // Callback methods for the attachment sequence
void attachAllSenseDevicesFromSpecsReq2( void attachAllUnattachedDevicesFromReq2(
std::shared_ptr<AttachAllSenseDevicesFromSpecsReq> context, std::shared_ptr<AttachAllUnattachedDevicesFromReq> context,
bool success, std::shared_ptr<DeviceRole> deviceRole, bool success, std::shared_ptr<DeviceRole> deviceRole,
std::shared_ptr<DeviceAttachmentSpec> spec std::shared_ptr<DeviceAttachmentSpec> spec
) )
@@ -549,8 +549,8 @@ public:
AsynchronousLoop loop; AsynchronousLoop loop;
}; };
void DeviceManager::attachAllSenseDevicesFromSpecsReq( void DeviceManager::attachAllUnattachedDevicesFromReq(
Callback<attachAllSenseDevicesFromSpecsReqCbFn> cb Callback<attachAllUnattachedDevicesFromReqCbFn> cb
) )
{ {
if (DeviceManager::getInstance().deviceAttachmentSpecs.size() == 0) if (DeviceManager::getInstance().deviceAttachmentSpecs.size() == 0)
@@ -561,24 +561,24 @@ void DeviceManager::attachAllSenseDevicesFromSpecsReq(
} }
const auto& caller = ComponentThread::getSelf(); const auto& caller = ComponentThread::getSelf();
auto request = std::make_shared<AttachAllSenseDevicesFromSpecsReq>( auto request = std::make_shared<AttachAllUnattachedDevicesFromReq>(
DeviceManager::getInstance().deviceAttachmentSpecs.size(), DeviceManager::getInstance().deviceAttachmentSpecs.size(),
caller, std::move(cb)); caller, std::move(cb));
mrntt::mrntt.thread->getIoService().post( mrntt::mrntt.thread->getIoService().post(
std::bind( std::bind(
&AttachAllSenseDevicesFromSpecsReq::attachAllSenseDevicesFromSpecsReq1_posted, &AttachAllUnattachedDevicesFromReq::attachAllUnattachedDevicesFromReq1_posted,
request.get(), request)); request.get(), request));
} }
class DeviceManager::DetachAllSenseDevicesReq class DeviceManager::DetachAllAttachedDeviceRoles
: public AttachAllSenseDevicesFromSpecsReq : public AttachAllUnattachedDevicesFromReq
{ {
public: public:
using AttachAllSenseDevicesFromSpecsReq::AttachAllSenseDevicesFromSpecsReq; using AttachAllUnattachedDevicesFromReq::AttachAllUnattachedDevicesFromReq;
void detachAllSenseDevicesReq1_posted( void detachAllAttachedDeviceRoles1_posted(
[[maybe_unused]] std::shared_ptr<DetachAllSenseDevicesReq> context [[maybe_unused]] std::shared_ptr<DetachAllAttachedDeviceRoles> context
) )
{ {
for (const auto& spec : DeviceManager::deviceAttachmentSpecs) for (const auto& spec : DeviceManager::deviceAttachmentSpecs)
@@ -586,14 +586,14 @@ public:
DeviceManager::getInstance().detachSenseDeviceReq( DeviceManager::getInstance().detachSenseDeviceReq(
spec, spec,
{context, std::bind( {context, std::bind(
&DetachAllSenseDevicesReq::detachAllSenseDevicesReq2, &DetachAllAttachedDeviceRoles::detachAllAttachedDeviceRoles2,
context.get(), context, context.get(), context,
std::placeholders::_1, std::placeholders::_2)}); std::placeholders::_1, std::placeholders::_2)});
} }
} }
void detachAllSenseDevicesReq2( void detachAllAttachedDeviceRoles2(
std::shared_ptr<DetachAllSenseDevicesReq> context, std::shared_ptr<DetachAllAttachedDeviceRoles> context,
bool success, std::shared_ptr<DeviceAttachmentSpec> spec bool success, std::shared_ptr<DeviceAttachmentSpec> spec
) )
{ {
@@ -621,8 +621,8 @@ public:
} }
}; };
void DeviceManager::detachAllSenseDevicesReq( void DeviceManager::detachAllAttachedDeviceRoles(
Callback<detachAllSenseDevicesReqCbFn> cb Callback<detachAllAttachedDeviceRolesCbFn> cb
) )
{ {
if (DeviceManager::getInstance().deviceAttachmentSpecs.size() == 0) if (DeviceManager::getInstance().deviceAttachmentSpecs.size() == 0)
@@ -633,13 +633,13 @@ void DeviceManager::detachAllSenseDevicesReq(
} }
const auto& caller = ComponentThread::getSelf(); const auto& caller = ComponentThread::getSelf();
auto request = std::make_shared<DetachAllSenseDevicesReq>( auto request = std::make_shared<DetachAllAttachedDeviceRoles>(
DeviceManager::getInstance().deviceAttachmentSpecs.size(), DeviceManager::getInstance().deviceAttachmentSpecs.size(),
caller, std::move(cb)); caller, std::move(cb));
mrntt::mrntt.thread->getIoService().post( mrntt::mrntt.thread->getIoService().post(
std::bind( std::bind(
&DetachAllSenseDevicesReq::detachAllSenseDevicesReq1_posted, &DetachAllAttachedDeviceRoles::detachAllAttachedDeviceRoles1_posted,
request.get(), request)); request.get(), request));
} }
@@ -66,14 +66,14 @@ public:
Callback<detachSenseDeviceReqCbFn> cb); Callback<detachSenseDeviceReqCbFn> cb);
typedef std::function<void(AsynchronousLoop &results)> typedef std::function<void(AsynchronousLoop &results)>
attachAllSenseDevicesFromSpecsReqCbFn; attachAllUnattachedDevicesFromReqCbFn;
typedef std::function<void(AsynchronousLoop &results)> typedef std::function<void(AsynchronousLoop &results)>
detachAllSenseDevicesReqCbFn; detachAllAttachedDeviceRolesCbFn;
void attachAllSenseDevicesFromSpecsReq( void attachAllUnattachedDevicesFromReq(
Callback<attachAllSenseDevicesFromSpecsReqCbFn> cb); Callback<attachAllUnattachedDevicesFromReqCbFn> cb);
void detachAllSenseDevicesReq( void detachAllAttachedDeviceRoles(
Callback<detachAllSenseDevicesReqCbFn> cb); Callback<detachAllAttachedDeviceRolesCbFn> cb);
private: private:
DeviceManager() DeviceManager()
@@ -96,8 +96,8 @@ private:
class RemoveDeviceAttachmentSpecReq; class RemoveDeviceAttachmentSpecReq;
class AttachSenseDeviceReq; class AttachSenseDeviceReq;
typedef AttachSenseDeviceReq DetachSenseDeviceReq; typedef AttachSenseDeviceReq DetachSenseDeviceReq;
class AttachAllSenseDevicesFromSpecsReq; class AttachAllUnattachedDevicesFromReq;
class DetachAllSenseDevicesReq; class DetachAllAttachedDeviceRoles;
}; };
} // namespace device } // namespace device