OPeNDAP Hyrax Back End Server (BES)  Updated for version 3.8.3
BESDapRequestHandler.cc
Go to the documentation of this file.
1 // BESDapRequestHandler.cc
2 
3 // This file is part of bes, A C++ back-end server implementation framework
4 // for the OPeNDAP Data Access Protocol.
5 
6 // Copyright (c) 2004-2009 University Corporation for Atmospheric Research
7 // Author: Patrick West <pwest@ucar.edu> and Jose Garcia <jgarcia@ucar.edu>
8 //
9 // This library is free software; you can redistribute it and/or
10 // modify it under the terms of the GNU Lesser General Public
11 // License as published by the Free Software Foundation; either
12 // version 2.1 of the License, or (at your option) any later version.
13 //
14 // This library is distributed in the hope that it will be useful,
15 // but WITHOUT ANY WARRANTY; without even the implied warranty of
16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 // Lesser General Public License for more details.
18 //
19 // You should have received a copy of the GNU Lesser General Public
20 // License along with this library; if not, write to the Free Software
21 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 //
23 // You can contact University Corporation for Atmospheric Research at
24 // 3080 Center Green Drive, Boulder, CO 80301
25 
26 // (c) COPYRIGHT University Corporation for Atmospheric Research 2004-2005
27 // Please read the full copyright statement in the file COPYRIGHT_UCAR.
28 //
29 // Authors:
30 // pwest Patrick West <pwest@ucar.edu>
31 // jgarcia Jose Garcia <jgarcia@ucar.edu>
32 
33 #include <util.h>
34 
35 using namespace libdap ;
36 
37 #include "BESDapRequestHandler.h"
38 #include "BESResponseHandler.h"
39 #include "BESDapNames.h"
40 #include "BESResponseNames.h"
41 #include "BESVersionInfo.h"
42 
44  : BESRequestHandler( name )
45 {
48 }
49 
51 {
52 }
53 
54 bool
56 {
58  BESInfo *info = dynamic_cast < BESInfo * >(response) ;
59  if( !info )
60  throw BESInternalError( "cast error", __FILE__, __LINE__ ) ;
61 
62  map<string,string> attrs ;
63  attrs["name"] = libdap_name() ;
64  attrs["version"] = libdap_version() ;
65  info->begin_tag( "module", &attrs ) ;
66  info->add_data_from_file( "DAP.Help", "DAP Help" ) ;
67  info->end_tag( "module" ) ;
68 
69  return true ;
70 }
71 
72 bool
74 {
76  BESVersionInfo *info = dynamic_cast < BESVersionInfo * >(response) ;
77  if( !info )
78  throw BESInternalError( "cast error", __FILE__, __LINE__ ) ;
79 
80  info->add_library( libdap_name(), libdap_version() ) ;
81  list<string> versions ;
82  versions.push_back( "2.0" ) ;
83  versions.push_back( "3.0" ) ;
84  versions.push_back( "3.2" ) ;
85  info->add_service( OPENDAP_SERVICE, versions ) ;
86 
87  return true ;
88 }
89 
96 void
97 BESDapRequestHandler::dump( ostream &strm ) const
98 {
99  strm << BESIndent::LMarg << "BESDapRequestHandler::dump - ("
100  << (void *)this << ")" << endl ;
102  BESRequestHandler::dump( strm ) ;
104 }
105 
brief represents simple text information in a response object, such as version and help inforamtion...
virtual void dump(ostream &strm) const
dumps information about this object
exception thrown if inernal error encountered
virtual void add_data_from_file(const string &key, const string &name)
add data from a file to the informational object.
Definition: BESInfo.cc:192
#define OPENDAP_SERVICE
macros representing the default response objects handled
Definition: BESDapNames.h:52
BESDapRequestHandler(const string &name)
virtual void add_library(const string &n, const string &v)
static void Indent()
Definition: BESIndent.cc:38
#define HELP_RESPONSE
informational response object
Definition: BESInfo.h:68
static bool dap_build_version(BESDataHandlerInterface &dhi)
virtual BESResponseObject * get_response_object()
return the current response object
virtual ~BESDapRequestHandler(void)
BESResponseHandler * response_handler
virtual void begin_tag(const string &tag_name, map< string, string > *attrs=0)
Definition: BESInfo.cc:142
static ostream & LMarg(ostream &strm)
Definition: BESIndent.cc:73
Represents a specific data type request handler.
static bool dap_build_help(BESDataHandlerInterface &dhi)
virtual void dump(ostream &strm) const
dumps information about this object
Structure storing information used by the BES to handle the request.
virtual void add_service(const string &n, const list< string > &vers)
#define VERS_RESPONSE
virtual bool add_handler(const string &handler_name, p_request_handler handler_method)
add a handler method to the request handler that knows how to fill in a specific response object ...
static void UnIndent()
Definition: BESIndent.cc:44
Abstract base class representing a specific set of information in response to a request to the BES...
virtual void end_tag(const string &tag_name)
Definition: BESInfo.cc:149