libdap Updated for version 3.21.1
libdap4 is an implementation of OPeNDAP's DAP protocol.
Resource.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) 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 resource_h
27#define resource_h
28
29#include <iostream>
30#include <string>
31
32#ifndef _error_h
33#include "Error.h"
34#endif
35
36using namespace std;
37
38namespace libdap {
39
49class Resource {
50public:
69
72 Resource() : d_url(""), d_rule(overwrite) {}
73
77 Resource(const string &u) : d_url(u), d_rule(overwrite) {}
78
82 Resource(const string &u, const rule &r) : d_url(u), d_rule(r) {}
83
94 Resource(const string &u, const string &r) throw(Error) : d_url(u) {
95 if (r == "replace")
96 d_rule = replace;
97 else if (r == "fallback")
98 d_rule = fallback;
99 else if (r == "overwrite" || r == "default")
100 d_rule = overwrite;
101 else
102 throw Error(string("An AIS Resource object was created with an unknown rule type '") + r);
103 }
104
105 virtual ~Resource() {}
106
108 virtual string get_url() const { return d_url; }
109
112 virtual void set_url(const string &u) { d_url = u; }
113
115 virtual Resource::rule get_rule() const { return d_rule; }
116
119 virtual void set_rule(const Resource::rule &r) { d_rule = r; }
120
125 friend ostream &operator<<(ostream &os, const Resource &r);
126
127private:
128 string d_url;
129 Resource::rule d_rule;
130};
131
132} // namespace libdap
133
134#endif // resource_h
A class for error processing.
Definition Error.h:92
Associate a rule with an ancillary resource.
Definition Resource.h:49
virtual string get_url() const
Definition Resource.h:108
virtual Resource::rule get_rule() const
Definition Resource.h:115
Resource(const string &u, const string &r)
Definition Resource.h:94
virtual void set_url(const string &u)
Definition Resource.h:112
friend ostream & operator<<(ostream &os, const Resource &r)
Resource(const string &u)
Definition Resource.h:77
virtual void set_rule(const Resource::rule &r)
Definition Resource.h:119
rule
How are ancillary resources used.
Definition Resource.h:68
Resource(const string &u, const rule &r)
Definition Resource.h:82
virtual ~Resource()
Definition Resource.h:105
top level DAP object to house generic methods
Definition AISConnect.cc:30