bes  Updated for version 3.20.5
BESXDRequestHandler.cc
1 // BESXDRequestHandler.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 // Authors:
27 // pwest Patrick West <pwest@ucar.edu>
28 // jgarcia Jose Garcia <jgarcia@ucar.edu>
29 
30 #include "config.h"
31 
32 #include <BESResponseHandler.h>
33 #include <BESResponseNames.h>
34 #include <BESVersionInfo.h>
35 #include <BESDataNames.h>
36 
37 #include "BESXDRequestHandler.h"
38 
39 BESXDRequestHandler::BESXDRequestHandler(const string &name) :
40  BESRequestHandler(name)
41 {
42  add_method(HELP_RESPONSE, BESXDRequestHandler::dap_build_help);
43  add_method(VERS_RESPONSE, BESXDRequestHandler::dap_build_version);
44 }
45 
46 BESXDRequestHandler::~BESXDRequestHandler()
47 {
48 }
49 
50 bool BESXDRequestHandler::dap_build_help(BESDataHandlerInterface &dhi)
51 {
52  BESResponseObject *response = dhi.response_handler->get_response_object();
53  BESInfo *info = dynamic_cast<BESInfo *>(response);
54  if (!info)
55  throw BESInternalError("cast error", __FILE__, __LINE__);
56 
57  map < string, string > attrs;
58  attrs["name"] = MODULE_NAME ;
59  attrs["version"] = MODULE_VERSION ;
60 #if 0
61  attrs["name"] = PACKAGE_NAME;
62  attrs["version"] = PACKAGE_VERSION;
63 #endif
64  info->begin_tag("module", &attrs);
65  info->end_tag("module");
66 
67  return true;
68 }
69 
70 bool BESXDRequestHandler::dap_build_version(BESDataHandlerInterface &dhi)
71 {
72  BESResponseObject *response = dhi.response_handler->get_response_object();
73  BESVersionInfo *info = dynamic_cast<BESVersionInfo *>(response);
74  if (!info)
75  throw BESInternalError("cast error", __FILE__, __LINE__);
76 
77 #if 0
78  info->add_module(PACKAGE_NAME, PACKAGE_VERSION);
79 #endif
80  info->add_module(MODULE_NAME, MODULE_VERSION);
81 
82  return true;
83 }
84 
91 void BESXDRequestHandler::dump(ostream &strm) const
92 {
93  strm << BESIndent::LMarg << "BESXDRequestHandler::dump - (" << (void *) this << ")" << endl;
94  BESIndent::Indent();
96  BESIndent::UnIndent();
97 }
98 
exception thrown if inernal error encountered
informational response object
Definition: BESInfo.h:68
virtual BESResponseObject * get_response_object()
return the current response object
virtual void dump(ostream &strm) const
dumps information about this object
Represents a specific data type request handler.
virtual void dump(ostream &strm) const
dumps information about this object
Structure storing information used by the BES to handle the request.
Abstract base class representing a specific set of information in response to a request to the BES.