bes  Updated for version 3.20.6
FONcStructure Class Referenceabstract

A DAP Structure with file out netcdf information included. More...

#include <FONcStructure.h>

Collaboration diagram for FONcStructure:
Collaboration graph

Public Member Functions

virtual void clear_embedded ()
 Clears the list of embedded variable names. More...
 
virtual void convert (std::vector< std::string > embed)
 
virtual void convert (vector< string > embed)
 Creates the FONc objects for each variable of the DAP structure. More...
 
virtual void define (int ncid)
 Define the members of the structure in the netcdf file. More...
 
virtual void dump (ostream &strm) const
 dumps information about this object for debugging purposes More...
 
virtual void dump (std::ostream &strm) const =0
 dump the contents of this object to the specified ostream More...
 
 FONcStructure (BaseType *b)
 Constructor for FONcStructure that takes a DAP Structure. More...
 
virtual bool isNetCDF4 ()
 Returns true if NetCDF4 features will be required. More...
 
virtual string name ()
 Returns the name of the structure. More...
 
virtual void setVersion (std::string version)
 Identifies variable with use of NetCDF4 features. More...
 
virtual nc_type type ()
 Returns the type of data of this variable. More...
 
virtual int varid () const
 
virtual void write (int ncid)
 write the member variables of the structure to the netcdf file More...
 
virtual ~FONcStructure ()
 Destructor that cleans up the structure. More...
 

Protected Attributes

bool _defined
 
std::vector< std::string > _embed
 
std::string _ncVersion
 
std::string _orig_varname
 
int _varid
 
std::string _varname
 

Detailed Description

A DAP Structure with file out netcdf information included.

This class represents a DAP Structure with additional information needed to write it out to a netcdf file. Includes a reference to the actual DAP Structure being converted. Keeps the list of converted BaseTypes as FONcBaseType instances.

Definition at line 48 of file FONcStructure.h.

Constructor & Destructor Documentation

◆ FONcStructure()

FONcStructure::FONcStructure ( BaseType *  b)

Constructor for FONcStructure that takes a DAP Structure.

This constructor takes a DAP BaseType and makes sure that it is a DAP Structure instance. If not, it throws an exception

Parameters
bA DAP BaseType that should be a Structure
Exceptions
BESInternalErrorif the BaseType is not a Structure

Definition at line 47 of file FONcStructure.cc.

◆ ~FONcStructure()

FONcStructure::~FONcStructure ( )
virtual

Destructor that cleans up the structure.

Delete each of the FONcBaseType instances that is a part of this structure.

Definition at line 62 of file FONcStructure.cc.

Member Function Documentation

◆ clear_embedded()

void FONcBaseType::clear_embedded ( )
virtualinherited

Clears the list of embedded variable names.

Definition at line 81 of file FONcBaseType.cc.

◆ convert()

void FONcStructure::convert ( vector< string >  embed)
virtual

Creates the FONc objects for each variable of the DAP structure.

For each of the variables of the DAP Structure we convert to a similar FONc object. Because NetCDF does not support structures, we must flatten out the structures. To do this, we embed the name of the structure as part of the name of the children variables. For example, if the structure, called s1, contains an array called a1 and an int called i1, then two variables are created in the netcdf file called s1.a1 and s1.i1.

Note
This method only converts the variables that are to be sent. Thsi keeps the convert() and write() methods below from operating on DAP variables that should not be sent.
Parameters
embedThe parent names of this structure.
Exceptions
BESInternalErrorif there is a problem converting this structure

Definition at line 98 of file FONcStructure.cc.

◆ define()

void FONcStructure::define ( int  ncid)
virtual

Define the members of the structure in the netcdf file.

Since netcdf does not support structures, we define the members of the structure to include the name of the structure in their name.

Note
This will call the FONcBaseType's define() method for the FONcBaseType variables. Because the FONcStructure::convert() method above only builds a FONcBaseType for elements of the DAP Structure with send_p true, the code is protected from trying to operate on DAP variables that should not be sent. This is important because those variables likely don't contain any values!
Parameters
ncidThe id of the netcdf file
Exceptions
BESInternalErrorif there is a problem defining the structure

Reimplemented from FONcBaseType.

Definition at line 131 of file FONcStructure.cc.

◆ dump() [1/2]

void FONcStructure::dump ( ostream &  strm) const
virtual

dumps information about this object for debugging purposes

Displays the pointer value of this instance plus instance data, including the members of the structure by calling dump on those FONc objects.

Parameters
strmC++ i/o stream to dump the information to

Definition at line 185 of file FONcStructure.cc.

◆ dump() [2/2]

virtual void FONcBaseType::dump ( std::ostream &  strm) const
pure virtualinherited

dump the contents of this object to the specified ostream

This method is implemented by all derived classes to dump their contents, in other words, any state they might have, private variables, etc...

The inline function below can be used to dump the contents of an OPeNDAOObj object. For example, the object Animal is derived from BESObj. A user could do the following:

Animal *a = new dog( "Sparky" ) ; cout << a << endl ;

And the dump method for dog could display the name passed into the constructor, the (this) pointer of the object, etc...

Parameters
strmC++ i/o stream to dump the object to

Implements BESObj.

Implemented in FONcArray.

◆ isNetCDF4()

bool FONcBaseType::isNetCDF4 ( )
virtualinherited

Returns true if NetCDF4 features will be required.

Definition at line 97 of file FONcBaseType.cc.

◆ name()

string FONcStructure::name ( )
virtual

Returns the name of the structure.

Returns
The name of the structure

Implements FONcBaseType.

Definition at line 172 of file FONcStructure.cc.

◆ setVersion()

void FONcBaseType::setVersion ( std::string  version)
virtualinherited

Identifies variable with use of NetCDF4 features.

Definition at line 88 of file FONcBaseType.cc.

◆ type()

nc_type FONcBaseType::type ( )
virtualinherited

Returns the type of data of this variable.

This implementation of the method returns the default type of data. Subclasses of FONcBaseType will return the specific type of data for simple types

Reimplemented in FONcStr, FONcByte, FONcDouble, FONcFloat, FONcInt, and FONcShort.

Definition at line 74 of file FONcBaseType.cc.

◆ write()

void FONcStructure::write ( int  ncid)
virtual

write the member variables of the structure to the netcdf file

Parameters
ncidThe id of the netcdf file
Exceptions
BESInternalErrorif there is a problem writing out the members of the structure.

Reimplemented from FONcBaseType.

Definition at line 156 of file FONcStructure.cc.


The documentation for this class was generated from the following files: