36#include "BESModuleApp.h"
38#include "BESPluginFactory.h"
39#include "BESAbstractModule.h"
40#include "TheBESKeys.h"
61BESModuleApp::~BESModuleApp()
77 retVal = loadModules();
80 cerr <<
"Error during module initialization: " << e.
get_message() << endl;
84 cerr <<
"Error during module initialization: Unknown exception" << endl;
94int BESModuleApp::loadModules()
115 vector<string> ordered_list;
116 for (; l != le; l++) {
119 if (mods.find(
"dap", 0) != string::npos) {
120 ordered_list.insert(ordered_list.begin(), mods);
123 ordered_list.push_back(mods);
128 l = ordered_list.begin();
129 le = ordered_list.end();
131 for (; l != le; l++) {
133 list<string> mod_list;
136 list<string>::iterator i = mod_list.begin();
137 list<string>::iterator e = mod_list.end();
138 for (; i != e; i++) {
140 string key =
"BES.module." + (*i);
145 catch( BESError &e ) {
150 cerr <<
"Couldn't find the module for " << (*i) << endl;
154 new_mod._module_name = (*i);
155 new_mod._module_library = so;
156 _module_list.push_back(new_mod);
161 list<bes_module>::iterator mi = _module_list.begin();
162 list<bes_module>::iterator me = _module_list.end();
163 for (; mi != me; mi++) {
164 bes_module curr_mod = *mi;
165 _moduleFactory.add_mapping(curr_mod._module_name, curr_mod._module_library);
168 for (mi = _module_list.begin(); mi != me; mi++) {
169 bes_module curr_mod = *mi;
171 string modname = curr_mod._module_name;
172 BESAbstractModule *o = _moduleFactory.get(modname);
173 o->initialize(modname);
176 catch( BESError &e ) {
177 cerr <<
"Caught plugin exception during initialization of " << curr_mod._module_name <<
" module:" << endl
183 cerr <<
"Caught unknown exception during initialization of " << curr_mod._module_name <<
" module" << endl;
213 bes_module curr_mod = *e;
214 string modname = curr_mod._module_name;
217 o->terminate(modname);
224 cerr <<
"Caught exception during module termination: " << e.get_message() << endl;
227 cerr <<
"Caught unknown exception during terminate" << endl;
243 strm << BESIndent::LMarg <<
"BESModuleApp::dump - (" << (
void *)
this <<
")" << endl;
245 if (_module_list.size()) {
246 strm << BESIndent::LMarg <<
"loaded modules:" << endl;
250 for (; i != e; i++) {
251 bes_module curr_mod = *i;
252 strm << BESIndent::LMarg << curr_mod._module_name <<
": " << curr_mod._module_library << endl;
254 BESIndent::UnIndent();
257 strm << BESIndent::LMarg <<
"loaded modules: none" << endl;
259 BESIndent::UnIndent();
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
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()
Access to the singleton.
void get_values(const std::string &s, std::vector< std::string > &vals, bool &found)
Retrieve the values of a given key, if set.