Files
salmanoff/smocore/include/stimBuffApis/stimBuffApiManager.h
T

78 lines
1.9 KiB
C++
Raw Normal View History

2025-10-01 18:47:42 -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>
#include <stimBuffApis/stimBuffApiLib.h>
#include <user/deviceAttachmentSpec.h>
#include <body/bodyThread.h>
#include <spinscale/co/coQutex.h>
#include <spinscale/sharedResourceGroup.h>
2025-10-01 18:47:42 -04:00
namespace smo {
namespace stim_buff {
class StimBuffApiManager
{
public:
struct Resources
{
std::vector<std::shared_ptr<StimBuffApiLib>> libs;
};
2025-10-01 18:47:42 -04:00
static StimBuffApiManager& getInstance()
{
static StimBuffApiManager instance;
return instance;
}
void initialize(void)
{};
void finalize(void)
{};
StimBuffApiLib& loadStimBuffApiLib(const std::string& libraryPath);
2025-10-01 18:47:42 -04:00
std::optional<std::shared_ptr<StimBuffApiLib>> findStimBuffApiLibByLibraryPath(
2025-10-01 18:47:42 -04:00
const std::string& libraryPath);
std::optional<std::shared_ptr<StimBuffApiLib>> findStimBuffApiLibByApiName(
2025-10-01 18:47:42 -04:00
const std::string& apiName);
StimBuffApiLib &getStimBuffApiLibByApiName(const std::string& apiName);
2025-10-01 18:47:42 -04:00
void unloadStimBuffApiLib(const std::string& libraryPath);
void loadAllStimBuffApiLibsFromOptions(void);
2025-10-01 18:47:42 -04:00
void unloadAllStimBuffApiLibs(void);
body::BodyViralPostingInvoker<void> initializeStimBuffApiLibCReq(
StimBuffApiLib &lib, bool acquireListLock=true);
body::BodyViralPostingInvoker<void> finalizeStimBuffApiLibCReq(
StimBuffApiLib &lib, bool acquireListLock=true);
body::BodyViralPostingInvoker<void> initializeAllStimBuffApiLibsCReq();
body::BodyViralPostingInvoker<void> finalizeAllStimBuffApiLibsCReq();
2025-10-01 18:47:42 -04:00
std::string stringifyLibs() const;
public:
sscl::SharedResourceGroup<sscl::co::CoQutex, Resources> s;
2025-10-01 18:47:42 -04:00
private:
StimBuffApiManager()
: s("StimBuffApiManager")
2025-10-01 18:47:42 -04:00
{}
2025-10-01 18:47:42 -04:00
~StimBuffApiManager() = default;
StimBuffApiManager(const StimBuffApiManager&) = delete;
StimBuffApiManager& operator=(const StimBuffApiManager&) = delete;
};
} // namespace stim_buff
} // namespace smo
#endif // SENSE_API_MANAGER_H