DAS.h
// -*- mode: c++; c-basic-offset:4 -*-
// This file is part of libdap, A C++ implementation of the OPeNDAP Data
// Access Protocol.
// Copyright (c) 2002,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.
// (c) COPYRIGHT URI/MIT 1994-1999
// Please read the full copyright statement in the file COPYRIGHT_URI.
//
// Authors:
// jhrg,jimg James Gallagher <jgallagher@gso.uri.edu>
// Using the DASVHMap class, build a parser for the DAS and add functions
// that provide access to the variables, their attributes and values.
//
// jhrg 7/25/94
#ifndef _das_h
#define _das_h 1
#include <cstdio>
#include <string>
#include <iostream>
#ifndef _attrtable_h
#include "AttrTable.h"
#endif
using std::cout;
namespace libdap
{
class DAS : public DapObj
{
private:
// The DAS support the notion of a current attribute table for a given
// container. Containers are used by the BES to support datasets that
// are built using several files (but not exactly the same way as
// NCML builds them.
AttrTable *d_container ;
string d_container_name ;
// A DAS is a shell around an attribute table. Since tables can be nested,
// there is one top-level table and the attribute tables for individual
// variables are its children.
AttrTable d_attrs ;
void duplicate(const DAS &src);
public:
DAS() : DapObj(), d_container( 0 ) { }
DAS(const DAS &das) { duplicate(das); }
virtual ~DAS() { }
DAS & operator=(const DAS &rhs);
virtual string container_name() const {return d_container_name; }
virtual void container_name( const string &cn ) ;
virtual AttrTable *container() { return d_container; }
virtual AttrTable *get_top_level_attributes() {
if (d_container)
return d_container;
return &d_attrs;
}
virtual void erase() ;
virtual unsigned int get_size() const ;
AttrTable::Attr_iter var_begin() ;
AttrTable::Attr_iter var_end() ;
string get_name(AttrTable::Attr_iter &i);
AttrTable *get_table(AttrTable::Attr_iter &i);
virtual AttrTable *get_table(const string &name);
virtual AttrTable *add_table(const string &name, AttrTable *at);
virtual void parse(string fname);
virtual void parse(int fd);
virtual void parse(FILE *in = stdin);
virtual void print(FILE *out, bool dereference = false);
virtual void print(ostream &out, bool dereference = false);
virtual void dump(ostream &strm) const ;
};
} // namespace libdap
#endif // _das_h
libdap::DAS::container
virtual AttrTable * container()
Returns the current attribute container when multiple files used to build this DAS.
Definition: DAS.h:158
libdap::DAS::get_table
AttrTable * get_table(AttrTable::Attr_iter &i)
Returns the referenced variable attribute table.
Definition: DAS.cc:179
libdap::DAS
Hold attribute data for a DAP2 dataset.
Definition: DAS.h:121
libdap::DAS::var_end
AttrTable::Attr_iter var_end()
Definition: DAS.cc:158
libdap
top level DAP object to house generic methods
Definition: AlarmHandler.h:35
libdap::DapObj
libdap base object for common functionality of libdap objects
Definition: DapObj.h:50
libdap::DAS::var_begin
AttrTable::Attr_iter var_begin()
Returns a reference to the attribute table for the first variable.
Definition: DAS.cc:147
libdap::DAS::get_name
string get_name(AttrTable::Attr_iter &i)
Returns the name of the referenced variable attribute table.
Definition: DAS.cc:168
libdap::DAS::dump
virtual void dump(ostream &strm) const
dumps information about this object
Definition: DAS.cc:369
libdap::AttrTable
Contains the attributes for a dataset.
Definition: AttrTable.h:142
libdap::DAS::erase
virtual void erase()
erase all attributes in this DAS
Definition: DAS.cc:135
libdap::DAS::print
virtual void print(FILE *out, bool dereference=false)
Definition: DAS.cc:331
libdap::DAS::parse
virtual void parse(string fname)
Reads a DAS from the named file.
Definition: DAS.cc:232
libdap::DAS::get_top_level_attributes
virtual AttrTable * get_top_level_attributes()
Returns the top most set of attributes.
Definition: DAS.h:166
libdap::DAS::get_size
virtual unsigned int get_size() const
Returns the number of attributes in the current attribute table.
Definition: DAS.cc:125
libdap::DAS::container_name
virtual string container_name() const
Returns the name of the current attribute container when multiple files used to build this DAS.
Definition: DAS.h:149
libdap::DAS::add_table
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:209