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();
108 vector<string> ordered_list;
109 for (; l != le; l++) {
112 if (mods.find(
"dap", 0) != string::npos) {
113 ordered_list.insert(ordered_list.begin(), mods);
116 ordered_list.push_back(mods);
121 l = ordered_list.begin();
122 le = ordered_list.end();
123 for (; l != le; l++) {
125 list<string> mod_list;
128 list<string>::iterator i = mod_list.begin();
129 list<string>::iterator e = mod_list.end();
130 for (; i != e; i++) {
132 string key =
"BES.module." + (*i);
142 cerr <<
"couldn't find the module for " << (*i) << endl;
146 new_mod._module_name = (*i);
147 new_mod._module_library = so;
148 _module_list.push_back(new_mod);
153 list<bes_module>::iterator mi = _module_list.begin();
154 list<bes_module>::iterator me = _module_list.end();
155 for (; mi != me; mi++) {
156 bes_module curr_mod = *mi;
157 _moduleFactory.
add_mapping(curr_mod._module_name, curr_mod._module_library);
160 for (mi = _module_list.begin(); mi != me; mi++) {
161 bes_module curr_mod = *mi;
163 string modname = curr_mod._module_name;
169 cerr <<
"Caught plugin exception during initialization of " << curr_mod._module_name <<
" module:" << endl
175 cerr <<
"Caught unknown exception during initialization of " << curr_mod._module_name <<
" module" << endl;
194 list<bes_module>::iterator i = _module_list.begin();
195 list<bes_module>::iterator e = _module_list.end();
205 bes_module curr_mod = *e;
206 string modname = curr_mod._module_name;
216 cerr <<
"Caught exception during module termination: " << e.
get_message() << endl;
219 cerr <<
"Caught unknown exception during terminate" << endl;
235 strm <<
BESIndent::LMarg <<
"BESModuleApp::dump - (" << (
void *)
this <<
")" << endl;
237 if (_module_list.size()) {
240 list<bes_module>::const_iterator i = _module_list.begin();
241 list<bes_module>::const_iterator e = _module_list.end();
242 for (; i != e; i++) {
243 bes_module curr_mod = *i;
244 strm <<
BESIndent::LMarg << curr_mod._module_name <<
": " << curr_mod._module_library << endl;
virtual ~BESModuleApp(void)
Default destructor.
virtual int initialize(int argC, char **argV)
initialize the BES application
Base application object for all BES applications.
virtual void dump(ostream &strm) const
dumps information about this object
virtual int terminate(int sig=0)
clean up after the application
virtual void terminate(const string &modname)=0
virtual string get_message()
get the error message for this exception
virtual void initialize(const string &modname)=0
Abstract exception class for the BES with basic string message.
static ostream & LMarg(ostream &strm)
static void explode(char delim, const string &str, list< string > &values)
explode a string into an array given a delimiter
C * get(const string &name)
Use the BESPlugingFactory to get an instance of the class C matched to 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)
Add a mapping of name to library_name to the BESPluginFactory.
void get_values(const string &s, vector< string > &vals, bool &found)
Retrieve the values of a given key, if set.
static BESKeys * TheKeys()