Files
salmanoff/smocore/include/deviceManager/deviceManager.h
T

122 lines
3.6 KiB
C++
Raw Normal View History

#ifndef DEVICEMANAGER_H
#define DEVICEMANAGER_H
#include <vector>
#include <string>
#include <memory>
#include <opts.h>
#include <utility>
#include <iostream>
2025-09-20 18:23:03 -04:00
#include <functional>
#include <user/senseApiDesc.h>
#include <user/deviceAttachmentSpec.h>
#include <asynchronousLoop.h>
2025-08-29 17:42:13 -04:00
#include <deviceManager/device.h>
#include <deviceManager/deviceRole.h>
#include <deviceManager/deviceReattacher.h>
#include <callback.h>
2025-09-28 01:27:32 -04:00
#include <qutex.h>
2025-07-22 06:48:04 -04:00
namespace smo {
namespace device {
class DeviceReattacher;
class DeviceManager
{
public:
static DeviceManager& getInstance()
{
static DeviceManager instance;
return instance;
}
void initialize(void)
{};
void finalize(void)
{};
void initializeDeviceReattacher();
void finalizeDeviceReattacher();
2025-08-29 16:12:30 -04:00
std::string readDapSpecFile(const std::string& filename);
void collateAllDapSpecs(void);
void parseAllDapSpecs(void);
static const std::string stringifyDeviceSpecs(void);
typedef std::function<void(
bool success, std::shared_ptr<DeviceRole> deviceRole,
std::shared_ptr<DeviceAttachmentSpec> deviceSpec)>
newDeviceAttachmentSpecIndCbFn;
typedef std::function<void(
bool success, std::shared_ptr<DeviceAttachmentSpec> deviceSpec)>
removeDeviceAttachmentSpecReqCbFn;
void newDeviceAttachmentSpecInd(
const DeviceAttachmentSpec &spec,
Callback<newDeviceAttachmentSpecIndCbFn> callback);
void removeDeviceAttachmentSpecReq(
const DeviceAttachmentSpec &spec,
Callback<removeDeviceAttachmentSpecReqCbFn> callback);
2025-08-29 17:42:13 -04:00
// Device attachment/detachment methods moved from SenseApiManager
2025-10-01 18:47:42 -04:00
typedef stim_buff::sal_mlo_attachDeviceReqCbFn attachStimBuffDeviceReqCbFn;
typedef stim_buff::sal_mlo_detachDeviceReqCbFn detachStimBuffDeviceReqCbFn;
2025-10-01 18:47:42 -04:00
void attachStimBuffDeviceReq(
const std::shared_ptr<DeviceAttachmentSpec>& spec,
2025-10-01 18:47:42 -04:00
Callback<attachStimBuffDeviceReqCbFn> cb);
void detachStimBuffDeviceReq(
const std::shared_ptr<DeviceAttachmentSpec>& spec,
2025-10-01 18:47:42 -04:00
Callback<detachStimBuffDeviceReqCbFn> cb);
typedef std::function<void(AsynchronousLoop &results)>
2025-09-28 12:19:56 -04:00
attachAllUnattachedDevicesFromReqCbFn;
typedef std::function<void(AsynchronousLoop &results)>
2025-09-28 12:19:56 -04:00
detachAllAttachedDeviceRolesCbFn;
2025-09-28 12:19:56 -04:00
void attachAllUnattachedDevicesFromReq(
const std::shared_ptr<std::vector<DeviceAttachmentSpec>> &specs,
2025-09-28 12:19:56 -04:00
Callback<attachAllUnattachedDevicesFromReqCbFn> cb);
void attachAllUnattachedDevicesFromKnownListReq(
Callback<attachAllUnattachedDevicesFromReqCbFn> cb);
void attachAllUnattachedDevicesFromCmdlineReq(
Callback<attachAllUnattachedDevicesFromReqCbFn> cb);
2025-09-28 12:19:56 -04:00
void detachAllAttachedDeviceRoles(
Callback<detachAllAttachedDeviceRolesCbFn> cb);
private:
2025-09-28 01:27:32 -04:00
DeviceManager()
: qutex("DeviceManager"), deviceReattacher(nullptr)
2025-09-28 01:27:32 -04:00
{}
~DeviceManager();
DeviceManager(const DeviceManager&) = delete;
DeviceManager& operator=(const DeviceManager&) = delete;
public:
2025-09-28 01:27:32 -04:00
Qutex qutex;
std::string allDapSpecs;
static std::vector<std::shared_ptr<DeviceAttachmentSpec>>
deviceAttachmentSpecs;
static std::vector<std::shared_ptr<Device>> devices;
static std::vector<std::shared_ptr<DeviceRole>> attachedDeviceRoles;
static std::vector<DeviceAttachmentSpec> commandLineDASpecs;
private:
std::unique_ptr<DeviceReattacher> deviceReattacher;
class NewDeviceAttachmentSpecInd;
class RemoveDeviceAttachmentSpecReq;
2025-10-01 18:47:42 -04:00
class AttachStimBuffDeviceReq;
typedef AttachStimBuffDeviceReq DetachStimBuffDeviceReq;
2025-09-28 12:19:56 -04:00
class AttachAllUnattachedDevicesFromReq;
class AttachAllUnattachedDevicesFromKnownListReq;
2025-09-28 12:19:56 -04:00
class DetachAllAttachedDeviceRoles;
};
} // namespace device
2025-07-22 06:48:04 -04:00
} // namespace smo
#endif // DEVICEMANAGER_H