Files
salmanoff/smocore/include/stimBuffApis/stimBuffApiManager.h
T
hayodea 3e19d39853 SenseApiDesc,xcbWindow: port to sscl coro framework
SenseApiDesc's exported API now uses coro pointers instead of
CPS fn pointers.
* Do not build this version of SMO with the Livox drivers enabled,
  because SMO has been changed at the smocore level to use coros
  when calling into stimbuffAPI libs. But the Livox drivers
  haven't yet been ported from CPS to coros.

xcbWindow has been ported to expose coros to SMO in its
senseApiDesc exported iface.
2026-05-25 08:58:36 -04:00

85 lines
2.1 KiB
C++

#ifndef SENSE_API_MANAGER_H
#define SENSE_API_MANAGER_H
#include <config.h>
#include <memory>
#include <vector>
#include <string>
#include <optional>
#include <functional>
#include <stimBuffApis/stimBuffApiLib.h>
#include <user/deviceAttachmentSpec.h>
#include <body/bodyThread.h>
#include <spinscale/co/coQutex.h>
#include <spinscale/sharedResourceGroup.h>
namespace smo {
namespace stim_buff {
class StimBuffApiManager
{
public:
struct Resources
{
std::vector<std::shared_ptr<StimBuffApiLib>> stimBuffApiLibs;
};
static StimBuffApiManager& getInstance()
{
static StimBuffApiManager instance;
return instance;
}
void initialize(void)
{};
void finalize(void)
{};
StimBuffApiLib& loadStimBuffApiLib(
const std::string& libraryPath,
const std::shared_ptr<sscl::ComponentThread>& componentThread);
std::optional<std::shared_ptr<StimBuffApiLib>> getStimBuffApiLib(
const std::string& libraryPath);
std::optional<std::shared_ptr<StimBuffApiLib>> getStimBuffApiLibByApiName(
const std::string& apiName);
void unloadStimBuffApiLib(const std::string& libraryPath);
void loadAllStimBuffApiLibsFromOptions(
const std::shared_ptr<sscl::ComponentThread>& componentThread);
void unloadAllStimBuffApiLibs(void);
body::BodyViralPostingInvoker<void> initializeStimBuffApiLibCReq(
StimBuffApiLib &lib, bool acquireSbamLock);
body::BodyViralPostingInvoker<void> finalizeStimBuffApiLibCReq(
StimBuffApiLib &lib, bool acquireSbamLock);
body::BodyViralPostingInvoker<void> initializeAllStimBuffApiLibsCReq();
body::BodyViralPostingInvoker<void> finalizeAllStimBuffApiLibsCReq();
std::string stringifyLibs() const;
private:
StimBuffApiManager()
: s("StimBuffApiManager")
{}
~StimBuffApiManager() = default;
StimBuffApiManager(const StimBuffApiManager&) = delete;
StimBuffApiManager& operator=(const StimBuffApiManager&) = delete;
public:
sscl::SharedResourceGroup<sscl::co::CoQutex, Resources> s;
public:
static std::optional<std::string> searchForLibInSmoSearchPaths(
const std::string& libraryPath);
};
} // namespace stim_buff
} // namespace smo
#endif // SENSE_API_MANAGER_H