2025-01-05 14:19:53 -04:00
|
|
|
#ifndef DEVICEMANAGER_H
|
|
|
|
|
#define DEVICEMANAGER_H
|
|
|
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
|
#include <string>
|
2025-01-08 06:23:34 -04:00
|
|
|
#include <memory>
|
2025-01-05 14:19:53 -04:00
|
|
|
#include <opts.h>
|
2025-01-07 14:11:51 -04:00
|
|
|
#include <utility>
|
|
|
|
|
#include <iostream>
|
2025-09-20 18:23:03 -04:00
|
|
|
#include <functional>
|
2025-09-27 23:16:46 -04:00
|
|
|
#include <user/senseApiDesc.h>
|
2025-08-29 15:16:11 -04:00
|
|
|
#include <user/deviceAttachmentSpec.h>
|
2025-09-27 23:16:46 -04:00
|
|
|
#include <asynchronousLoop.h>
|
2025-08-29 17:42:13 -04:00
|
|
|
#include <deviceManager/device.h>
|
2025-09-28 00:50:05 -04:00
|
|
|
#include <deviceManager/deviceRole.h>
|
2025-09-29 01:07:32 -04:00
|
|
|
#include <deviceManager/deviceReattacher.h>
|
2025-09-27 18:30:09 -04:00
|
|
|
#include <callback.h>
|
2025-09-28 01:27:32 -04:00
|
|
|
#include <qutex.h>
|
2025-01-05 14:19:53 -04:00
|
|
|
|
2025-07-22 06:48:04 -04:00
|
|
|
namespace smo {
|
2025-01-13 21:57:11 -04:00
|
|
|
namespace device {
|
|
|
|
|
|
2025-09-29 01:07:32 -04:00
|
|
|
class DeviceReattacher;
|
|
|
|
|
|
2025-01-05 14:19:53 -04:00
|
|
|
class DeviceManager
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
static DeviceManager& getInstance()
|
|
|
|
|
{
|
|
|
|
|
static DeviceManager instance;
|
|
|
|
|
return instance;
|
|
|
|
|
}
|
|
|
|
|
|
2025-09-12 16:09:26 -04:00
|
|
|
void initialize(void)
|
|
|
|
|
{};
|
|
|
|
|
void finalize(void)
|
|
|
|
|
{};
|
|
|
|
|
|
2025-09-29 01:07:32 -04:00
|
|
|
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);
|
2025-08-29 16:33:17 -04:00
|
|
|
|
2025-01-10 18:27:10 -04:00
|
|
|
static const std::string stringifyDeviceSpecs(void);
|
2025-01-05 14:19:53 -04:00
|
|
|
|
2025-09-10 06:51:55 -04:00
|
|
|
typedef std::function<void(
|
2025-09-28 00:50:05 -04:00
|
|
|
bool success, std::shared_ptr<DeviceRole> deviceRole,
|
2025-09-10 06:51:55 -04:00
|
|
|
std::shared_ptr<DeviceAttachmentSpec> deviceSpec)>
|
2025-09-15 14:20:08 -04:00
|
|
|
newDeviceAttachmentSpecIndCbFn;
|
2025-09-28 11:41:20 -04:00
|
|
|
typedef std::function<void(
|
|
|
|
|
bool success, std::shared_ptr<DeviceAttachmentSpec> deviceSpec)>
|
|
|
|
|
removeDeviceAttachmentSpecReqCbFn;
|
|
|
|
|
|
2025-09-10 06:51:55 -04:00
|
|
|
void newDeviceAttachmentSpecInd(
|
2025-09-28 11:41:20 -04:00
|
|
|
const DeviceAttachmentSpec &spec,
|
|
|
|
|
Callback<newDeviceAttachmentSpecIndCbFn> callback);
|
|
|
|
|
void removeDeviceAttachmentSpecReq(
|
|
|
|
|
const DeviceAttachmentSpec &spec,
|
|
|
|
|
Callback<removeDeviceAttachmentSpecReqCbFn> callback);
|
2025-08-29 17:42:13 -04:00
|
|
|
|
2025-09-27 23:16:46 -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-09-27 23:16:46 -04:00
|
|
|
|
2025-10-01 18:47:42 -04:00
|
|
|
void attachStimBuffDeviceReq(
|
2025-09-27 23:16:46 -04:00
|
|
|
const std::shared_ptr<DeviceAttachmentSpec>& spec,
|
2025-10-01 18:47:42 -04:00
|
|
|
Callback<attachStimBuffDeviceReqCbFn> cb);
|
|
|
|
|
void detachStimBuffDeviceReq(
|
2025-09-27 23:16:46 -04:00
|
|
|
const std::shared_ptr<DeviceAttachmentSpec>& spec,
|
2025-10-01 18:47:42 -04:00
|
|
|
Callback<detachStimBuffDeviceReqCbFn> cb);
|
2025-09-27 23:16:46 -04:00
|
|
|
|
|
|
|
|
typedef std::function<void(AsynchronousLoop &results)>
|
2025-09-28 12:19:56 -04:00
|
|
|
attachAllUnattachedDevicesFromReqCbFn;
|
2025-09-27 23:16:46 -04:00
|
|
|
typedef std::function<void(AsynchronousLoop &results)>
|
2025-09-28 12:19:56 -04:00
|
|
|
detachAllAttachedDeviceRolesCbFn;
|
2025-09-27 23:16:46 -04:00
|
|
|
|
2025-09-28 12:19:56 -04:00
|
|
|
void attachAllUnattachedDevicesFromReq(
|
2025-09-28 12:39:45 -04:00
|
|
|
const std::shared_ptr<std::vector<DeviceAttachmentSpec>> &specs,
|
2025-09-28 12:19:56 -04:00
|
|
|
Callback<attachAllUnattachedDevicesFromReqCbFn> cb);
|
2025-09-28 23:15:22 -04:00
|
|
|
void attachAllUnattachedDevicesFromKnownListReq(
|
|
|
|
|
Callback<attachAllUnattachedDevicesFromReqCbFn> cb);
|
2025-09-28 12:52:59 -04:00
|
|
|
void attachAllUnattachedDevicesFromCmdlineReq(
|
|
|
|
|
Callback<attachAllUnattachedDevicesFromReqCbFn> cb);
|
2025-09-28 12:19:56 -04:00
|
|
|
void detachAllAttachedDeviceRoles(
|
|
|
|
|
Callback<detachAllAttachedDeviceRolesCbFn> cb);
|
2025-09-27 23:16:46 -04:00
|
|
|
|
2025-01-05 14:19:53 -04:00
|
|
|
private:
|
2025-09-28 01:27:32 -04:00
|
|
|
DeviceManager()
|
2025-09-29 01:07:32 -04:00
|
|
|
: qutex("DeviceManager"), deviceReattacher(nullptr)
|
2025-09-28 01:27:32 -04:00
|
|
|
{}
|
2025-09-29 01:07:32 -04:00
|
|
|
~DeviceManager();
|
2025-01-05 14:19:53 -04:00
|
|
|
DeviceManager(const DeviceManager&) = delete;
|
|
|
|
|
DeviceManager& operator=(const DeviceManager&) = delete;
|
2025-01-07 14:11:51 -04:00
|
|
|
|
|
|
|
|
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;
|
2025-09-28 12:52:59 -04:00
|
|
|
static std::vector<DeviceAttachmentSpec> commandLineDASpecs;
|
2025-09-15 14:20:08 -04:00
|
|
|
|
|
|
|
|
private:
|
2025-09-29 01:07:32 -04:00
|
|
|
std::unique_ptr<DeviceReattacher> deviceReattacher;
|
|
|
|
|
|
2025-09-15 14:20:08 -04:00
|
|
|
class NewDeviceAttachmentSpecInd;
|
2025-09-28 11:41:20 -04:00
|
|
|
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;
|
2025-09-30 21:24:51 -04:00
|
|
|
class AttachAllUnattachedDevicesFromKnownListReq;
|
2025-09-28 12:19:56 -04:00
|
|
|
class DetachAllAttachedDeviceRoles;
|
2025-01-05 14:19:53 -04:00
|
|
|
};
|
|
|
|
|
|
2025-01-13 21:57:11 -04:00
|
|
|
} // namespace device
|
2025-07-22 06:48:04 -04:00
|
|
|
} // namespace smo
|
2025-01-13 21:57:11 -04:00
|
|
|
|
2025-01-05 14:19:53 -04:00
|
|
|
#endif // DEVICEMANAGER_H
|