Files
salmanoff/smocore/include/deviceManager/deviceManager.h
T
hayodea cde2737876 Libspinscale: Initial top-level SMO port to coroutine framework
We haven't ported everything. Just the top-level methods. We'll
dig in to the leaf stuff later. Surprisingly, this all went without
any real difficulties.

Runs like a charm on first try.
2026-05-24 23:26:18 -04:00

111 lines
2.9 KiB
C++

#ifndef DEVICEMANAGER_H
#define DEVICEMANAGER_H
#include <vector>
#include <string>
#include <memory>
#include <opts.h>
#include <utility>
#include <iostream>
#include <user/senseApiDesc.h>
#include <user/deviceAttachmentSpec.h>
#include <deviceManager/device.h>
#include <deviceManager/deviceRole.h>
#include <deviceManager/deviceReattacher.h>
#include <cpsBoundary/stimBuffDeviceAReq.h>
#include <marionette/marionetteThread.h>
#include <spinscale/co/coQutex.h>
#include <spinscale/multiOperationResultSet.h>
#include <spinscale/sharedResourceGroup.h>
namespace smo {
namespace device {
class DeviceReattacher;
class DeviceManager
{
public:
struct DeviceAttachmentIndResult
{
bool success = false;
std::shared_ptr<DeviceRole> deviceRole;
std::shared_ptr<DeviceAttachmentSpec> deviceSpec;
};
static DeviceManager& getInstance()
{
static DeviceManager instance;
return instance;
}
void initialize(void)
{};
void finalize(void)
{};
void initializeDeviceReattacher();
void finalizeDeviceReattacher();
std::string readDapSpecFile(const std::string& filename);
void collateAllDapSpecs(void);
void parseAllDapSpecs(void);
static const std::string stringifyDeviceSpecs(void);
mrntt::MrnttViralPostingInvoker<DeviceAttachmentIndResult>
newDeviceAttachmentSpecIndCReq(const DeviceAttachmentSpec &spec);
mrntt::MrnttViralPostingInvoker<DeviceAttachmentIndResult>
removeDeviceAttachmentSpecCReq(const DeviceAttachmentSpec &spec);
mrntt::MrnttViralPostingInvoker<cpsBoundary::StimBuffDeviceOpResult>
attachStimBuffDeviceCReq(
const std::shared_ptr<DeviceAttachmentSpec>& spec);
mrntt::MrnttViralPostingInvoker<cpsBoundary::StimBuffDeviceOpResult>
detachStimBuffDeviceCReq(
const std::shared_ptr<DeviceAttachmentSpec>& spec);
mrntt::MrnttViralPostingInvoker<sscl::MultiOperationResultSet>
attachAllUnattachedDevicesFromCReq(
const std::shared_ptr<std::vector<DeviceAttachmentSpec>> &specs);
mrntt::MrnttViralPostingInvoker<sscl::MultiOperationResultSet>
attachAllUnattachedDevicesFromKnownListCReq();
mrntt::MrnttViralPostingInvoker<sscl::MultiOperationResultSet>
attachAllUnattachedDevicesFromCmdlineCReq();
mrntt::MrnttViralPostingInvoker<sscl::MultiOperationResultSet>
detachAllAttachedDeviceRolesCReq();
private:
DeviceManager()
: s("DeviceManager")
{}
~DeviceManager();
DeviceManager(const DeviceManager&) = delete;
DeviceManager& operator=(const DeviceManager&) = delete;
public:
struct Resources
{
std::vector<std::shared_ptr<DeviceAttachmentSpec>> deviceAttachmentSpecs;
std::vector<std::shared_ptr<Device>> devices;
std::vector<std::shared_ptr<DeviceRole>> attachedDeviceRoles;
std::vector<DeviceAttachmentSpec> commandLineDASpecs;
std::string allDapSpecs;
};
sscl::SharedResourceGroup<sscl::co::CoQutex, Resources> s;
private:
std::unique_ptr<DeviceReattacher> deviceReattacher;
};
} // namespace device
} // namespace smo
#endif // DEVICEMANAGER_H