bes Updated for version 3.21.1
The Backend Server (BES) is the lower two tiers of the Hyrax data server
BESDataHandlerInterface.cc
1// BESDataHandlerInterface.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 "BESDataHandlerInterface.h"
34#include "BESContainer.h"
35#include "BESResponseHandler.h"
36#include "BESInfo.h"
37#include "BESIndent.h"
38
39using std::endl;
40using std::list;
41using std::ostream;
42
58void BESDataHandlerInterface::make_copy(const BESDataHandlerInterface &copy_from)
59{
60 clone(copy_from);
61}
62
72void BESDataHandlerInterface::clone(const BESDataHandlerInterface &copy_from)
73{
74#if 0
75 // Added because this can be called from make_copy() which is public.
76 // jhrg 4/18/14
77 // I removed this because I think it's bogus but having it here confuses
78 // coverity into thinking that parts of the object built be the copy ctor
79 // might be uninitialized. All of the NCML handler tests pass with this
80 // modification. jhrg 9/17/15
81 if (this == &copy_from)
82 return;
83#endif
84 output_stream = copy_from.output_stream;
85 response_handler = copy_from.response_handler;
86
87 containers = copy_from.containers;
88 containers_iterator = copy_from.containers_iterator;
89 container = copy_from.container;
90
91 action = copy_from.action;
92 action_name = copy_from.action_name;
93 executed = copy_from.executed;
94
96
97 // I do this because clang 5 (on OSX 10.9) will remove everything from 'data'
98 // if copy_from.data and 'data' are the same object. Since the ncml handler uses
99 // make_copy() and may be using a reference to a DHI and/or the DHI's 'data' map,
100 // I'm leaving the test in here. That is, it could be building a new DHI instance
101 // that uses a reference to an existing 'data' field and then assign the original
102 // DHI instance to the new one. The DHIs are different, but the 'data' map are
103 // not. jhrg 4/18/14
104 if (&data != &copy_from.data)
105 data = copy_from.data;
106
107 error_info = copy_from.error_info;
108}
109
110BESDataHandlerInterface::BESDataHandlerInterface(const BESDataHandlerInterface &from)
111{
112 clone(from);
113}
114
116BESDataHandlerInterface::operator=(const BESDataHandlerInterface &rhs)
117{
118 if (&rhs == this) {
119 return *this;
120 }
121
122 clone(rhs);
123
124 return *this;
125}
126
135{
136 if (response_handler) {
137 delete response_handler;
138 }
139 response_handler = nullptr;
140}
141
151{
152 BESResponseObject *response = 0;
153
154 if (response_handler) {
155 response = response_handler->get_response_object();
156 }
157 return response;
158}
159
167void BESDataHandlerInterface::dump(ostream &strm) const
168{
169 strm << BESIndent::LMarg << "BESDataHandlerInterface::dump" << endl;
170 BESIndent::Indent();
171 if (response_handler) {
172 strm << BESIndent::LMarg << "response handler:" << endl;
173 BESIndent::Indent();
174 response_handler->dump(strm);
175 BESIndent::UnIndent();
176 }
177 else {
178 strm << BESIndent::LMarg << "response handler: not set" << endl;
179 }
180
181 if (container) {
182 strm << BESIndent::LMarg << "current container:" << endl;
183 BESIndent::Indent();
184 container->dump(strm);
185 BESIndent::UnIndent();
186 }
187 else {
188 strm << BESIndent::LMarg << "current container: not set" << endl;
189 }
190
191 if (containers.size()) {
192 strm << BESIndent::LMarg << "container list:" << endl;
193 BESIndent::Indent();
194 list<BESContainer *>::const_iterator i = containers.begin();
195 list<BESContainer *>::const_iterator ie = containers.end();
196 for (; i != ie; i++) {
197 (*i)->dump(strm);
198 }
199 BESIndent::UnIndent();
200 }
201 else {
202 strm << BESIndent::LMarg << "container list: empty" << endl;
203 }
204
205 strm << BESIndent::LMarg << "action: " << action << endl;
206 strm << BESIndent::LMarg << "action name: " << action_name << endl;
207 strm << BESIndent::LMarg << "transmit protocol: " << transmit_protocol << endl;
208 if (data.size()) {
209 strm << BESIndent::LMarg << "data:" << endl;
210 BESIndent::Indent();
211 data_citer i = data.begin();
212 data_citer ie = data.end();
213 for (; i != ie; i++) {
214 strm << BESIndent::LMarg << (*i).first << ": " << (*i).second << endl;
215 }
216 BESIndent::UnIndent();
217 }
218 else {
219 strm << BESIndent::LMarg << "data: none" << endl;
220 }
221
222 if (error_info) {
223 strm << BESIndent::LMarg << "error info:" << endl;
224 BESIndent::Indent();
225 error_info->dump(strm);
226 BESIndent::UnIndent();
227 }
228 else {
229 strm << BESIndent::LMarg << "error info: null" << endl;
230 }
231 BESIndent::UnIndent();
232}
233
Structure storing information used by the BES to handle the request.
std::string transmit_protocol
request protocol, such as HTTP
void make_copy(const BESDataHandlerInterface &copy_from)
deprecated
std::map< std::string, std::string > data
the map of string data that will be required for the current request.
std::string action
the response object requested, e.g. das, dds
void clean()
clean up any information created within this data handler interface
void dump(std::ostream &strm) const override
dumps information about this object
BESContainer * container
pointer to current container in this interface
BESResponseObject * get_response_object()
returns the response object using the response handler
BESInfo * error_info
error information object
Abstract base class representing a specific set of information in response to a request to the BES.
STL iterator class.