Resource.h
// -*- mode: c++; c-basic-offset:4 -*-
// This file is part of libdap, A C++ implementation of the OPeNDAP Data
// Access Protocol.
// Copyright (c) 2003 OPeNDAP, Inc.
// Author: James Gallagher <jgallagher@opendap.org>
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
//
// You can contact OPeNDAP, Inc. at PO Box 112, Saunderstown, RI. 02874-0112.
#ifndef resource_h
#define resource_h
#include <string>
#include <iostream>
#ifndef _error_h
#include "Error.h"
#endif
using namespace std;
namespace libdap
{
class Resource
{
public:
enum rule { overwrite, replace, fallback };
Resource() : d_url(""), d_rule(overwrite)
{}
Resource(const string &u) : d_url(u), d_rule(overwrite)
{}
Resource(const string &u, const rule &r) : d_url(u), d_rule(r)
{}
Resource(const string &u, const string &r) throw(Error) : d_url(u)
{
if (r == "replace")
d_rule = replace;
else if (r == "fallback")
d_rule = fallback;
else if (r == "overwrite" || r == "default")
d_rule = overwrite;
else
throw Error(string("An AIS Resource object was created with an unknown rule type '") + r);
}
virtual ~Resource()
{}
virtual string get_url() const
{
return d_url;
}
virtual void set_url(const string &u)
{
d_url = u;
}
virtual Resource::rule get_rule() const
{
return d_rule;
}
virtual void set_rule(const Resource::rule &r)
{
d_rule = r;
}
friend ostream &operator<<(ostream &os, const Resource &r);
private:
string d_url;
Resource::rule d_rule;
};
} // namespace libdap
#endif // resource_h
libdap::Resource::get_url
virtual string get_url() const
Definition: Resource.h:116
libdap::Resource::Resource
Resource(const string &u, const string &r)
Definition: Resource.h:100
libdap::Resource::Resource
Resource(const string &u)
Definition: Resource.h:81
std
STL namespace.
libdap::Resource::set_rule
virtual void set_rule(const Resource::rule &r)
Definition: Resource.h:136
libdap
Definition: AlarmHandler.h:35
libdap::Resource::Resource
Resource()
Definition: Resource.h:75
libdap::Resource::Resource
Resource(const string &u, const rule &r)
Definition: Resource.h:87
libdap::Resource::rule
rule
How are ancillary resources used.
Definition: Resource.h:71
libdap::Resource::set_url
virtual void set_url(const string &u)
Definition: Resource.h:123
libdap::Resource::get_rule
virtual Resource::rule get_rule() const
Definition: Resource.h:129
libdap::Resource
Associate a rule with an ancillary resource.
Definition: Resource.h:50
libdap::Error
A class for error processing.
Definition: Error.h:90