35 #include "BESModuleApp.h" 37 #include "BESPluginFactory.h" 38 #include "BESAbstractModule.h" 39 #include "TheBESKeys.h" 74 retVal = loadModules();
77 string newerr =
"Error during module initialization: ";
79 cerr << newerr << endl;
83 string newerr =
"Error during module initialization: ";
84 newerr +=
"caught unknown exception";
85 cerr << newerr << endl;
95 int BESModuleApp::loadModules()
102 vector<string>::iterator l = vals.begin();
103 vector<string>::iterator le = vals.end();
116 vector<string> ordered_list;
117 for (; l != le; l++) {
120 if (mods.find(
"dap", 0) != string::npos) {
121 ordered_list.insert(ordered_list.begin(), mods);
124 ordered_list.push_back(mods);
129 l = ordered_list.begin();
130 le = ordered_list.end();
132 for (; l != le; l++) {
134 list<string> mod_list;
137 list<string>::iterator i = mod_list.begin();
138 list<string>::iterator e = mod_list.end();
139 for (; i != e; i++) {
141 string key =
"BES.module." + (*i);
151 cerr <<
"Couldn't find the module for " << (*i) << endl;
155 new_mod._module_name = (*i);
156 new_mod._module_library = so;
157 _module_list.push_back(new_mod);
162 list<bes_module>::iterator mi = _module_list.begin();
163 list<bes_module>::iterator me = _module_list.end();
164 for (; mi != me; mi++) {
165 bes_module curr_mod = *mi;
166 _moduleFactory.
add_mapping(curr_mod._module_name, curr_mod._module_library);
169 for (mi = _module_list.begin(); mi != me; mi++) {
170 bes_module curr_mod = *mi;
172 string modname = curr_mod._module_name;
174 o->initialize(modname);
178 cerr <<
"Caught plugin exception during initialization of " << curr_mod._module_name <<
" module:" << endl
184 cerr <<
"Caught unknown exception during initialization of " << curr_mod._module_name <<
" module" << endl;
203 list<bes_module>::iterator i = _module_list.begin();
204 list<bes_module>::iterator e = _module_list.end();
214 bes_module curr_mod = *e;
215 string modname = curr_mod._module_name;
218 o->terminate(modname);
225 cerr <<
"Caught exception during module termination: " << e.
get_message() << endl;
228 cerr <<
"Caught unknown exception during terminate" << endl;
244 strm << BESIndent::LMarg <<
"BESModuleApp::dump - (" << (
void *)
this <<
")" << endl;
246 if (_module_list.size()) {
247 strm << BESIndent::LMarg <<
"loaded modules:" << endl;
249 list<bes_module>::const_iterator i = _module_list.begin();
250 list<bes_module>::const_iterator e = _module_list.end();
251 for (; i != e; i++) {
252 bes_module curr_mod = *i;
253 strm << BESIndent::LMarg << curr_mod._module_name <<
": " << curr_mod._module_library << endl;
255 BESIndent::UnIndent();
258 strm << BESIndent::LMarg <<
"loaded modules: none" << endl;
260 BESIndent::UnIndent();
virtual ~BESModuleApp(void)
Default destructor.
virtual int terminate(int sig=0)
Clean up after the application.
virtual std::string get_message()
get the error message for this exception
void get_value(const std::string &s, std::string &val, bool &found)
Retrieve the value of a given key, if set.
virtual int terminate(int sig=0)
clean up after the application
Abstract exception class for the BES with basic string message.
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.
static void explode(char delim, const string &str, list< string > &values)
virtual void dump(ostream &strm) const
dumps information about this object
C * get(const string &name)
virtual int initialize(int argC, char **argV)
Load and initialize any BES modules.
BESModuleApp(void)
Default constructor.
void add_mapping(const string &name, const string &library_name)
Application class for BES applications.
virtual int initialize(int argC, char **argV)
Initialize the application using the passed argc and argv values.