CSVModule.cc

Go to the documentation of this file.
00001 // CSVModule.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: Stephan Zednik <zednik@ucar.edu> and Patrick West <pwest@ucar.edu>
00008 // and Jose Garcia <jgarcia@ucar.edu>
00009 //
00010 // This library is free software; you can redistribute it and/or
00011 // modify it under the terms of the GNU Lesser General Public
00012 // License as published by the Free Software Foundation; either
00013 // version 2.1 of the License, or (at your option) any later version.
00014 // 
00015 // This library is distributed in the hope that it will be useful,
00016 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00018 // Lesser General Public License for more details.
00019 // 
00020 // You should have received a copy of the GNU Lesser General Public
00021 // License along with this library; if not, write to the Free Software
00022 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00023 //
00024 // You can contact University Corporation for Atmospheric Research at
00025 // 3080 Center Green Drive, Boulder, CO 80301
00026  
00027 // (c) COPYRIGHT University Corporation for Atmospheric Research 2004-2005
00028 // Please read the full copyright statement in the file COPYRIGHT_UCAR.
00029 //
00030 // Authors:
00031 //      zednik      Stephan Zednik <zednik@ucar.edu>
00032 //      pwest       Patrick West <pwest@ucar.edu>
00033 //      jgarcia     Jose Garcia <jgarcia@ucar.edu>
00034 
00035 #include <iostream>
00036 
00037 using std::endl ;
00038 
00039 #include "CSVModule.h"
00040 #include "BESRequestHandlerList.h"
00041 #include "CSVRequestHandler.h"
00042 #include "BESLog.h"
00043 #include "BESResponseHandlerList.h"
00044 #include "BESResponseNames.h"
00045 #include "CSVResponseNames.h"
00046 
00047 #include "BESContainerStorageList.h"
00048 #include "BESContainerStorageCatalog.h"
00049 #include "BESCatalogDirectory.h"
00050 #include "BESCatalogList.h"
00051 
00052 #include "BESDebug.h"
00053 
00054 void
00055 CSVModule::initialize( const string &modname )
00056 {
00057     BESDEBUG( "csv", "Initializing CSV Module " << modname << endl )
00058 
00059     BESDEBUG( "csv", "    adding " << modname << " request handler" << endl )
00060     BESRequestHandlerList::TheList()->
00061         add_handler( modname, new CSVRequestHandler( modname ) ) ;
00062 
00063     BESDEBUG( "csv", "    adding " << CSV_CATALOG << " catalog" << endl )
00064     if( !BESCatalogList::TheCatalogList()->find_catalog( CSV_CATALOG ) )
00065     {
00066         BESCatalogList::TheCatalogList()->
00067             add_catalog(new BESCatalogDirectory( CSV_CATALOG ) ) ;
00068     }
00069     else
00070     {
00071         BESDEBUG( "csv", "    catalog already exists, skipping" << endl )
00072     }
00073 
00074     BESDEBUG( "csv", "    adding Catalog Container Storage" << endl )
00075     if( !BESContainerStorageList::TheList()->find_persistence( CSV_CATALOG ) )
00076     {
00077         BESContainerStorageList::TheList()->
00078             add_persistence( new BESContainerStorageCatalog( CSV_CATALOG ) ) ;
00079     }
00080     else
00081     {
00082         BESDEBUG( "csv", "    storage already exists, skipping" << endl )
00083     }
00084 
00085     BESDEBUG( "csv", "    adding csv debug context" << endl )
00086     BESDebug::Register( "csv" ) ;
00087 
00088     BESDEBUG( "csv", "Done Initializing CSV Handler " << modname << endl )
00089 }
00090 
00091 void
00092 CSVModule::terminate( const string &modname )
00093 {
00094     BESDEBUG( "csv", "Cleaning CSV Module" << modname << endl )
00095 
00096     BESDEBUG( "csv", "    removing " << modname << " request handler" << endl )
00097     BESRequestHandler *rh = BESRequestHandlerList::TheList()->remove_handler( modname ) ;
00098     if( rh ) delete rh ;
00099     
00100     BESDEBUG( "csv", "    removing catalog container storage" << CSV_CATALOG << endl )
00101     BESContainerStorageList::TheList()->del_persistence( CSV_CATALOG ) ;
00102 
00103     BESDEBUG( "csv", "    removing " << CSV_CATALOG << " catalog" << endl )
00104     BESCatalogList::TheCatalogList()->del_catalog( CSV_CATALOG ) ;
00105 
00106     BESDEBUG( "csv", "Done Cleaning CSV Module" << modname << endl )
00107 }
00108 
00109 extern "C"
00110 {
00111     BESAbstractModule *maker()
00112     {
00113         return new CSVModule ;
00114     }
00115 }
00116 
00117 void
00118 CSVModule::dump( ostream &strm ) const
00119 {
00120     strm << BESIndent::LMarg << "CSVModule::dump - ("
00121                              << (void *)this << ")" << endl ;
00122 }
00123 

Generated on Sat Aug 22 06:06:27 2009 for OPeNDAP Hyrax Back End Server (BES) by  doxygen 1.6.0