#ifndef SENSE_API_MANAGER_H #define SENSE_API_MANAGER_H #include #include #include #include #include #include struct SenseApiInstance { int a; bool operator==(const SenseApiInstance& other) const { return a == other.a; } }; class SenseApiLib { public: std::string libraryPath; std::unique_ptr handle; SenseApiLib(const std::string& path) : libraryPath(path), handle(nullptr, &dlclose) {} }; class SenseApiManager { public: static SenseApiManager& getInstance() { static SenseApiManager instance { #ifdef CONFIG_SENSEAPI_FOO "builtinApi1", #endif #ifdef CONFIG_SENSEAPI_BAR "builtinApi2", #endif // X11 XCB is always built-in. "x11-xcb" }; return instance; } void registerSenseApi(const SenseApiInstance& apiInstance); void unregisterSenseApi(const SenseApiInstance& apiInstance); SenseApiLib& loadSenseApiLib(const std::string& libraryPath); std::optional> getSenseApiLib( const std::string& libraryPath); void unloadSenseApiLib(const std::string& libraryPath); private: SenseApiManager() = delete; SenseApiManager(std::initializer_list builtinApis) : builtinSenseApis(builtinApis) {} ~SenseApiManager() = default; SenseApiManager(const SenseApiManager&) = delete; SenseApiManager& operator=(const SenseApiManager&) = delete; std::vector> senseApiInstances; std::vector> senseApiLibs; const std::vector builtinSenseApis; }; #endif // SENSE_API_MANAGER_H