122 lines
3.6 KiB
C++
122 lines
3.6 KiB
C++
#ifndef DEVICEMANAGER_H
|
|
#define DEVICEMANAGER_H
|
|
|
|
#include <vector>
|
|
#include <string>
|
|
#include <memory>
|
|
#include <opts.h>
|
|
#include <utility>
|
|
#include <iostream>
|
|
#include <functional>
|
|
#include <user/senseApiDesc.h>
|
|
#include <user/deviceAttachmentSpec.h>
|
|
#include <asynchronousLoop.h>
|
|
#include <deviceManager/device.h>
|
|
#include <deviceManager/deviceRole.h>
|
|
#include <deviceManager/deviceReattacher.h>
|
|
#include <callback.h>
|
|
#include <qutex.h>
|
|
|
|
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();
|
|
|
|
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);
|
|
|
|
// Device attachment/detachment methods moved from SenseApiManager
|
|
typedef stim_buff::sal_mlo_attachDeviceReqCbFn attachStimBuffDeviceReqCbFn;
|
|
typedef stim_buff::sal_mlo_detachDeviceReqCbFn detachStimBuffDeviceReqCbFn;
|
|
|
|
void attachStimBuffDeviceReq(
|
|
const std::shared_ptr<DeviceAttachmentSpec>& spec,
|
|
Callback<attachStimBuffDeviceReqCbFn> cb);
|
|
void detachStimBuffDeviceReq(
|
|
const std::shared_ptr<DeviceAttachmentSpec>& spec,
|
|
Callback<detachStimBuffDeviceReqCbFn> cb);
|
|
|
|
typedef std::function<void(AsynchronousLoop &results)>
|
|
attachAllUnattachedDevicesFromReqCbFn;
|
|
typedef std::function<void(AsynchronousLoop &results)>
|
|
detachAllAttachedDeviceRolesCbFn;
|
|
|
|
void attachAllUnattachedDevicesFromReq(
|
|
const std::shared_ptr<std::vector<DeviceAttachmentSpec>> &specs,
|
|
Callback<attachAllUnattachedDevicesFromReqCbFn> cb);
|
|
void attachAllUnattachedDevicesFromKnownListReq(
|
|
Callback<attachAllUnattachedDevicesFromReqCbFn> cb);
|
|
void attachAllUnattachedDevicesFromCmdlineReq(
|
|
Callback<attachAllUnattachedDevicesFromReqCbFn> cb);
|
|
void detachAllAttachedDeviceRoles(
|
|
Callback<detachAllAttachedDeviceRolesCbFn> cb);
|
|
|
|
private:
|
|
DeviceManager()
|
|
: qutex("DeviceManager"), deviceReattacher(nullptr)
|
|
{}
|
|
~DeviceManager();
|
|
DeviceManager(const DeviceManager&) = delete;
|
|
DeviceManager& operator=(const DeviceManager&) = delete;
|
|
|
|
public:
|
|
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;
|
|
class AttachStimBuffDeviceReq;
|
|
typedef AttachStimBuffDeviceReq DetachStimBuffDeviceReq;
|
|
class AttachAllUnattachedDevicesFromReq;
|
|
class AttachAllUnattachedDevicesFromKnownListReq;
|
|
class DetachAllAttachedDeviceRoles;
|
|
};
|
|
|
|
} // namespace device
|
|
} // namespace smo
|
|
|
|
#endif // DEVICEMANAGER_H
|