36#include <unordered_map>
54 [[nodiscard]]
virtual bool lib_present(
const char *lib_base)
const = 0;
57 [[nodiscard]]
virtual const std::vector<std::string> &
62 const
char *description) const = 0;
68 template <typename Fn>
69 Fn
load_sym(const
char *lib_base, const
char *sym_name) {
97 [[nodiscard]]
bool lib_present(
const char *lib_base)
const override;
99 [[nodiscard]]
const std::vector<std::string> &
105 const char *description)
const override;
116 std::vector<std::string>
lib_names(
const char *lib_base)
const;
117 void append_paths(
const std::string &path_str,
char sep);
121 std::unordered_map<std::string, dynlib::Handle>
m_handles;
virtual ~IPluginLoader()=default
virtual void throw_not_found(const char *lib_base, const char *description) const =0
Throw a descriptive error for a missing potential library.
Fn load_sym(const char *lib_base, const char *sym_name)
Load a symbol from a named potential library.
IPluginLoader & operator=(const IPluginLoader &)=delete
virtual const std::vector< std::string > & search_paths() const noexcept=0
Get the current search paths (for diagnostics).
virtual dynlib::Handle open_lib(const char *lib_base)=0
virtual void add_config_paths(const std::string &colon_paths)=0
Inject search paths from the eOn config file.
IPluginLoader(const IPluginLoader &)=delete
virtual bool lib_present(const char *lib_base) const =0
Filesystem probe: a matching library file is on the configured search path.
void throw_not_found(const char *lib_base, const char *description) const override
Throw a descriptive error for a missing potential library.
std::vector< std::string > m_search_paths
bool m_last_load_saw_file
void add_config_paths(const std::string &colon_paths) override
Inject search paths from the eOn config file.
dynlib::Handle open_lib(const char *lib_base) override
static PluginLoader & instance()
Thread-safe singleton accessor (Meyer's pattern).
void append_paths(const std::string &path_str, char sep)
std::string m_last_load_error
Last dynlib::error() from a failed open (for throw_not_found).
PluginLoader(const PluginLoader &)=delete
std::vector< std::string > lib_names(const char *lib_base) const
bool lib_present(const char *lib_base) const override
Filesystem probe: a matching library file is on the configured search path.
std::unordered_map< std::string, dynlib::Handle > m_handles
const std::vector< std::string > & search_paths() const noexcept override
Get the current search paths (for diagnostics).
PluginLoader & operator=(const PluginLoader &)=delete
Fn loadSym(Handle h, const char *name) noexcept
Load a symbol and cast to a function pointer type.
RAII resource manager for the ARTn C library with global synchronization.