38 #include "BESModuleApp.h" 40 #include "BESPluginFactory.h" 41 #include "BESAbstractModule.h" 42 #include "TheBESKeys.h" 75 retVal = loadModules();
78 string newerr =
"Error during module initialization: ";
80 cerr << newerr << endl;
84 string newerr =
"Error during module initialization: ";
85 newerr +=
"caught unknown exception";
86 cerr << newerr << endl;
96 int BESModuleApp::loadModules()
103 vector<string>::iterator l = vals.begin();
104 vector<string>::iterator le = vals.end();
117 vector<string> ordered_list;
118 for (; l != le; l++) {
121 if (mods.find(
"dap", 0) != string::npos) {
122 ordered_list.insert(ordered_list.begin(), mods);
125 ordered_list.push_back(mods);
130 l = ordered_list.begin();
131 le = ordered_list.end();
133 for (; l != le; l++) {
135 list<string> mod_list;
138 list<string>::iterator i = mod_list.begin();
139 list<string>::iterator e = mod_list.end();
140 for (; i != e; i++) {
142 string key =
"BES.module." + (*i);
152 cerr <<
"Couldn't find the module for " << (*i) << endl;
156 new_mod._module_name = (*i);
157 new_mod._module_library = so;
158 _module_list.push_back(new_mod);
163 list<bes_module>::iterator mi = _module_list.begin();
164 list<bes_module>::iterator me = _module_list.end();
165 for (; mi != me; mi++) {
166 bes_module curr_mod = *mi;
167 _moduleFactory.
add_mapping(curr_mod._module_name, curr_mod._module_library);
170 for (mi = _module_list.begin(); mi != me; mi++) {
171 bes_module curr_mod = *mi;
173 string modname = curr_mod._module_name;
175 o->initialize(modname);
179 cerr <<
"Caught plugin exception during initialization of " << curr_mod._module_name <<
" module:" << endl
185 cerr <<
"Caught unknown exception during initialization of " << curr_mod._module_name <<
" module" << endl;
204 list<bes_module>::iterator i = _module_list.begin();
205 list<bes_module>::iterator e = _module_list.end();
215 bes_module curr_mod = *e;
216 string modname = curr_mod._module_name;
219 o->terminate(modname);
226 cerr <<
"Caught exception during module termination: " << e.
get_message() << endl;
229 cerr <<
"Caught unknown exception during terminate" << endl;
245 strm << BESIndent::LMarg <<
"BESModuleApp::dump - (" << (
void *)
this <<
")" << endl;
247 if (_module_list.size()) {
248 strm << BESIndent::LMarg <<
"loaded modules:" << endl;
250 list<bes_module>::const_iterator i = _module_list.begin();
251 list<bes_module>::const_iterator e = _module_list.end();
252 for (; i != e; i++) {
253 bes_module curr_mod = *i;
254 strm << BESIndent::LMarg << curr_mod._module_name <<
": " << curr_mod._module_library << endl;
256 BESIndent::UnIndent();
259 strm << BESIndent::LMarg <<
"loaded modules: none" << endl;
261 BESIndent::UnIndent();
virtual ~BESModuleApp(void)
Default destructor.
virtual int initialize(int argC, char **argV)
initialize the BES application
Base application object for all BES applications.
virtual std::string get_message()
get the error message for this exception
virtual int terminate(int sig=0)
clean up after the application
Abstract exception class for the BES with basic string message.
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.
void get_value(const string &s, string &val, bool &found)
Retrieve the value of a given key, if set.
virtual int terminate(int sig=0)
clean up after the application
BESModuleApp(void)
Default constructor.
void add_mapping(const string &name, const string &library_name)
void get_values(const string &s, vector< string > &vals, bool &found)
Retrieve the values of a given key, if set.
static BESKeys * TheKeys()