13#include <Poco/DirectoryIterator.h>
16#include <boost/algorithm/string.hpp>
21Logger
g_log(
"LibraryManager");
37 const std::vector<std::string> &excludes) {
38 g_log.
debug(
"Opening all libraries in " + filepath +
"\n");
40 return openLibraries(Poco::File(filepath), loadingBehaviour, excludes);
41 }
catch (std::exception &exc) {
42 g_log.
debug() <<
"Error occurred while opening libraries: " << exc.what() <<
"\n";
45 g_log.
error(
"An unknown error occurred while opening libraries.");
64 const std::vector<std::string> &excludes) {
66 if (libpath.exists() && libpath.isDirectory()) {
68 Poco::DirectoryIterator end_itr;
69 for (Poco::DirectoryIterator itr(libpath); itr != end_itr; ++itr) {
70 const Poco::File &item = *itr;
73 libCount +=
openLibrary(itr.path(), itr.path().getFileName());
82 g_log.
error(
"In OpenAllLibraries: " + libpath.path() +
" must be a directory.");
119 for (
const auto &exclude : excludes) {
120 if (filename.find(exclude) != std::string::npos) {
139 if (
g_log.
is(Poco::Message::PRIO_DEBUG)) {
140 g_log.
debug(
"Opened library: " + filepath.path() +
".\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 openLibrary(const Poco::File &filepath, const std::string &cacheKey)
Load a given library.
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.
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")