18Logger
g_log(
"LibraryManager");
34 const std::vector<std::string> &excludes) {
35 g_log.
debug(
"Opening all libraries in " + filepath +
"\n");
37 return openLibraries(std::filesystem::path(filepath), loadingBehaviour, excludes);
38 }
catch (std::exception &exc) {
39 g_log.
debug() <<
"Error occurred while opening libraries: " << exc.what() <<
"\n";
42 g_log.
error(
"An unknown error occurred while opening libraries.");
62 const std::vector<std::string> &excludes) {
64 if (std::filesystem::exists(libpath) && std::filesystem::is_directory(libpath)) {
66 for (
const auto &file : std::filesystem::directory_iterator(libpath)) {
67 const auto &path = file.path();
68 if (std::filesystem::is_regular_file(path)) {
70 libCount +=
openLibrary(path.string(), path.filename().string());
79 g_log.
error(
"In OpenAllLibraries: " + libpath.string() +
" must be a directory.");
116 return std::any_of(excludes.cbegin(), excludes.cend(),
117 [&filename](
const auto exclude) { return filename.find(exclude) != std::string::npos; });
132 if (
g_log.
is(Poco::Message::PRIO_DEBUG)) {
133 g_log.
debug(
"Opened library: " + filepath.string() +
".\n");
static bool isValidFilename(const std::string &filename)
Check if the filename conforms to the expected style for this platform.
bool isExcluded(const std::string &filename, const std::vector< std::string > &excludes) const
Returns true if the library has been requested to be excluded.
bool isLoaded(const std::string &filename) const
Check if the library has already been loaded.
int openLibraries(const std::string &libpath, LoadLibraries loadingBehaviour, const std::vector< std::string > &excludes)
Opens suitable DLLs on a given path.
std::unordered_map< std::string, LibraryWrapper > m_openedLibs
Storage for the LibraryWrappers.
bool shouldBeLoaded(const std::string &filename, const std::vector< std::string > &excludes) const
Check if the library should be loaded.
int openLibrary(const std::filesystem::path &filepath, const std::string &cacheKey)
Load a given library.
LibraryManagerImpl()
Private Constructor.
Class for wrapping a shared library.
bool openLibrary(const std::string &filepath)
Opens a DLL.
void debug(const std::string &msg)
Logs at debug level.
void error(const std::string &msg)
Logs at error level.
bool is(int level) const
Returns true if at least the given log level is set.
Logger g_log("DateAndTime")