29 #include <boost/format.hpp>
31 #include <boost/tokenizer.hpp>
33 #include "../runtime/ContainerIO.h"
35 #include "../logging/LoggerFactory.h"
39 using namespace boost;
40 using namespace boost::filesystem;
45 Configurator::Configurator(
ManagerPtr manager,
const vector<path>& defaultPath)
46 : logger(logging::LoggerFactory::getInstance()
50 defaultPath(defaultPath) {
57 RSCINFO(this->
logger,
"No searchpath configured; using default: "
63 for (vector<string>::const_iterator it = this->
load.begin();
64 it != this->
load.end(); ++it) {
71 set<PluginPtr> matches;
73 matches = this->
manager->getPlugins(boost::regex(pattern));
74 }
catch (
const std::exception& e) {
75 throw runtime_error(str(format(
"Failed to lookup matching plugins for patterns `%1%' as requested via configuration: %2%")
79 RSCDEBUG(this->
logger,
"Found " << matches.size() <<
" match(es)");
82 for (set<PluginPtr>::iterator it = matches.begin();
83 it != matches.end(); ++it) {
87 }
catch (
const std::exception& e) {
88 throw runtime_error(str(format(
"Failed to load plugin `%1%' as requested via configuration: %2%")
97 const string& value) {
98 RSCDEBUG(this->
logger,
"Processing option " << key <<
" = `" << value <<
"'");
101 if (!((key.size() == 3)
102 && (key[0] ==
"plugins")
103 && (key[1] ==
"cpp"))) {
108 if (key[2] ==
"path") {
115 for (vector<string>::const_iterator it = paths.begin();
116 it != paths.end(); ++it) {
120 path =
"<default path>";
125 }
catch (
const std::exception& e) {
126 throw runtime_error(str(format(
"Failed to add path `%1%' as requested via configuration: %2%")
133 }
else if (key[2] ==
"load") {
135 copy(temp.begin(), temp.end(), back_inserter(this->
load));
137 throw invalid_argument(str(format(
"Invalid option key `%1%'; plugin related option keys are `path' and `load'.")
143 for (vector<path>::const_iterator it = this->
defaultPath.begin();
150 vector<string> result;
151 boost::escaped_list_separator<char> sep(
'\\',
':');
152 boost::tokenizer< boost::escaped_list_separator<char> > tok(value, sep);
153 copy(tok.begin(), tok.end(), back_inserter(result));