libdap++  Updated for version 3.12.0
Response.h
Go to the documentation of this file.
1 
2 // -*- mode: c++; c-basic-offset:4 -*-
3 
4 // This file is part of libdap, A C++ implementation of the OPeNDAP Data
5 // Access Protocol.
6 
7 // Copyright (c) 2002,2003 OPeNDAP, Inc.
8 // Author: James Gallagher <jgallagher@opendap.org>
9 //
10 // This library is free software; you can redistribute it and/or
11 // modify it under the terms of the GNU Lesser General Public
12 // License as published by the Free Software Foundation; either
13 // version 2.1 of the License, or (at your option) any later version.
14 //
15 // This library is distributed in the hope that it will be useful,
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 // Lesser General Public License for more details.
19 //
20 // You should have received a copy of the GNU Lesser General Public
21 // License along with this library; if not, write to the Free Software
22 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23 //
24 // You can contact OPeNDAP, Inc. at PO Box 112, Saunderstown, RI. 02874-0112.
25 
26 #ifndef response_h
27 #define response_h
28 
29 #include <cstdio>
30 #include <string>
31 
32 #ifndef _debug_h
33 #include "debug.h"
34 #endif
35 
36 using namespace std;
37 
38 #ifndef _object_type_h
39 #include "ObjectType.h"
40 #endif
41 
42 #ifndef _internalerr_h
43 #include "InternalErr.h"
44 #endif
45 
46 namespace libdap
47 {
48 
62 class Response
63 {
64 private:
66  FILE *d_stream;
68  ObjectType d_type;
70  string d_version;
72  string d_protocol;
74  int d_status;
75 
76 protected:
80  {}
81  Response(const Response &)
82  {}
84  {
85  throw InternalErr(__FILE__, __LINE__, "Unimplemented assignment");
86  }
88 
89 public:
97  Response(FILE *s, int status = 0) : d_stream(s), d_type(unknown_type),
98  d_version("dods/0.0"), d_protocol("2.0"),
99  d_status(status)
100  { }
101 
103  virtual ~Response()
104  {
105  if (d_stream)
106  fclose(d_stream);
107  }
108 
111  virtual int get_status() const
112  {
113  return d_status;
114  }
115  virtual FILE *get_stream() const
116  {
117  return d_stream;
118  }
119  virtual ObjectType get_type() const
120  {
121  return d_type;
122  }
123  virtual string get_version() const
124  {
125  return d_version;
126  }
127  virtual string get_protocol() const
128  {
129  return d_protocol;
130  }
132 
135  virtual void set_status(int s)
136  {
137  d_status = s;
138  }
139  virtual void set_stream(FILE *s)
140  {
141  d_stream = s;
142  }
143  virtual void set_type(ObjectType o)
144  {
145  d_type = o;
146  }
147  virtual void set_version(const string &v)
148  {
149  d_version = v;
150  }
151  virtual void set_protocol(const string &p)
152  {
153  d_protocol = p;
154  }
156 };
157 
158 } // namespace libdap
159 
160 #endif // response_h