29 #include <boost/format.hpp> 31 #include <boost/tokenizer.hpp> 33 #include "../runtime/ContainerIO.h" 34 #include "../runtime/NoSuchObject.h" 36 #include "../config/Utility.h" 38 #include "../logging/LoggerFactory.h" 42 using namespace boost;
49 const vector<boost::filesystem::path>& defaultPath)
50 : logger(logging::LoggerFactory::getInstance()
53 defaultPath(defaultPath) {
55 this->
path.push_back(
"");
67 const string& value) {
68 RSCDEBUG(this->
logger,
"Processing option " << key <<
" = `" << value <<
"'");
71 if (!((key.size() == 3)
72 && (key[0] ==
"plugins")
73 && (key[1] ==
"cpp"))) {
78 if (key[2] ==
"path") {
80 key, value, this->
path);
81 }
else if (key[2] ==
"load") {
83 key, value, this->
load);
85 throw invalid_argument(str(format(
"Invalid option key `%1%'; plugin related option keys are `path' and `load'.")
93 for (vector<boost::filesystem::path>::const_iterator it = this->
defaultPath.begin();
100 for (vector<string>::const_iterator it = entries.begin();
101 it != entries.end(); ++it) {
105 path =
"<default path>";
112 }
catch (
const std::exception& e) {
113 throw runtime_error(str(format(
"Failed to add path `%1%' as requested via configuration: %2%")
121 bool errorOnMissing) {
122 for (vector<string>::const_iterator it = names.begin();
123 it != names.end(); ++it) {
127 string pattern = *it;
130 set<PluginPtr> matches;
132 matches = this->
manager->getPlugins(boost::regex(pattern));
133 }
catch (
const std::exception& e) {
134 throw runtime_error(str(format(
"Failed to lookup matching plugins for patterns `%1%' as requested via configuration: %2%")
138 RSCDEBUG(this->
logger,
"Found " << matches.size() <<
" match(es)");
140 if (matches.empty() && errorOnMissing) {
142 "Cannot find a plugin with name %1%") % pattern));
146 for (set<PluginPtr>::iterator it = matches.begin();
147 it != matches.end(); ++it) {
151 }
catch (
const std::exception& e) {
152 throw runtime_error(str(format(
"Failed to load plugin `%1%' as requested via configuration: %2%")
std::vector< boost::filesystem::path > defaultPath
#define RSCDEBUG(logger, msg)
detail::set_element_sequence_style< detail::element_sequence_style > element_sequence(const string &separator, const string &first_separator, const string &last_separator)
void loadPlugins(const std::vector< std::string > &names, bool errorOnMissing)
void execute(bool errorOnMissing=true)
Performs the actual loading of plugins.
void handleOption(const std::vector< std::string > &key, const std::string &value)
This method is called once for each individual option available from a given ConfigSource.
void addPathEntries(const std::vector< std::string > &entries)
std::vector< std::string > path
const detail::set_container_style< detail::container_style > container_none
#define RSCINFO(logger, msg)
vector< string > mergeSequenceValue(const string &description, const vector< string > &key, const string &raw, const vector< string > &previous)
std::vector< std::string > load
logging::LoggerPtr logger
boost::shared_ptr< Manager > ManagerPtr
This exception is thrown if a specified object does not exist.