32 #include <boost/filesystem/operations.hpp> 33 #include <boost/regex.hpp> 34 #include <boost/format.hpp> 36 #include "../runtime/NoSuchObject.h" 37 #include "../logging/LoggerFactory.h" 41 using namespace boost;
48 : logger(logging::LoggerFactory::getInstance()
61 if (find(this->path.begin(), this->path.end(),
path)
62 != this->path.end()) {
68 this->path.push_back(path);
69 if (!is_directory(path)) {
70 RSCINFO(this->
logger,
"Ignoring non-existent path `" << path <<
"'");
74 set<string> namesInThisPath;
75 for (directory_iterator it = directory_iterator(path);
76 it != directory_iterator(); ++it) {
78 if (!is_regular_file(it->path())) {
79 RSCINFO(this->
logger,
"Ignoring non-regular file " << it->path());
84 string name = it->path()
85 #if BOOST_FILESYSTEM_VERSION == 3 92 #
if defined(__linux__)
93 "^lib([^.]*)(.*)\\.so(.*)$" 94 #elif defined(__APPLE__)
95 "^lib([^.]*)(.*)\\.dylib$" 102 if (!regex_match(name, libraryName)) {
103 RSCINFO(this->
logger,
"Ignoring non-matching file " << name);
107 name = regex_replace(name, libraryName,
"\\1");
108 if (namesInThisPath.count(name) != 0) {
112 "The path %1% contains multiple plugins forming the plugin name %2%.")
115 namesInThisPath.insert(name);
117 boost::filesystem::path library = it->path();
123 << name <<
"' [" << library <<
"]");
132 set<PluginPtr> result;
134 for (PluginMap::const_iterator it = this->
plugins.begin();
135 it != this->
plugins.end(); ++it) {
136 if (regex_match(it->first, regex)) {
137 result.insert(it->second);
148 PluginMap::const_iterator it;
void addPath(const boost::filesystem::path &path)
Adds path to the list of search path entries.
std::vector< boost::filesystem::path > getPath() const
Returns the current plugin search path.
static boost::shared_ptr< Plugin > create(const std::string &name, const std::string &library)
#define RSCTRACE(logger, msg)
#define RSCINFO(logger, msg)
boost::shared_ptr< Plugin > PluginPtr
std::set< PluginPtr > getPlugins(const boost::regex ®ex=boost::regex(".*")) const
Returns the set of known plugins, potentially filtered by name according to regular expression regex...
PluginPtr getPlugin(const std::string &name) const
Return the plugin designated by name.
logging::LoggerPtr logger
This exception is thrown if a specified object does not exist.