Libspinscale: Add separate CMake project config
This commit is contained in:
@@ -14,7 +14,7 @@
|
||||
#include <deviceManager/deviceManager.h>
|
||||
#include <deviceManager/deviceReattacher.h>
|
||||
#include <stimBuffApis/stimBuffApiManager.h>
|
||||
#include <marionette/marionette.h>
|
||||
#include <spinscale/marionette.h>
|
||||
#include <mind.h>
|
||||
|
||||
namespace smo {
|
||||
@@ -304,7 +304,7 @@ void DeviceManager::newDeviceAttachmentSpecInd(
|
||||
});
|
||||
|
||||
NewDeviceAttachmentSpecInd::LockerAndInvoker lockvoker(
|
||||
*request, mrntt::mrntt.thread,
|
||||
*request, sscl::mrntt::mrntt.thread,
|
||||
std::bind(
|
||||
&NewDeviceAttachmentSpecInd::newDeviceAttachmentSpecInd1_posted,
|
||||
request.get(), request));
|
||||
@@ -323,7 +323,7 @@ void DeviceManager::removeDeviceAttachmentSpecReq(
|
||||
});
|
||||
|
||||
RemoveDeviceAttachmentSpecReq::LockerAndInvoker lockvoker(
|
||||
*request, mrntt::mrntt.thread,
|
||||
*request, sscl::mrntt::mrntt.thread,
|
||||
std::bind(
|
||||
&RemoveDeviceAttachmentSpecReq
|
||||
::removeDeviceAttachmentSpecReq1_posted,
|
||||
@@ -500,7 +500,7 @@ void DeviceManager::attachStimBuffDeviceReq(
|
||||
});
|
||||
|
||||
AttachStimBuffDeviceReq::LockerAndInvoker lockvoker(
|
||||
*request, mrntt::mrntt.thread,
|
||||
*request, sscl::mrntt::mrntt.thread,
|
||||
std::bind(
|
||||
&AttachStimBuffDeviceReq::attachStimBuffDeviceReq1_posted,
|
||||
request.get(), request));
|
||||
@@ -535,7 +535,7 @@ void DeviceManager::detachStimBuffDeviceReq(
|
||||
});
|
||||
|
||||
DetachStimBuffDeviceReq::LockerAndInvoker lockvoker(
|
||||
*request, mrntt::mrntt.thread,
|
||||
*request, sscl::mrntt::mrntt.thread,
|
||||
std::bind(
|
||||
&DetachStimBuffDeviceReq::detachStimBuffDeviceReq1_posted,
|
||||
request.get(), request));
|
||||
@@ -626,7 +626,7 @@ void DeviceManager::attachAllUnattachedDevicesFromReq(
|
||||
auto request = std::make_shared<AttachAllUnattachedDevicesFromReq>(
|
||||
specs->size(), specs, caller, std::move(cb));
|
||||
|
||||
mrntt::mrntt.thread->getIoService().post(
|
||||
sscl::mrntt::mrntt.thread->getIoService().post(
|
||||
STC(std::bind(
|
||||
&AttachAllUnattachedDevicesFromReq
|
||||
::attachAllUnattachedDevicesFromReq1_posted,
|
||||
@@ -723,7 +723,7 @@ void DeviceManager::attachAllUnattachedDevicesFromKnownListReq(
|
||||
});
|
||||
|
||||
AttachAllUnattachedDevicesFromKnownListReq::LockerAndInvoker lockvoker(
|
||||
*request, mrntt::mrntt.thread,
|
||||
*request, sscl::mrntt::mrntt.thread,
|
||||
std::bind(
|
||||
&AttachAllUnattachedDevicesFromKnownListReq
|
||||
::attachAllUnattachedDevicesFromKnownListReq1_posted,
|
||||
@@ -807,7 +807,7 @@ void DeviceManager::detachAllAttachedDeviceRoles(
|
||||
DeviceManager::getInstance().attachedDeviceRoles.size(),
|
||||
caller, std::move(cb));
|
||||
|
||||
mrntt::mrntt.thread->getIoService().post(
|
||||
sscl::mrntt::mrntt.thread->getIoService().post(
|
||||
STC(std::bind(
|
||||
&DetachAllAttachedDeviceRoles::detachAllAttachedDeviceRoles1_posted,
|
||||
request.get(), request)));
|
||||
@@ -816,7 +816,7 @@ void DeviceManager::detachAllAttachedDeviceRoles(
|
||||
void DeviceManager::initializeDeviceReattacher()
|
||||
{
|
||||
deviceReattacher = std::make_unique<DeviceReattacher>(
|
||||
*this, mrntt::mrntt.thread);
|
||||
*this, sscl::mrntt::mrntt.thread);
|
||||
|
||||
deviceReattacher->start();
|
||||
}
|
||||
|
||||
@@ -1,56 +0,0 @@
|
||||
#ifndef _MARIONETTE_H
|
||||
#define _MARIONETTE_H
|
||||
|
||||
#include <cstdint>
|
||||
#include <atomic>
|
||||
#include <memory>
|
||||
#include <spinscale/component.h>
|
||||
|
||||
namespace smo {
|
||||
|
||||
class MarionetteThread;
|
||||
|
||||
namespace mrntt {
|
||||
|
||||
class MarionetteComponent
|
||||
: public sscl::Component
|
||||
{
|
||||
public:
|
||||
MarionetteComponent(const std::shared_ptr<sscl::ComponentThread> &thread);
|
||||
~MarionetteComponent() = default;
|
||||
|
||||
public:
|
||||
typedef std::function<void(bool)> mrnttLifetimeMgmtOpCbFn;
|
||||
void initializeReq(sscl::Callback<mrnttLifetimeMgmtOpCbFn> callback);
|
||||
void finalizeReq(sscl::Callback<mrnttLifetimeMgmtOpCbFn> callback);
|
||||
// Intentionally doesn't take a callback.
|
||||
void exceptionInd();
|
||||
|
||||
private:
|
||||
class MrnttLifetimeMgmtOp;
|
||||
class TerminationEvent;
|
||||
};
|
||||
|
||||
extern std::atomic<int> exitCode;
|
||||
void exitMarionetteLoop();
|
||||
void marionetteFinalizeReqCb(bool success);
|
||||
extern mrntt::MarionetteComponent mrntt;
|
||||
|
||||
} // namespace mrntt
|
||||
|
||||
struct CrtCommandLineArgs
|
||||
{
|
||||
CrtCommandLineArgs(int argc, char *argv[], char *envp[])
|
||||
: argc(argc), argv(argv), envp(envp)
|
||||
{}
|
||||
|
||||
int argc;
|
||||
char **argv;
|
||||
char **envp;
|
||||
|
||||
static void set(int argc, char *argv[], char *envp[]);
|
||||
};
|
||||
|
||||
} // namespace smo
|
||||
|
||||
#endif // _MARIONETTE_H
|
||||
@@ -4,12 +4,12 @@
|
||||
#include <spinscale/callback.h>
|
||||
#include <spinscale/callableTracer.h>
|
||||
#include <spinscale/component.h>
|
||||
#include <spinscale/marionette.h>
|
||||
#include <componentThread.h>
|
||||
#include <deviceManager/deviceManager.h>
|
||||
#include <mindManager/mindManager.h>
|
||||
#include <marionette/marionette.h>
|
||||
|
||||
namespace smo {
|
||||
namespace sscl {
|
||||
namespace mrntt {
|
||||
|
||||
class MarionetteComponent::MrnttLifetimeMgmtOp
|
||||
@@ -33,13 +33,13 @@ public:
|
||||
)
|
||||
{
|
||||
auto self = sscl::ComponentThread::getSelf();
|
||||
if (self->id != SmoThreadId::MRNTT)
|
||||
if (self->id != smo::SmoThreadId::MRNTT)
|
||||
{
|
||||
throw std::runtime_error(std::string(__func__)
|
||||
+ ": Must be executed on Marionette thread");
|
||||
}
|
||||
|
||||
smo::mind::globalMind = std::make_shared<Mind>();
|
||||
smo::mind::globalMind = std::make_shared<smo::Mind>();
|
||||
smo::mind::globalMind->initializeReq({context, std::bind(
|
||||
&MrnttLifetimeMgmtOp::initializeReq2,
|
||||
this, context, std::placeholders::_1)});
|
||||
@@ -58,7 +58,7 @@ public:
|
||||
return;
|
||||
}
|
||||
|
||||
device::DeviceManager::getInstance().initializeDeviceReattacher();
|
||||
smo::device::DeviceManager::getInstance().initializeDeviceReattacher();
|
||||
|
||||
// Call negtrinEventInd on the Director in the final callback
|
||||
smo::mind::globalMind->director.negtrinEventInd();
|
||||
@@ -71,13 +71,13 @@ public:
|
||||
)
|
||||
{
|
||||
auto self = sscl::ComponentThread::getSelf();
|
||||
if (self->id != SmoThreadId::MRNTT)
|
||||
if (self->id != smo::SmoThreadId::MRNTT)
|
||||
{
|
||||
throw std::runtime_error(std::string(__func__)
|
||||
+ ": Must be executed on Marionette thread");
|
||||
}
|
||||
|
||||
device::DeviceManager::getInstance().finalizeDeviceReattacher();
|
||||
smo::device::DeviceManager::getInstance().finalizeDeviceReattacher();
|
||||
|
||||
/** FIXME:
|
||||
* It may be necessary to add a delay here to ensure that all in-flight
|
||||
@@ -133,24 +133,24 @@ public:
|
||||
)
|
||||
{
|
||||
auto self = sscl::ComponentThread::getSelf();
|
||||
if (self->id != SmoThreadId::MRNTT)
|
||||
if (self->id != smo::SmoThreadId::MRNTT)
|
||||
{
|
||||
throw std::runtime_error(std::string(__func__)
|
||||
+ ": Must be executed on Marionette thread");
|
||||
}
|
||||
|
||||
mrntt::mrntt.finalizeReq({nullptr, std::bind(
|
||||
&mrntt::marionetteFinalizeReqCb,
|
||||
sscl::mrntt::mrntt.finalizeReq({nullptr, std::bind(
|
||||
&sscl::mrntt::marionetteFinalizeReqCb,
|
||||
std::placeholders::_1)});
|
||||
}
|
||||
};
|
||||
|
||||
void MarionetteComponent::initializeReq(
|
||||
void sscl::mrntt::MarionetteComponent::initializeReq(
|
||||
sscl::Callback<mrnttLifetimeMgmtOpCbFn> callback)
|
||||
{
|
||||
auto mrntt = sscl::ComponentThread::getSelf();
|
||||
|
||||
if (mrntt->id != SmoThreadId::MRNTT)
|
||||
if (mrntt->id != smo::SmoThreadId::MRNTT)
|
||||
{
|
||||
throw std::runtime_error(std::string(__func__)
|
||||
+ ": Must be executed on Marionette thread");
|
||||
@@ -165,12 +165,12 @@ void MarionetteComponent::initializeReq(
|
||||
request.get(), request)));
|
||||
}
|
||||
|
||||
void MarionetteComponent::finalizeReq(
|
||||
void sscl::mrntt::MarionetteComponent::finalizeReq(
|
||||
sscl::Callback<mrnttLifetimeMgmtOpCbFn> callback)
|
||||
{
|
||||
auto mrntt = sscl::ComponentThread::getSelf();
|
||||
|
||||
if (mrntt->id != SmoThreadId::MRNTT)
|
||||
if (mrntt->id != smo::SmoThreadId::MRNTT)
|
||||
{
|
||||
throw std::runtime_error(std::string(__func__)
|
||||
+ ": Must be executed on Marionette thread");
|
||||
@@ -185,7 +185,7 @@ void MarionetteComponent::finalizeReq(
|
||||
request.get(), request)));
|
||||
}
|
||||
|
||||
void MarionetteComponent::exceptionInd()
|
||||
void sscl::mrntt::MarionetteComponent::exceptionInd()
|
||||
{
|
||||
auto faultyThread = sscl::ComponentThread::getSelf();
|
||||
auto mrntt = sscl::ComponentThread::getMrntt();
|
||||
@@ -200,4 +200,4 @@ void MarionetteComponent::exceptionInd()
|
||||
}
|
||||
|
||||
} // namespace mrntt
|
||||
} // namespace smo
|
||||
} // namespace sscl
|
||||
|
||||
+24
-21
@@ -9,12 +9,16 @@
|
||||
#include <boost/asio/signal_set.hpp>
|
||||
#include <spinscale/asynchronousBridge.h>
|
||||
#include <spinscale/componentThread.h>
|
||||
#include <spinscale/marionette.h>
|
||||
#include <componentThread.h>
|
||||
#include <mindManager/mindManager.h>
|
||||
#include <marionette/marionette.h>
|
||||
#include <salmanoff.h>
|
||||
|
||||
namespace smo {
|
||||
// Define the global marionette thread instance (declared extern in libspinscale)
|
||||
namespace sscl {
|
||||
namespace mrntt {
|
||||
std::shared_ptr<MarionetteThread> thread = std::make_shared<MarionetteThread>();
|
||||
} // namespace mrntt
|
||||
|
||||
CrtCommandLineArgs crtCommandLineArgs(0, nullptr, nullptr);
|
||||
|
||||
@@ -25,9 +29,6 @@ void CrtCommandLineArgs::set(int argc, char *argv[], char *envp[])
|
||||
|
||||
namespace mrntt {
|
||||
std::atomic<int> exitCode;
|
||||
// Global marionette thread instance
|
||||
std::shared_ptr<sscl::MarionetteThread> thread =
|
||||
std::make_shared<sscl::MarionetteThread>();
|
||||
MarionetteComponent mrntt(std::static_pointer_cast<sscl::ComponentThread>(thread));
|
||||
|
||||
void exitMarionetteLoop()
|
||||
@@ -47,6 +48,10 @@ void marionetteFinalizeReqCb(bool success)
|
||||
std::cout << __func__ << ": Marionette finalized." << '\n';
|
||||
exitMarionetteLoop();
|
||||
}
|
||||
} // namespace mrntt
|
||||
} // namespace sscl
|
||||
|
||||
namespace smo {
|
||||
|
||||
void marionetteInitializeReqCb(bool success)
|
||||
{
|
||||
@@ -59,13 +64,11 @@ void marionetteInitializeReqCb(bool success)
|
||||
std::cerr << __func__ << ": Failed to initialize Marionette. Shutting down."
|
||||
<< '\n';
|
||||
|
||||
mrntt::mrntt.finalizeReq({nullptr, std::bind(
|
||||
&mrntt::marionetteFinalizeReqCb,
|
||||
sscl::mrntt::mrntt.finalizeReq({nullptr, std::bind(
|
||||
&sscl::mrntt::marionetteFinalizeReqCb,
|
||||
std::placeholders::_1)});
|
||||
}
|
||||
|
||||
} // namespace mrntt
|
||||
|
||||
} // namespace smo
|
||||
|
||||
namespace sscl {
|
||||
@@ -78,7 +81,7 @@ void MarionetteThread::main(MarionetteThread& self)
|
||||
std::cout << __func__ << ": Waiting for command line JOLT" << std::endl;
|
||||
self.getIoService().run();
|
||||
self.initializeTls();
|
||||
smo::mrntt::exitCode = EXIT_SUCCESS;
|
||||
sscl::mrntt::exitCode = EXIT_SUCCESS;
|
||||
static boost::asio::signal_set signals(self.getIoService(), SIGINT);
|
||||
bool callShutdownSalmanoff = false;
|
||||
|
||||
@@ -100,8 +103,8 @@ void MarionetteThread::main(MarionetteThread& self)
|
||||
default:
|
||||
break;
|
||||
}
|
||||
smo::mrntt::mrntt.finalizeReq({nullptr, std::bind(
|
||||
&smo::mrntt::marionetteFinalizeReqCb,
|
||||
sscl::mrntt::mrntt.finalizeReq({nullptr, std::bind(
|
||||
&sscl::mrntt::marionetteFinalizeReqCb,
|
||||
std::placeholders::_1)});
|
||||
}
|
||||
);
|
||||
@@ -112,8 +115,8 @@ void MarionetteThread::main(MarionetteThread& self)
|
||||
<< std::endl;
|
||||
|
||||
options.parseArguments(
|
||||
smo::crtCommandLineArgs.argc, smo::crtCommandLineArgs.argv,
|
||||
smo::crtCommandLineArgs.envp);
|
||||
sscl::crtCommandLineArgs.argc, sscl::crtCommandLineArgs.argv,
|
||||
sscl::crtCommandLineArgs.envp);
|
||||
|
||||
std::cout << __func__ << ": " << options.stringifyOptions()
|
||||
<< std::endl;
|
||||
@@ -144,8 +147,8 @@ void MarionetteThread::main(MarionetteThread& self)
|
||||
callShutdownSalmanoff = true;
|
||||
|
||||
// Create new Mind instance just before initializeReq
|
||||
smo::mrntt::mrntt.initializeReq({nullptr, std::bind(
|
||||
&smo::mrntt::marionetteInitializeReqCb, std::placeholders::_1)});
|
||||
sscl::mrntt::mrntt.initializeReq({nullptr, std::bind(
|
||||
&smo::marionetteInitializeReqCb, std::placeholders::_1)});
|
||||
|
||||
std::cout << __func__ << ": Entering event loop" << "\n";
|
||||
|
||||
@@ -188,8 +191,8 @@ void MarionetteThread::main(MarionetteThread& self)
|
||||
|
||||
if (sendExceptionInd)
|
||||
{
|
||||
smo::mrntt::exitCode = EXIT_FAILURE;
|
||||
smo::mrntt::mrntt.exceptionInd();
|
||||
sscl::mrntt::exitCode = EXIT_FAILURE;
|
||||
sscl::mrntt::mrntt.exceptionInd();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -202,7 +205,7 @@ void MarionetteThread::main(MarionetteThread& self)
|
||||
|
||||
if (typeid(e) == typeid(OptionsParserError))
|
||||
{
|
||||
smo::mrntt::exitCode = EXIT_FAILURE;
|
||||
sscl::mrntt::exitCode = EXIT_FAILURE;
|
||||
out = &std::cerr;
|
||||
outUsageMsg = std::string(__func__) + ": ";
|
||||
}
|
||||
@@ -213,12 +216,12 @@ void MarionetteThread::main(MarionetteThread& self)
|
||||
{
|
||||
std::cerr << __func__ << ": Exception occurred: " << e.what()
|
||||
<< std::endl;
|
||||
smo::mrntt::exitCode = EXIT_FAILURE;
|
||||
sscl::mrntt::exitCode = EXIT_FAILURE;
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
std::cerr << __func__ << ": Unknown exception occurred" << std::endl;
|
||||
smo::mrntt::exitCode = EXIT_FAILURE;
|
||||
sscl::mrntt::exitCode = EXIT_FAILURE;
|
||||
}
|
||||
|
||||
if (callShutdownSalmanoff) {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include <iostream>
|
||||
#include <spinscale/component.h>
|
||||
#include <nonNeutralQualia.h>
|
||||
#include <marionette/marionette.h>
|
||||
#include <spinscale/marionette.h>
|
||||
|
||||
|
||||
namespace smo {
|
||||
|
||||
+3
-3
@@ -9,7 +9,7 @@
|
||||
#include <director/director.h>
|
||||
#include <simulator/simulator.h>
|
||||
#include <stimBuffApis/stimBuffApiManager.h>
|
||||
#include <marionette/marionette.h>
|
||||
#include <spinscale/marionette.h>
|
||||
|
||||
namespace smo {
|
||||
|
||||
@@ -227,7 +227,7 @@ void Mind::initializeReq(sscl::Callback<mindLifetimeMgmtOpCbFn> callback)
|
||||
auto request = std::make_shared<MindLifetimeMgmtOp>(
|
||||
*this, caller, callback);
|
||||
|
||||
mrntt::mrntt.thread->getIoService().post(
|
||||
sscl::mrntt::mrntt.thread->getIoService().post(
|
||||
STC(std::bind(
|
||||
&MindLifetimeMgmtOp::initializeReq1_posted,
|
||||
request.get(), request)));
|
||||
@@ -239,7 +239,7 @@ void Mind::finalizeReq(sscl::Callback<mindLifetimeMgmtOpCbFn> callback)
|
||||
auto request = std::make_shared<MindLifetimeMgmtOp>(
|
||||
*this, caller, callback);
|
||||
|
||||
mrntt::mrntt.thread->getIoService().post(
|
||||
sscl::mrntt::mrntt.thread->getIoService().post(
|
||||
STC(std::bind(
|
||||
&MindLifetimeMgmtOp::finalizeReq1_posted,
|
||||
request.get(), request)));
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
#include <componentThread.h>
|
||||
#include <mindThread.h>
|
||||
#include <marionette/marionette.h>
|
||||
#include <spinscale/marionette.h>
|
||||
|
||||
namespace smo {
|
||||
|
||||
void MindThread::handleException()
|
||||
{
|
||||
mrntt::mrntt.exceptionInd();
|
||||
sscl::mrntt::mrntt.exceptionInd();
|
||||
}
|
||||
|
||||
} // namespace smo
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#include <user/senseApiDesc.h>
|
||||
#include <mind.h>
|
||||
#include <deviceManager/deviceManager.h>
|
||||
#include <marionette/marionette.h>
|
||||
#include <spinscale/marionette.h>
|
||||
#include <computeManager/computeManager.h>
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user