bes  Updated for version 3.17.0
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 using std::string;
42 using std::list;
43 using std::map;
44 using std::ostream;
45 
46 class BESResponseHandler;
47 class BESResponseObject;
48 class BESInfo;
49 
50 #include "BESObj.h"
51 #include "BESContainer.h"
52 #include "BESInternalError.h"
53 
61 private:
62  ostream *output_stream;
63 
64  // I tried adding a complete 'clone the dhi' method to see if that
65  // would address the problem we're seeing on OSX 10.9. It didn't but
66  // we're not done yet, so maybe this will be useful still. jhrg 4/16/14
67  void clone(const BESDataHandlerInterface &copy_from);
68 
69 public:
70  typedef map<string, string>::const_iterator data_citer;
71 
72  BESResponseHandler *response_handler;
73 
74  list<BESContainer *> containers;
75  list<BESContainer *>::iterator containers_iterator;
76 
80 
83  string action;
84  string action_name;
85  bool executed;
86 
90 
94  map<string, string> data;
95 
99 
101  output_stream(0), response_handler(0), container(0), executed(false), error_info(0)
102  {
103  }
104 
105  // These were causing multiple compiler warnings, so I removed the implementations since
106  // it's clear they are private to be disallowed from auto generation for now
107  // and this just not declaring an impl solves it. (mpj 2/26/10)
108  //
109  // I implemented these - and made clone() private, since that's a more common pattern.
110  // jhrg 4/18/14
112  BESDataHandlerInterface & operator=(const BESDataHandlerInterface &rhs);
113 
115  void make_copy(const BESDataHandlerInterface &copy_from);
116 
117  void clean();
118 
119  void set_output_stream(ostream *strm)
120  {
121  if (output_stream) {
122  string err = "output stream has already been set";
123  throw BESInternalError(err, __FILE__, __LINE__);
124  }
125  output_stream = strm;
126  }
127 
128  ostream &get_output_stream()
129  {
130  if (!output_stream)
131  throw BESInternalError("output stream has not yet been set, cannot use", __FILE__, __LINE__);
132  return *output_stream;
133  }
134 
136 
140  {
141  containers_iterator = containers.begin();
142  if (containers_iterator != containers.end())
143  container = (*containers_iterator);
144  else
145  container = NULL;
146  }
147 
151  {
152  containers_iterator++;
153  if (containers_iterator != containers.end())
154  container = (*containers_iterator);
155  else
156  container = NULL;
157  }
158 
159  const map<string, string> &data_c() const
160  {
161  return data;
162  }
163 
164  void dump(ostream &strm) const;
165 };
166 
167 #endif // BESDataHandlerInterface_h_
void clean()
clean up any information created within this data handler interface
void dump(ostream &strm) const
dumps information about this object
exception thrown if inernal error encountered
void next_container()
set the container pointer to the next * container in the list, null if at the end or no containers in...
void make_copy(const BESDataHandlerInterface &copy_from)
deprecated
Base object for bes objects.
Definition: BESObj.h:52
handler object that knows how to create a specific response object
informational response object
Definition: BESInfo.h:68
BESResponseObject * get_response_object()
returns the response object using the response handler
string transmit_protocol
request protocol, such as HTTP
Structure storing information used by the BES to handle the request.
map< string, string > data
the map of string data that will be required for the current request.
void first_container()
set the container pointer to the first container in the containers list
BESInfo * error_info
error information object
A container is something that holds data. I.E. a netcdf file or a database entry. ...
Definition: BESContainer.h:60
Abstract base class representing a specific set of information in response to a request to the BES...
string action
the response object requested, e.g. das, dds
BESContainer * container
pointer to current container in this interface