bes  Updated for version 3.20.5
BESAsciiRequestHandler.cc
1 // BESAsciiRequestHandler.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,2005 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 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 "BESAsciiRequestHandler.h"
34 #include "BESResponseHandler.h"
35 #include "BESResponseNames.h"
36 #include "BESVersionInfo.h"
37 #include "BESDataNames.h"
38 #include "config.h"
39 
40 BESAsciiRequestHandler::BESAsciiRequestHandler(const string &name) :
41  BESRequestHandler(name)
42 {
43  add_method(HELP_RESPONSE, BESAsciiRequestHandler::dap_build_help);
44  add_method(VERS_RESPONSE, BESAsciiRequestHandler::dap_build_version);
45 }
46 
47 BESAsciiRequestHandler::~BESAsciiRequestHandler()
48 {
49 }
50 
51 bool BESAsciiRequestHandler::dap_build_help(BESDataHandlerInterface &)
52 {
53  // the usage request handler is already loading this and, since all
54  // three dap-server modules are usually loaded, we'll assume it's
55  // already taken care of
56 
57  return true;
58 }
59 
60 bool BESAsciiRequestHandler::dap_build_version(BESDataHandlerInterface &dhi)
61 {
62  BESResponseObject *response = dhi.response_handler->get_response_object();
63  BESVersionInfo *info = dynamic_cast<BESVersionInfo *>(response);
64  if (!info)
65  throw BESInternalError("cast error", __FILE__, __LINE__);
66 
67  info->add_module(MODULE_NAME, MODULE_VERSION);
68 
69  return true;
70 }
71 
78 void BESAsciiRequestHandler::dump(ostream &strm) const
79 {
80  strm << BESIndent::LMarg << "BESAsciiRequestHandler::dump - (" << (void *) this << ")" << endl;
81  BESIndent::Indent();
83  BESIndent::UnIndent();
84 }
85 
BESRequestHandler
Represents a specific data type request handler.
Definition: BESRequestHandler.h:77
BESResponseHandler::get_response_object
virtual BESResponseObject * get_response_object()
return the current response object
Definition: BESResponseHandler.cc:78
BESVersionInfo
Definition: BESVersionInfo.h:47
BESAsciiRequestHandler::dump
virtual void dump(ostream &strm) const
dumps information about this object
Definition: BESAsciiRequestHandler.cc:78
BESInternalError
exception thrown if inernal error encountered
Definition: BESInternalError.h:43
BESRequestHandler::dump
virtual void dump(ostream &strm) const
dumps information about this object
Definition: BESRequestHandler.cc:124
BESDataHandlerInterface
Structure storing information used by the BES to handle the request.
Definition: BESDataHandlerInterface.h:60
BESResponseObject
Abstract base class representing a specific set of information in response to a request to the BES.
Definition: BESResponseObject.h:51