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();