bes  Updated for version 3.19.1
DapFunctionsRequestHandler.cc
1 // -*- mode: c++; c-basic-offset:4 -*-
2 //
3 // DapFunctionsRequestHandler.cc
4 //
5 // This file is part of BES DAP Functions module
6 //
7 // Copyright (c) 2016 OPeNDAP, Inc.
8 // Author: James Gallagher <jgallagher@opendap.org>
9 //
10 // This library is free software; you can redistribute it and/or
11 // modify it under the terms of the GNU Lesser General Public
12 // License as published by the Free Software Foundation; either
13 // version 2.1 of the License, or (at your option) any later version.
14 //
15 // This library is distributed in the hope that it will be useful,
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 // Lesser General Public License for more details.
19 //
20 // You should have received a copy of the GNU Lesser General Public
21 // License along with this library; if not, write to the Free Software
22 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23 //
24 // You can contact OPeNDAP, Inc. at PO Box 112, Saunderstown, RI. 02874-0112.
25 
26 #include "config.h"
27 
28 #include "BESResponseHandler.h" // Used to access the DataHandlerInterface
29 #include "BESResponseNames.h" // for {HELP,VER}_RESPONSE constants
30 #include "BESDataHandlerInterface.h" // Used to get the Info object
31 #include "BESVersionInfo.h" // Includes BESInfo too
32 
33 #include "TheBESKeys.h" // A BES Key can be used to supply help info
34 
35 #include "DapFunctionsRequestHandler.h"
36 
46  BESRequestHandler(name)
47 {
50 }
51 
60 {
61  BESResponseObject *response = dhi.response_handler->get_response_object();
62  BESInfo *info = dynamic_cast<BESInfo *>(response);
63  if (!info) throw BESInternalError("cast error", __FILE__, __LINE__);
64 
65  bool found = false;
66  string key = "BES.functions.Reference";
67  string ref;
68  TheBESKeys::TheKeys()->get_value(key, ref, found);
69  if (ref.empty()) ref = "http://docs.opendap.org/index.php/Server_Side_Processing_Functions";
70 
71  map<string, string> attrs;
72  attrs["name"] = MODULE_NAME;
73  attrs["version"] = MODULE_VERSION;
74  attrs["reference"] = ref;
75 
76  info->begin_tag("module", &attrs);
77  info->end_tag("module");
78 
79  return true;
80 }
81 
90 {
91  BESResponseObject *response = dhi.response_handler->get_response_object();
92  BESVersionInfo *info = dynamic_cast<BESVersionInfo *>(response);
93  if (!info) throw BESInternalError("cast error", __FILE__, __LINE__);
94 
95  info->add_module(MODULE_NAME, MODULE_VERSION);
96 
97  return true;
98 }
99 
106 void DapFunctionsRequestHandler::dump(ostream &strm) const
107 {
108  strm << BESIndent::LMarg << "DapFunctionsRequestHandler::dump - (" << (void *) this << ")" << endl;
109  BESIndent::Indent();
111  BESIndent::UnIndent();
112 }
113 
exception thrown if inernal error encountered
DapFunctionsRequestHandler(const std::string &name)
Constructor for FileOut NetCDF module.
void get_value(const string &s, string &val, bool &found)
Retrieve the value of a given key, if set.
Definition: TheBESKeys.cc:422
informational response object
Definition: BESInfo.h:68
static bool build_help(BESDataHandlerInterface &dhi)
Provides information for the DAP functions help request.
virtual BESResponseObject * get_response_object()
return the current response object
static TheBESKeys * TheKeys()
Definition: TheBESKeys.cc:62
Represents a specific data type request handler.
virtual void dump(std::ostream &strm) const
dumps information about this object
static bool build_version(BESDataHandlerInterface &dhi)
add version information to a version response
virtual void dump(ostream &strm) const
dumps information about this object
Structure storing information used by the BES to handle the request.
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
Abstract base class representing a specific set of information in response to a request to the BES.