35#include "BESModuleApp.h"
37#include "BESPluginFactory.h"
38#include "BESAbstractModule.h"
39#include "TheBESKeys.h"
60BESModuleApp::~BESModuleApp()
76 retVal = loadModules();
79 cerr <<
"Error during module initialization: " << e.
get_message() << endl;
83 cerr <<
"Error during module initialization: Unknown exception" << endl;
93int BESModuleApp::loadModules()
100 vector<string>::iterator l = vals.begin();
101 vector<string>::iterator le = vals.end();
114 vector<string> ordered_list;
115 for (; l != le; l++) {
118 if (mods.find(
"dap", 0) != string::npos) {
119 ordered_list.insert(ordered_list.begin(), mods);
122 ordered_list.push_back(mods);
127 l = ordered_list.begin();
128 le = ordered_list.end();
130 for (; l != le; l++) {
132 list<string> mod_list;
135 list<string>::iterator i = mod_list.begin();
136 list<string>::iterator e = mod_list.end();
137 for (; i != e; i++) {
139 string key =
"BES.module." + (*i);
149 cerr <<
"Couldn't find the module for " << (*i) << endl;
153 new_mod._module_name = (*i);
154 new_mod._module_library = so;
155 _module_list.push_back(new_mod);
160 list<bes_module>::iterator mi = _module_list.begin();
161 list<bes_module>::iterator me = _module_list.end();
162 for (; mi != me; mi++) {
163 bes_module curr_mod = *mi;
164 _moduleFactory.
add_mapping(curr_mod._module_name, curr_mod._module_library);
167 for (mi = _module_list.begin(); mi != me; mi++) {
168 bes_module curr_mod = *mi;
170 string modname = curr_mod._module_name;
172 o->initialize(modname);
176 cerr <<
"Caught plugin exception during initialization of " << curr_mod._module_name <<
" module:" << endl
182 cerr <<
"Caught unknown exception during initialization of " << curr_mod._module_name <<
" module" << endl;
201 list<bes_module>::iterator i = _module_list.begin();
202 list<bes_module>::iterator e = _module_list.end();
212 bes_module curr_mod = *e;
213 string modname = curr_mod._module_name;
216 o->terminate(modname);
223 cerr <<
"Caught exception during module termination: " << e.get_message() << endl;
226 cerr <<
"Caught unknown exception during terminate" << endl;
242 strm << BESIndent::LMarg <<
"BESModuleApp::dump - (" << (
void *)
this <<
")" << endl;
244 if (_module_list.size()) {
245 strm << BESIndent::LMarg <<
"loaded modules:" << endl;
247 list<bes_module>::const_iterator i = _module_list.begin();
248 list<bes_module>::const_iterator e = _module_list.end();
249 for (; i != e; i++) {
250 bes_module curr_mod = *i;
251 strm << BESIndent::LMarg << curr_mod._module_name <<
": " << curr_mod._module_library << endl;
253 BESIndent::UnIndent();
256 strm << BESIndent::LMarg <<
"loaded modules: none" << endl;
258 BESIndent::UnIndent();
Application class for BES applications.
virtual int initialize(int argC, char **argV)
Initialize the application using the passed argc and argv values.
virtual int terminate(int sig=0)
Clean up after the application.
Base exception class for the BES with basic string message.
std::string get_message() const
get the error message for this exception
BESModuleApp()
Default constructor.
int terminate(int sig=0) override
clean up after the application
int initialize(int argC, char **argV) override
Load and initialize any BES modules.
void dump(std::ostream &strm) const override
dumps information about this object
void add_mapping(const std::string &name, const std::string &library_name)
C * get(const std::string &name)
static void explode(char delim, const std::string &str, std::list< std::string > &values)
void get_value(const std::string &s, std::string &val, bool &found)
Retrieve the value of a given key, if set.
static TheBESKeys * TheKeys()
void get_values(const std::string &s, std::vector< std::string > &vals, bool &found)
Retrieve the values of a given key, if set.