2025-01-08 06:26:36 -04:00
|
|
|
#ifndef SENSE_API_MANAGER_H
|
|
|
|
|
#define SENSE_API_MANAGER_H
|
|
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
#include <memory>
|
|
|
|
|
#include <vector>
|
|
|
|
|
#include <string>
|
|
|
|
|
#include <optional>
|
|
|
|
|
#include <functional>
|
2025-09-04 17:35:49 -04:00
|
|
|
#include <componentThread.h>
|
2025-09-10 18:12:08 -04:00
|
|
|
#include <asynchronousLoop.h>
|
2025-01-08 11:49:28 -04:00
|
|
|
#include <senseApis/senseApiLib.h>
|
2025-08-29 15:16:11 -04:00
|
|
|
#include <user/deviceAttachmentSpec.h>
|
2025-01-08 06:26:36 -04:00
|
|
|
|
2025-07-22 06:48:04 -04:00
|
|
|
namespace smo {
|
2025-01-08 11:49:28 -04:00
|
|
|
namespace sense_api {
|
2025-01-08 06:26:36 -04:00
|
|
|
|
2025-01-12 09:44:08 -04:00
|
|
|
class SenseApiManager
|
|
|
|
|
{
|
2025-01-08 06:26:36 -04:00
|
|
|
public:
|
|
|
|
|
static SenseApiManager& getInstance()
|
|
|
|
|
{
|
2025-01-08 11:49:28 -04:00
|
|
|
static SenseApiManager instance;
|
2025-01-08 06:26:36 -04:00
|
|
|
return instance;
|
|
|
|
|
}
|
|
|
|
|
|
2025-09-12 16:09:26 -04:00
|
|
|
void initialize(void)
|
|
|
|
|
{};
|
|
|
|
|
void finalize(void)
|
|
|
|
|
{};
|
|
|
|
|
|
2025-09-04 17:35:49 -04:00
|
|
|
SenseApiLib& loadSenseApiLib(
|
|
|
|
|
const std::string& libraryPath,
|
2025-09-12 16:09:26 -04:00
|
|
|
const std::shared_ptr<ComponentThread>& componentThread);
|
2025-09-04 17:35:49 -04:00
|
|
|
|
2025-08-29 13:19:33 -04:00
|
|
|
std::optional<std::shared_ptr<SenseApiLib>> getSenseApiLib(
|
2025-01-08 06:26:36 -04:00
|
|
|
const std::string& libraryPath);
|
2025-08-29 13:19:33 -04:00
|
|
|
std::optional<std::shared_ptr<SenseApiLib>> getSenseApiLibByApiName(
|
2025-01-12 14:31:33 -04:00
|
|
|
const std::string& apiName);
|
2025-01-08 06:26:36 -04:00
|
|
|
void unloadSenseApiLib(const std::string& libraryPath);
|
2025-01-12 09:44:49 -04:00
|
|
|
|
|
|
|
|
void initializeSenseApiLib(SenseApiLib& lib);
|
|
|
|
|
void finalizeSenseApiLib(SenseApiLib& lib);
|
|
|
|
|
|
2025-09-04 17:35:49 -04:00
|
|
|
void loadAllSenseApiLibsFromOptions(
|
2025-09-12 16:09:26 -04:00
|
|
|
const std::shared_ptr<ComponentThread>& componentThread);
|
2025-09-04 17:35:49 -04:00
|
|
|
|
2025-01-12 09:44:49 -04:00
|
|
|
void unloadAllSenseApiLibs(void);
|
|
|
|
|
void initializeAllSenseApiLibs(void);
|
|
|
|
|
void finalizeAllSenseApiLibs(void);
|
2025-01-08 06:26:36 -04:00
|
|
|
|
2025-09-10 06:51:55 -04:00
|
|
|
typedef sal_mlo_attachDeviceReqCbFn attachSenseDeviceReqCbFn;
|
|
|
|
|
typedef sal_mlo_detachDeviceReqCbFn detachSenseDeviceReqCbFn;
|
|
|
|
|
|
|
|
|
|
void attachSenseDeviceReq(
|
|
|
|
|
const std::shared_ptr<device::DeviceAttachmentSpec>& spec,
|
|
|
|
|
attachSenseDeviceReqCbFn cb);
|
|
|
|
|
void detachSenseDeviceReq(
|
|
|
|
|
const std::shared_ptr<device::DeviceAttachmentSpec>& spec,
|
|
|
|
|
detachSenseDeviceReqCbFn cb);
|
2025-09-10 18:12:08 -04:00
|
|
|
|
|
|
|
|
typedef std::function<void(AsynchronousLoop &results)>
|
|
|
|
|
attachAllSenseDevicesFromSpecsReqCbFn;
|
|
|
|
|
typedef std::function<void(AsynchronousLoop &results)>
|
|
|
|
|
detachAllSenseDevicesReqCbFn;
|
|
|
|
|
|
|
|
|
|
void attachAllSenseDevicesFromSpecsReq(
|
|
|
|
|
attachAllSenseDevicesFromSpecsReqCbFn cb);
|
|
|
|
|
void detachAllSenseDevicesReq(
|
|
|
|
|
detachAllSenseDevicesReqCbFn cb);
|
2025-01-12 14:31:33 -04:00
|
|
|
|
2025-01-11 06:40:43 -04:00
|
|
|
std::string stringifyLibs() const;
|
|
|
|
|
|
2025-01-08 06:26:36 -04:00
|
|
|
private:
|
2025-01-08 11:49:28 -04:00
|
|
|
SenseApiManager() = default;
|
2025-01-08 06:26:36 -04:00
|
|
|
~SenseApiManager() = default;
|
|
|
|
|
|
|
|
|
|
SenseApiManager(const SenseApiManager&) = delete;
|
|
|
|
|
SenseApiManager& operator=(const SenseApiManager&) = delete;
|
|
|
|
|
|
2025-08-29 13:19:33 -04:00
|
|
|
std::vector<std::shared_ptr<SenseApiLib>> senseApiLibs;
|
2025-07-24 02:12:31 -04:00
|
|
|
|
2025-09-10 06:51:55 -04:00
|
|
|
class AttachSenseDeviceReq;
|
2025-09-16 18:38:06 -04:00
|
|
|
typedef AttachSenseDeviceReq DetachSenseDeviceReq;
|
2025-09-10 18:12:08 -04:00
|
|
|
class AttachAllSenseDevicesFromSpecsReq;
|
|
|
|
|
class DetachAllSenseDevicesReq;
|
2025-09-10 06:51:55 -04:00
|
|
|
|
2025-07-24 02:12:31 -04:00
|
|
|
public:
|
|
|
|
|
static std::optional<std::string> searchForLibInSmoSearchPaths(
|
|
|
|
|
const std::string& libraryPath);
|
2025-01-08 06:26:36 -04:00
|
|
|
};
|
|
|
|
|
|
2025-01-08 11:49:28 -04:00
|
|
|
} // namespace sense_api
|
2025-07-22 06:48:04 -04:00
|
|
|
} // namespace smo
|
2025-01-08 11:49:28 -04:00
|
|
|
|
2025-01-08 06:26:36 -04:00
|
|
|
#endif // SENSE_API_MANAGER_H
|