BESFilterTransmitter.cc

Go to the documentation of this file.
00001 // BESFilterTransmitter.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,2005 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 "BESFilterTransmitter.h"
00034 #include "DODSFilter.h"
00035 #include "BESInfo.h"
00036 #include "BESDASResponse.h"
00037 #include "BESDDSResponse.h"
00038 #include "BESDataDDSResponse.h"
00039 #include "BESDataNames.h"
00040 #include "BESTransmitter.h"
00041 #include "BESReturnManager.h"
00042 #include "BESTransmitterNames.h"
00043 #include "cgi_util.h"
00044 
00045 #define DAS_TRANSMITTER "das"
00046 #define DDS_TRANSMITTER "dds"
00047 #define DDX_TRANSMITTER "ddx"
00048 #define DATA_TRANSMITTER "data"
00049 
00050 BESFilterTransmitter *BESFilterTransmitter::Transmitter = 0 ;
00051 
00052 BESFilterTransmitter::BESFilterTransmitter( DODSFilter &df )
00053     : _df( &df )
00054 {
00055     BESFilterTransmitter::Transmitter = this ;
00056 
00057     add_method( DAS_TRANSMITTER, BESFilterTransmitter::send_basic_das ) ;
00058     add_method( DDS_TRANSMITTER, BESFilterTransmitter::send_basic_dds ) ;
00059     add_method( DDX_TRANSMITTER, BESFilterTransmitter::send_basic_ddx ) ;
00060     add_method( DATA_TRANSMITTER, BESFilterTransmitter::send_basic_data);
00061 }
00062 
00063 void
00064 BESFilterTransmitter::send_text( BESInfo &info,
00065                                  BESDataHandlerInterface &dhi )
00066 {
00067     if( info.is_buffered() )
00068     {
00069         set_mime_text( dhi.get_output_stream(), unknown_type ) ;
00070         info.print( dhi.get_output_stream() ) ;
00071     }
00072 }
00073 
00074 void
00075 BESFilterTransmitter::send_html( BESInfo &info,
00076                                  BESDataHandlerInterface &dhi )
00077 {
00078     if( info.is_buffered() )
00079     {
00080         set_mime_html( dhi.get_output_stream(), unknown_type ) ;
00081         info.print( dhi.get_output_stream() ) ;
00082     }
00083 }
00084 
00085 void
00086 BESFilterTransmitter::send_basic_das( BESResponseObject *obj,
00087                                       BESDataHandlerInterface &dhi )
00088 {
00089     BESDASResponse *bdas = dynamic_cast < BESDASResponse * >(obj);
00090     DAS *das = bdas->get_das();
00091     BESFilterTransmitter::Transmitter->get_filter()->send_das( dhi.get_output_stream(), *das ) ;
00092 }
00093 
00094 void
00095 BESFilterTransmitter::send_basic_dds( BESResponseObject *obj,
00096                                       BESDataHandlerInterface &dhi )
00097 {
00098     BESDDSResponse *bdds = dynamic_cast < BESDDSResponse * >(obj);
00099     DDS *dds = bdds->get_dds();
00100     ConstraintEvaluator & ce = bdds->get_ce();
00101     dhi.first_container();
00102     BESFilterTransmitter::Transmitter->get_filter()->set_ce( dhi.data[POST_CONSTRAINT] ) ;
00103     BESFilterTransmitter::Transmitter->get_filter()->send_dds( dhi.get_output_stream(), *dds, ce, true ) ;
00104 }
00105 
00106 void
00107 BESFilterTransmitter::send_basic_data( BESResponseObject *obj,
00108                                        BESDataHandlerInterface &dhi )
00109 {
00110     BESDataDDSResponse *bdds = dynamic_cast < BESDataDDSResponse * >(obj);
00111     DataDDS *dds = bdds->get_dds();
00112     ConstraintEvaluator & ce = bdds->get_ce();
00113     dhi.first_container();
00114     BESFilterTransmitter::Transmitter->get_filter()->set_ce( dhi.data[POST_CONSTRAINT] ) ;
00115     BESFilterTransmitter::Transmitter->get_filter()->send_data( *dds, ce, dhi.get_output_stream() ) ;
00116 }
00117 
00118 void
00119 BESFilterTransmitter::send_basic_ddx( BESResponseObject *obj,
00120                                       BESDataHandlerInterface &dhi )
00121 {
00122     BESDDSResponse *bdds = dynamic_cast < BESDDSResponse * >(obj);
00123     DDS *dds = bdds->get_dds();
00124     ConstraintEvaluator &ce = bdds->get_ce();
00125     dhi.first_container();
00126     BESFilterTransmitter::Transmitter->get_filter()->set_ce( dhi.data[POST_CONSTRAINT] ) ;
00127     BESFilterTransmitter::Transmitter->get_filter()->send_ddx( *dds, ce, dhi.get_output_stream() ) ;
00128 }
00129 
00137 void
00138 BESFilterTransmitter::dump( ostream &strm ) const
00139 {
00140     strm << BESIndent::LMarg << "BESFilterTransmitter::dump - ("
00141                              << (void *)this << ")" << endl ;
00142     BESIndent::Indent() ;
00143     BESTransmitter::dump( strm ) ;
00144     BESIndent::UnIndent() ;
00145 }
00146 

Generated on Wed Jan 2 06:01:18 2008 for OPeNDAP Back End Server (BES) by  doxygen 1.5.4