SampleModule.cc
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 #include <iostream>
00034
00035 using std::endl ;
00036
00037 #include "SampleModule.h"
00038 #include "BESRequestHandlerList.h"
00039 #include "SampleRequestHandler.h"
00040 #include "BESDebug.h"
00041 #include "BESResponseHandlerList.h"
00042 #include "BESResponseNames.h"
00043 #include "BESXMLCommand.h"
00044 #include "SampleResponseNames.h"
00045 #include "SampleSayResponseHandler.h"
00046 #include "SampleSayXMLCommand.h"
00047 #include "BESReporterList.h"
00048 #include "SayReporter.h"
00049
00050 void
00051 SampleModule::initialize( const string &modname )
00052 {
00053 BESDEBUG( modname, "Initializing Sample Module " << modname << endl )
00054
00055 BESDEBUG( modname, " adding " << modname << " request handler" << endl )
00056 BESRequestHandlerList::TheList()->add_handler( modname, new SampleRequestHandler( modname ) ) ;
00057
00058
00059
00060 string cmd_name ;
00061
00062 BESDEBUG( modname, " adding " << SAY_RESPONSE << " response handler" << endl )
00063 BESResponseHandlerList::TheList()->add_handler( SAY_RESPONSE, SampleSayResponseHandler::SampleSayResponseBuilder ) ;
00064
00065 cmd_name = SAY_RESPONSE ;
00066 BESDEBUG( modname, " adding " << cmd_name << " command" << endl )
00067 BESXMLCommand::add_command( cmd_name, SampleSayXMLCommand::CommandBuilder ) ;
00068
00069 BESDEBUG( "say", " adding Say reporter" << endl )
00070 BESReporterList::TheList()->add_reporter( modname, new SayReporter ) ;
00071
00072
00073
00074 BESDEBUG( modname, " adding Sample debug context" << endl )
00075 BESDebug::Register( modname ) ;
00076
00077 BESDEBUG( modname, "Done Initializing Sample Module " << modname << endl )
00078 }
00079
00080 void
00081 SampleModule::terminate( const string &modname )
00082 {
00083 BESDEBUG( modname, "Cleaning Sample module " << modname << endl )
00084
00085 BESDEBUG( modname, " removing " << modname << " request handler" << endl )
00086 BESRequestHandler *rh = BESRequestHandlerList::TheList()->remove_handler( modname ) ;
00087 if( rh ) delete rh ;
00088
00089
00090
00091 string cmd_name ;
00092
00093 BESDEBUG( modname, " removing " << SAY_RESPONSE << " response handler" << endl )
00094 BESResponseHandlerList::TheList()->remove_handler( SAY_RESPONSE ) ;
00095
00096 cmd_name = SAY_RESPONSE ;
00097 BESDEBUG( modname, " removing " << cmd_name << " command" << endl )
00098 BESXMLCommand::del_command( cmd_name ) ;
00099
00100
00101 BESDEBUG( modname, "Done Cleaning Sample module " << modname << endl )
00102 }
00103
00104 extern "C"
00105 {
00106 BESAbstractModule *maker()
00107 {
00108 return new SampleModule ;
00109 }
00110 }
00111
00112 void
00113 SampleModule::dump( ostream &strm ) const
00114 {
00115 strm << BESIndent::LMarg << "SampleModule::dump - ("
00116 << (void *)this << ")" << endl ;
00117 }
00118