bes  Updated for version 3.20.6
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 
111  void make_copy(const BESDataHandlerInterface &copy_from);
112 
113  void clean();
114 
115  void set_output_stream(std::ostream *strm)
116  {
117  if (output_stream) {
118  std::string err = "output stream has already been set";
119  throw BESInternalError(err, __FILE__, __LINE__);
120  }
121  output_stream = strm;
122  }
123 
124  std::ostream &get_output_stream()
125  {
126  if (!output_stream)
127  throw BESInternalError("output stream has not yet been set, cannot use", __FILE__, __LINE__);
128  return *output_stream;
129  }
130 
132 
136  {
137  containers_iterator = containers.begin();
138  if (containers_iterator != containers.end())
139  container = (*containers_iterator);
140  else
141  container = NULL;
142  }
143 
147  {
148  containers_iterator++;
149  if (containers_iterator != containers.end())
150  container = (*containers_iterator);
151  else
152  container = NULL;
153  }
154 
155  const std::map<std::string, std::string> &data_c() const
156  {
157  return data;
158  }
159 
160  void dump(std::ostream &strm) const;
161 };
162 
163 #endif // BESDataHandlerInterface_h_
BESDataHandlerInterface::container
BESContainer * container
pointer to current container in this interface
Definition: BESDataHandlerInterface.h:75
BESDataHandlerInterface::action
std::string action
the response object requested, e.g. das, dds
Definition: BESDataHandlerInterface.h:79
BESDataHandlerInterface::clean
void clean()
clean up any information created within this data handler interface
Definition: BESDataHandlerInterface.cc:134
BESDataHandlerInterface::next_container
void next_container()
set the container pointer to the next * container in the list, null if at the end or no containers in...
Definition: BESDataHandlerInterface.h:146
BESDataHandlerInterface::transmit_protocol
std::string transmit_protocol
request protocol, such as HTTP
Definition: BESDataHandlerInterface.h:85
BESInfo
informational response object
Definition: BESInfo.h:63
BESDataHandlerInterface::make_copy
void make_copy(const BESDataHandlerInterface &copy_from)
deprecated
Definition: BESDataHandlerInterface.cc:58
BESDataHandlerInterface::get_response_object
BESResponseObject * get_response_object()
returns the response object using the response handler
Definition: BESDataHandlerInterface.cc:150
BESObj
top level BES object to house generic methods
Definition: BESObj.h:49
BESDataHandlerInterface::data
std::map< std::string, std::string > data
the map of string data that will be required for the current request.
Definition: BESDataHandlerInterface.h:90
BESInternalError
exception thrown if internal error encountered
Definition: BESInternalError.h:43
BESResponseHandler
handler object that knows how to create a specific response object
Definition: BESResponseHandler.h:77
BESDataHandlerInterface::dump
void dump(std::ostream &strm) const
dumps information about this object
Definition: BESDataHandlerInterface.cc:167
BESContainer
A container is something that holds data. E.G., a netcdf file or a database entry.
Definition: BESContainer.h:65
BESDataHandlerInterface::first_container
void first_container()
set the container pointer to the first container in the containers list
Definition: BESDataHandlerInterface.h:135
BESDataHandlerInterface
Structure storing information used by the BES to handle the request.
Definition: BESDataHandlerInterface.h:56
BESDataHandlerInterface::error_info
BESInfo * error_info
error information object
Definition: BESDataHandlerInterface.h:94
BESResponseObject
Abstract base class representing a specific set of information in response to a request to the BES.
Definition: BESResponseObject.h:45