Spinscale: PuppetComponent takes PuppetApplication&

This commit is contained in:
2025-12-27 14:15:17 -04:00
parent f862db922e
commit 0c4f427c0a
13 changed files with 66 additions and 42 deletions
+11 -5
View File
@@ -4,6 +4,7 @@
#include <spinscale/asynchronousLoop.h>
#include <spinscale/callback.h>
#include <spinscale/callableTracer.h>
#include <spinscale/puppetApplication.h>
#include <body/body.h>
#include <componentThread.h>
#include <mind.h>
@@ -23,14 +24,15 @@ class Body::InitializeReq
{
public:
InitializeReq(
Mind &parent, const std::shared_ptr<ComponentThread> &caller,
PuppetApplication &parent,
const std::shared_ptr<ComponentThread> &caller,
Callback<bodyLifetimeMgmtOpCbFn> callback)
: PostedAsynchronousContinuation<bodyLifetimeMgmtOpCbFn>(caller, callback),
parent(parent)
{}
private:
Mind &parent;
PuppetApplication &parent;
public:
void initializeReq1_posted(
@@ -54,15 +56,17 @@ public:
* We used to use Marionette, but there's a strong argument for using
* Body instead since it's meant to handle device-management operations.
*/
// Upcast to Mind to access Mind-specific members
Mind &mind = static_cast<Mind&>(context->parent);
stim_buff::StimBuffApiManager::getInstance()
.loadAllStimBuffApiLibsFromOptions(parent.body.thread);
.loadAllStimBuffApiLibsFromOptions(mind.body.thread);
/** EXPLANATION:
* Consider body::initializeReq to have been called if even one of its
* operations was executed at all, whether successfully or
* unsuccessfully.
*/
context->parent.bodyComponentInitialized = true;
mind.bodyComponentInitialized = true;
std::cout << stim_buff::StimBuffApiManager::getInstance().stringifyLibs()
<< std::endl;
@@ -176,7 +180,9 @@ void Body::finalizeReq(Callback<bodyLifetimeMgmtOpCbFn> callback)
return;
}
if (!parent.bodyComponentInitialized)
// Upcast to Mind to access Mind-specific members
Mind &mind = static_cast<Mind&>(parent);
if (!mind.bodyComponentInitialized)
{
std::cout << "Mrntt: Body component not initialized. "
<< "Skipping finalization." << "\n";