libdap Updated for version 3.21.1
libdap4 is an implementation of OPeNDAP's DAP protocol.
DAS.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// (c) COPYRIGHT URI/MIT 1994-1999
27// Please read the full copyright statement in the file COPYRIGHT_URI.
28//
29// Authors:
30// jhrg,jimg James Gallagher <jgallagher@gso.uri.edu>
31
32// Using the DASVHMap class, build a parser for the DAS and add functions
33// that provide access to the variables, their attributes and values.
34//
35// jhrg 7/25/94
36
37#ifndef _das_h
38#define _das_h 1
39
40#include <cstdio>
41#include <iostream>
42#include <string>
43
44#ifndef _attrtable_h
45#include "AttrTable.h"
46#endif
47
48using std::cout;
49
50namespace libdap {
51
119class DAS : public DapObj {
120private:
121 // The DAS support the notion of a current attribute table for a given
122 // container. Containers are used by the BES to support datasets that
123 // are built using several files (but not exactly the same way as
124 // NCML builds them.
125 AttrTable *d_container;
126 string d_container_name;
127
128 // A DAS is a shell around an attribute table. Since tables can be nested,
129 // there is one top-level table and the attribute tables for individual
130 // variables are its children.
131 AttrTable d_attrs;
132
133 void duplicate(const DAS &src);
134
135public:
136 DAS() : DapObj(), d_container(0) {}
137 DAS(const DAS &das) { duplicate(das); }
138
139 virtual ~DAS() {}
140
141 DAS &operator=(const DAS &rhs);
142
146 virtual string container_name() const { return d_container_name; }
147
148 virtual void container_name(const string &cn);
149
155 virtual AttrTable *container() { return d_container; }
156
164 if (d_container)
165 return d_container;
166 return &d_attrs;
167 }
168
169 virtual void erase();
170
171 virtual unsigned int get_size() const;
172
175
178
179 virtual AttrTable *get_table(const string &name);
180
181 virtual AttrTable *add_table(const string &name, AttrTable *at);
182
184 virtual void parse(string fname);
185 virtual void parse(int fd);
186 virtual void parse(FILE *in = stdin);
187
189 virtual void print(FILE *out, bool dereference = false);
190 virtual void print(ostream &out, bool dereference = false);
191
192 virtual void dump(ostream &strm) const;
193};
194
195} // namespace libdap
196
197#endif // _das_h
Contains the attributes for a dataset.
Definition AttrTable.h:150
std::vector< entry * >::iterator Attr_iter
Definition AttrTable.h:258
Hold attribute data for a DAP2 dataset.
Definition DAS.h:119
AttrTable::Attr_iter var_begin()
Returns a reference to the attribute table for the first variable.
Definition DAS.cc:139
DAS & operator=(const DAS &rhs)
Definition DAS.cc:86
virtual AttrTable * container()
Returns the current attribute container when multiple files used to build this DAS.
Definition DAS.h:155
DAS(const DAS &das)
Definition DAS.h:137
virtual AttrTable * get_top_level_attributes()
Returns the top most set of attributes.
Definition DAS.h:163
virtual unsigned int get_size() const
Returns the number of attributes in the current attribute table.
Definition DAS.cc:120
virtual AttrTable * add_table(const string &name, AttrTable *at)
Adds a variable attribute table to the DAS or the current dataset container attribute table.
Definition DAS.cc:193
virtual void print(FILE *out, bool dereference=false)
Definition DAS.cc:304
virtual void dump(ostream &strm) const
dumps information about this object
Definition DAS.cc:339
AttrTable::Attr_iter var_end()
Definition DAS.cc:149
virtual void parse(string fname)
Reads a DAS from the named file.
Definition DAS.cc:213
virtual ~DAS()
Definition DAS.h:139
AttrTable * get_table(AttrTable::Attr_iter &i)
Returns the referenced variable attribute table.
Definition DAS.cc:167
virtual void erase()
erase all attributes in this DAS
Definition DAS.cc:129
string get_name(AttrTable::Attr_iter &i)
Returns the name of the referenced variable attribute table.
Definition DAS.cc:158
virtual string container_name() const
Returns the name of the current attribute container when multiple files used to build this DAS.
Definition DAS.h:146
libdap base object for common functionality of libdap objects
Definition DapObj.h:49
top level DAP object to house generic methods
Definition AISConnect.cc:30