SampleModule.cc

Go to the documentation of this file.
00001 // SampleModule.cc
00002 
00003 // This file is part of bes, A C++ back-end server implementation framework
00004 // for the OPeNDAP Data Access Protocol.
00005 
00006 // Copyright (c) 2004-2009 University Corporation for Atmospheric Research
00007 // Author: Patrick West <pwest@ucar.edu> and Jose Garcia <jgarcia@ucar.edu>
00008 //
00009 // This library is free software; you can redistribute it and/or
00010 // modify it under the terms of the GNU Lesser General Public
00011 // License as published by the Free Software Foundation; either
00012 // version 2.1 of the License, or (at your option) any later version.
00013 //
00014 // This library is distributed in the hope that it will be useful,
00015 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00016 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00017 // Lesser General Public License for more details.
00018 //
00019 // You should have received a copy of the GNU Lesser General Public
00020 // License along with this library; if not, write to the Free Software
00021 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00022 //
00023 // You can contact University Corporation for Atmospheric Research at
00024 // 3080 Center Green Drive, Boulder, CO 80301
00025 
00026 // (c) COPYRIGHT University Corporation for Atmospheric Research 2004-2005
00027 // Please read the full copyright statement in the file COPYRIGHT_UCAR.
00028 //
00029 // Authors:
00030 //      pwest       Patrick West <pwest@ucar.edu>
00031 //      jgarcia     Jose Garcia <jgarcia@ucar.edu>
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     // If new commands are needed, then let's declare this once here. If
00059     // not, then you can remove this line.
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     // INIT_END
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     // If new commands are needed, then let's declare this once here. If
00090     // not, then you can remove this line.
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     // TERM_END
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 

Generated on 18 Feb 2010 for OPeNDAP Hyrax Back End Server (BES) by  doxygen 1.6.1