bes Updated for version 3.21.1
The Backend Server (BES) is the lower two tiers of the Hyrax data server
SampleRequestHandler.cc
1// SampleRequestHandler.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., 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 "config.h"
34
35#include "BESResponseHandler.h"
36#include "BESResponseNames.h"
37#include "BESVersionInfo.h"
38#include "BESTextInfo.h"
39#include "BESConstraintFuncs.h"
40#include "BESInternalError.h"
41
42#include "SampleRequestHandler.h"
43#include "SampleResponseNames.h"
44
45using std::endl;
46using std::ostream;
47using std::string;
48using std::map;
49
50SampleRequestHandler::SampleRequestHandler(const string &name) :
52{
53 add_method( VERS_RESPONSE, SampleRequestHandler::sample_build_vers);
54 add_method( HELP_RESPONSE, SampleRequestHandler::sample_build_help);
55}
56
57SampleRequestHandler::~SampleRequestHandler()
58{
59}
60
61bool SampleRequestHandler::sample_build_vers(BESDataHandlerInterface &dhi)
62{
63 bool ret = true;
64
65 BESResponseObject *response = dhi.response_handler->get_response_object();
66 BESVersionInfo *info = dynamic_cast<BESVersionInfo *>(response);
67 if (!info) throw BESInternalError("cast error", __FILE__, __LINE__);
68 info->add_module( PACKAGE_NAME, PACKAGE_VERSION);
69
70 return ret;
71}
72
73bool SampleRequestHandler::sample_build_help(BESDataHandlerInterface &dhi)
74{
75 bool ret = true;
76
77 BESResponseObject *response = dhi.response_handler->get_response_object();
78 BESInfo *info = dynamic_cast<BESInfo *>(response);
79 if (!info) throw BESInternalError("cast error", __FILE__, __LINE__);
80
81 map<string, string, std::less<>> attrs;
82 attrs["name"] = PACKAGE_NAME;
83 attrs["version"] = PACKAGE_VERSION;
84 info->begin_tag("module", &attrs);
85 info->add_data_from_file("Sample.Help", "Sample Help");
86 info->end_tag("module");
87
88 return ret;
89}
90
91void SampleRequestHandler::dump(ostream &strm) const
92{
93 strm << BESIndent::LMarg << "SampleRequestHandler::dump - (" << (void *) this << ")" << endl;
94 BESIndent::Indent();
96 BESIndent::UnIndent();
97}
98
Structure storing information used by the BES to handle the request.
virtual void add_data_from_file(const std::string &key, const std::string &name)
add data from a file to the informational object.
Definition BESInfo.cc:172
Represents a specific data type request handler.
virtual void dump(std::ostream &strm) const
dumps information about this object
virtual BESResponseObject * get_response_object()
return the current response object
virtual void dump(std::ostream &strm) const
dumps information about this object