libdap Updated for version 3.20.10
libdap4 is an implementation of OPeNDAP's DAP protocol.
Resource.h
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 <string>
30#include <iostream>
31
32#ifndef _error_h
33#include "Error.h"
34#endif
35
36using namespace std;
37
38namespace libdap
39{
40
51{
52public:
53
71 enum rule { overwrite, replace, fallback };
72
75 Resource() : d_url(""), d_rule(overwrite)
76 {}
77
81 Resource(const string &u) : d_url(u), d_rule(overwrite)
82 {}
83
87 Resource(const string &u, const rule &r) : d_url(u), d_rule(r)
88 {}
89
100 Resource(const string &u, const string &r) throw(Error) : d_url(u)
101 {
102 if (r == "replace")
103 d_rule = replace;
104 else if (r == "fallback")
105 d_rule = fallback;
106 else if (r == "overwrite" || r == "default")
107 d_rule = overwrite;
108 else
109 throw Error(string("An AIS Resource object was created with an unknown rule type '") + r);
110 }
111
112 virtual ~Resource()
113{}
114
116 virtual string get_url() const
117 {
118 return d_url;
119 }
120
123 virtual void set_url(const string &u)
124 {
125 d_url = u;
126 }
127
129 virtual Resource::rule get_rule() const
130 {
131 return d_rule;
132 }
133
136 virtual void set_rule(const Resource::rule &r)
137 {
138 d_rule = r;
139 }
140
145 friend ostream &operator<<(ostream &os, const Resource &r);
146
147
148private:
149
150 string d_url;
151 Resource::rule d_rule;
152};
153
154} // namespace libdap
155
156#endif // resource_h
A class for error processing.
Definition Error.h:94
Associate a rule with an ancillary resource.
Definition Resource.h:51
virtual string get_url() const
Definition Resource.h:116
virtual Resource::rule get_rule() const
Definition Resource.h:129
Resource(const string &u, const string &r)
Definition Resource.h:100
virtual void set_url(const string &u)
Definition Resource.h:123
friend ostream & operator<<(ostream &os, const Resource &r)
Resource(const string &u)
Definition Resource.h:81
virtual void set_rule(const Resource::rule &r)
Definition Resource.h:136
rule
How are ancillary resources used.
Definition Resource.h:71
Resource(const string &u, const rule &r)
Definition Resource.h:87
top level DAP object to house generic methods