bes  Updated for version 3.20.13
BESDataHandlerInterface.h
1 // BESDataHandlerInterface.h
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 #ifndef BESDataHandlerInterface_h_
34 #define BESDataHandlerInterface_h_ 1
35 
36 #include <string>
37 #include <list>
38 #include <map>
39 #include <iostream>
40 
41 class BESResponseHandler;
42 class BESResponseObject;
43 class BESInfo;
44 
45 #include "BESObj.h"
46 #include "BESContainer.h"
47 #include "BESInternalError.h"
48 #include "BESResponseHandler.h"
49 
57 private:
58  std::ostream *output_stream;
59 
60  // I tried adding a complete 'clone the dhi' method to see if that
61  // would address the problem we're seeing on OSX 10.9. It didn't but
62  // we're not done yet, so maybe this will be useful still. jhrg 4/16/14
63  void clone(const BESDataHandlerInterface &copy_from);
64 
65 public:
66  typedef std::map<std::string, std::string>::const_iterator data_citer;
67 
68  BESResponseHandler *response_handler;
69 
70  std::list<BESContainer *> containers;
71  std::list<BESContainer *>::iterator containers_iterator;
72 
76 
79  std::string action;
80  std::string action_name;
81  bool executed;
82 
85  std::string transmit_protocol; // FIXME Not used? jhrg 5/30/18
86 
90  std::map<std::string, std::string> data;
91 
95 
97  output_stream(0), response_handler(0), container(0), executed(false), error_info(0)
98  {
99  }
100 
101  // These were causing multiple compiler warnings, so I removed the implementations since
102  // it's clear they are private to be disallowed from auto generation for now
103  // and this just not declaring an impl solves it. (mpj 2/26/10)
104  //
105  // I implemented these - and made clone() private, since that's a more common pattern.
106  // jhrg 4/18/14
108  BESDataHandlerInterface & operator=(const BESDataHandlerInterface &rhs);
109 
110  // Added 5/11/22 based on valgrind output. jhrg
111  ~BESDataHandlerInterface() override {
112  clean();
113  }
114 
116  void make_copy(const BESDataHandlerInterface &copy_from);
117 
118  void clean();
119 
120  void set_output_stream(std::ostream *strm)
121  {
122  if (output_stream) {
123  std::string err = "output stream has already been set";
124  throw BESInternalError(err, __FILE__, __LINE__);
125  }
126  output_stream = strm;
127  }
128 
129  std::ostream &get_output_stream()
130  {
131  if (!output_stream)
132  throw BESInternalError("output stream has not yet been set, cannot use", __FILE__, __LINE__);
133  return *output_stream;
134  }
135 
137 
141  {
142  containers_iterator = containers.begin();
143  if (containers_iterator != containers.end())
144  container = (*containers_iterator);
145  else
146  container = NULL;
147  }
148 
152  {
153  containers_iterator++;
154  if (containers_iterator != containers.end())
155  container = (*containers_iterator);
156  else
157  container = NULL;
158  }
159 
160  const std::map<std::string, std::string> &data_c() const
161  {
162  return data;
163  }
164 
165  void dump(std::ostream &strm) const override;
166 };
167 
168 #endif // BESDataHandlerInterface_h_
A container is something that holds data. E.G., a netcdf file or a database entry.
Definition: BESContainer.h:65
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
void first_container()
set the container pointer to the first container in the containers list
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
void next_container()
set the container pointer to the next * container in the list, null if at the end or no containers in...
informational response object
Definition: BESInfo.h:63
exception thrown if internal error encountered
top level BES object to house generic methods
Definition: BESObj.h:54
handler object that knows how to create a specific response object
Abstract base class representing a specific set of information in response to a request to the BES.