DataDDS Class Reference

Holds a DAP2 DDS. More...

#include <DataDDS.h>

Inheritance diagram for DataDDS:

Inheritance graph
[legend]
Collaboration diagram for DataDDS:

Collaboration graph
[legend]
List of all members.

Public Types

typedef std::vector< BaseType
* >::const_iterator 
Vars_citer
typedef std::vector< BaseType
* >::iterator 
Vars_iter
typedef std::vector< BaseType
* >::reverse_iterator 
Vars_riter

Public Member Functions

void add_var (BaseType *bt)
 Adds a copy of the variable to the DDS. Using the ptr_duplicate() method, perform a deep copy on the variable bt and adds the result to this DDS.
bool check_semantics (bool all=false)
 Check the semantics of each of the variables represented in the DDS.
 DataDDS (BaseTypeFactory *factory, const string &n="", const string &v="", const string &p="")
 Make an instance of DataDDS A DataDDS instance is a DDS with aditional information about the version of the server from which the data came.
void del_var (Vars_iter i1, Vars_iter i2)
 Removes a range of variables from the DDS.
void del_var (Vars_iter i)
 Removes a variable from the DDS.
void del_var (const string &n)
 Removes a variable from the DDS.
virtual void dump (ostream &strm) const
 dumps information about this object
virtual AttrTableget_attr_table ()
BaseTypeFactoryget_factory () const
string get_protocol () const
int get_protocol_major () const
int get_protocol_minor () const
int get_timeout ()
BaseTypeget_var_index (int i)
 Get a variable.
Vars_iter get_vars_iter (int i)
 Get an iterator.
string get_version () const
 Get the server version string, unparsed.
int get_version_major () const
 Returns the major version number.
int get_version_minor () const
 Returns the minor version number.
bool mark (const string &name, bool state)
 Mark the send_p flag of the named variable to state.
void mark_all (bool state)
int num_var ()
 Returns the number of variables in the DDS.
void parse (FILE *in=stdin)
 Parse a DDS from a file indicated by the input file descriptor. Read the persistent representation of a DDS from the FILE *in, parse it and create a matching binary object.
void parse (int fd)
 Parse a DDS from a file indicated by the input file descriptor.
void parse (string fname)
 Parse a DDS from a file with the given name.
void print (FILE *out)
 Print the entire DDS to the specified file.
void print_constrained (FILE *out)
 Print a constrained DDS to the specified file.
void print_xml (FILE *out, bool constrained, const string &blob)
BaseTypeFactoryset_factory (BaseTypeFactory *factory)
void set_protocol (const string &p)
void set_timeout (int t)
void set_version (const string &v)
void tag_nested_sequences ()
 Traverse DDS, set Sequence leaf nodes.
void timeout_off ()
void timeout_on ()
virtual void transfer_attributes (DAS *das)
BaseTypevar (const string &n, btp_stack *s=0)
 Find the variable with the given name.
BaseTypevar (const string &n, btp_stack &s)
Vars_iter var_begin ()
 Return an iterator.
Vars_iter var_end ()
 Return an iterator.
Vars_riter var_rbegin ()
 Return a reverse iterator.
Vars_riter var_rend ()
 Return a reverse iterator.
virtual ~DataDDS ()
File Name Accessor
Get and set the dataset's filename. This is the physical location on a disk where the dataset exists. The dataset name is simply a title.

See also:
Dataset Name Accessors


void filename (const string &fn)
string filename ()
Dataset Name Accessors
Get and set the dataset's name. This is the name of the dataset itself, and is not to be confused with the name of the file or disk on which it is stored.

string get_dataset_name () const
void set_dataset_name (const string &n)
File Name Accessor
Get and set the dataset's filename. This is the physical location on a disk where the dataset exists. The dataset name is simply a title.

See also:
Dataset Name Accessors


void filename (const string &fn)
string filename ()
Dataset Name Accessors
Get and set the dataset's name. This is the name of the dataset itself, and is not to be confused with the name of the file or disk on which it is stored.

string get_dataset_name () const
void set_dataset_name (const string &n)

Protected Member Functions

void duplicate (const DDS &dds)
BaseTypeexact_match (const string &name, btp_stack *s=0)
virtual AttrTablefind_matching_container (AttrTable::entry *source, BaseType **dest_variable)
BaseTypeleaf_match (const string &name, btp_stack *s=0)

Detailed Description

This class adds some useful state information to the DDS structure. It is for use on the client side of the connection.

Note:
Make sure to pass a valid pointer to the DDS constructor or use the set_factory() method before actually using the DDS. Also make sure that the Factory's lifetime thereafter is the same as the DDS's. Never delete the factory until you're done using the DDS.

Update: I removed the DEFAULT_BASETYPE_FACTORY switch because it caused more confusion than it avoided. See Trac #130.

The compile-time symbol DEFAULT_BASETYPE_FACTORY controls whether the old (3.4 and earlier) DDS and DataDDS constructors are supported. These constructors now use a default factory class (BaseTypeFactory, implemented by this library) to instantiate Byte, ..., Grid variables. To use the default ctor in your code you must also define this symbol. If you do choose to define this and fail to provide a specialization of BaseTypeFactory when your software needs one, you code may not link or may fail at run time. In addition to the older ctors for DDS and DataDDS, defining the symbol also makes some of the older methods in Connect available (because those methods require the older DDS and DataDDS ctors.

See also:
Connect

Definition at line 74 of file DataDDS.h.


Member Typedef Documentation

typedef std::vector<BaseType *>::const_iterator DDS::Vars_citer [inherited]

Definition at line 214 of file DDS.h.

typedef std::vector<BaseType *>::iterator DDS::Vars_iter [inherited]

Definition at line 215 of file DDS.h.

typedef std::vector<BaseType *>::reverse_iterator DDS::Vars_riter [inherited]

Definition at line 216 of file DDS.h.


Constructor & Destructor Documentation

DataDDS::DataDDS ( BaseTypeFactory factory,
const string &  n = "",
const string &  v = "",
const string &  p = "" 
)

Parameters:
factory Use this BaseTypeFactory to instantiate the variables. Caller must free; can also be set using the set_factory() method. Never delete until just before deleting the DDS istelf unless you intend to replace the factory with a new instance.
n The name of the dataset. Can also be set using the set_dataset_name() method.
v The server version.
p The protocol version.

Definition at line 160 of file DataDDS.cc.

virtual DataDDS::~DataDDS (  )  [inline, virtual]

Definition at line 94 of file DataDDS.h.


Member Function Documentation

void DDS::add_var ( BaseType bt  )  [inherited]

Note:
The copy will not copy data values.
Parameters:
bt Source variable.

Definition at line 349 of file DDS.cc.

References DBG2, and BaseType::ptr_duplicate().

Referenced by DDS::duplicate().

Here is the call graph for this function:

bool DDS::check_semantics ( bool  all = false  )  [inherited]

Check the semantics of the DDS describing a complete dataset. If ALL is true, check not only the semantics of THIS->TABLE, but also recurrsively all ctor types in the THIS->TABLE. By default, ALL is false since parsing a DDS input file runns semantic checks on all variables (but not the dataset itself.

Returns:
TRUE if the conventions for the DDS are not violated, FALSE otherwise.
Parameters:
all If true, recursively check the individual members of compound variables.
See also:
BaseType::check_semantics

Definition at line 780 of file DDS.cc.

References unique_names().

Here is the call graph for this function:

void DDS::del_var ( Vars_iter  i1,
Vars_iter  i2 
) [inherited]

Remove the variables referenced by the range of iterators and free their storage.

Note:
Invalidates any iterators that reference the contents of the DDS.
Parameters:
i1 The start of the range.
i2 The end of the range.

Definition at line 402 of file DDS.cc.

void DDS::del_var ( Vars_iter  i  )  [inherited]

Remove the variable referenced by the iterator and free its storage.

Note:
Invalidates any iterators that reference the contents of the DDS.
Parameters:
i The Vars_iter which refers to the variable.

Definition at line 386 of file DDS.cc.

void DDS::del_var ( const string &  n  )  [inherited]

Remove the named variable from the DDS. This method is not smart about looking up names. The variable must exist at the top level of the DDS and must match exactly the name given.

Note:
Invalidates any iterators that reference the contents of the DDS.
Parameters:
n The name of the variable to remove.

Definition at line 369 of file DDS.cc.

void DataDDS::dump ( ostream &  strm  )  const [virtual]

Displays the pointer value of this instance and then calls parent dump

Parameters:
strm C++ i/o stream to dump the information to
Returns:
void

Reimplemented from DDS.

Definition at line 125 of file DataDDS.cc.

References DDS::dump(), DapIndent::Indent(), DapIndent::LMarg(), and DapIndent::UnIndent().

Here is the call graph for this function:

void DDS::duplicate ( const DDS dds  )  [protected, inherited]

Definition at line 84 of file DDS.cc.

References DDS::add_var(), DDS::d_factory, DDS::name, DDS::var_begin(), and DDS::var_end().

Referenced by DDS::DDS(), and DDS::operator=().

Here is the call graph for this function:

BaseType * DDS::exact_match ( const string &  name,
btp_stack s = 0 
) [protected, inherited]

Definition at line 473 of file DDS.cc.

References DBG2, BaseType::name(), BaseType::var(), and DDS::var().

Referenced by DDS::var().

Here is the call graph for this function:

void DDS::filename ( const string &  fn  )  [inherited]

Set the dataset's filename.

Definition at line 337 of file DDS.cc.

string DDS::filename (  )  [inherited]

Gets the dataset file name.

Definition at line 330 of file DDS.cc.

AttrTable * DDS::find_matching_container ( AttrTable::entry source,
BaseType **  dest_variable 
) [protected, virtual, inherited]

Given an attribute container from a DAS, find or make a destination for its contents in the DDS.

Parameters:
source Attribute table
dest_variable result param that holds the BaseType
Returns:
Destination Attribute Table

Definition at line 180 of file DDS.cc.

References AttrTable::append_container(), Attr_container, DBG, dods_grid_c, AttrTable::find_container(), BaseType::get_attr_table(), BaseType::get_parent(), AttrTable::entry::name, BaseType::type(), AttrTable::entry::type, and DDS::var().

Referenced by DDS::transfer_attributes().

Here is the call graph for this function:

AttrTable & DDS::get_attr_table (  )  [virtual, inherited]

Get the attribute table for the global attributes.

Definition at line 315 of file DDS.cc.

Referenced by DDXParser::ddx_start_document().

string DDS::get_dataset_name (  )  const [inherited]

Returns the dataset's name.

Definition at line 299 of file DDS.cc.

BaseTypeFactory* DDS::get_factory (  )  const [inline, inherited]

Return the factory which makes instances of the Byte, ..., Grid type classes. Specialize BaseTypeFactory so that a DDS will be populated with your client or server's specialized types.

Returns:
An instance of BaseTypeFactory.

Definition at line 234 of file DDS.h.

Referenced by Connect::request_ddx().

string DataDDS::get_protocol (  )  const [inline]

Definition at line 126 of file DataDDS.h.

Referenced by Sequence::deserialize().

int DataDDS::get_protocol_major (  )  const [inline]

Definition at line 130 of file DataDDS.h.

Referenced by Sequence::deserialize().

int DataDDS::get_protocol_minor (  )  const [inline]

Definition at line 134 of file DataDDS.h.

Referenced by Sequence::deserialize().

int DDS::get_timeout (  )  [inherited]

Definition at line 578 of file DDS.cc.

BaseType * DDS::get_var_index ( int  i  )  [inherited]

Return the ith variable.

Parameters:
i the index
Returns:
The corresponding variable

Definition at line 542 of file DDS.cc.

DDS::Vars_iter DDS::get_vars_iter ( int  i  )  [inherited]

Return the iterator for the ith variable.

Parameters:
i the index
Returns:
The corresponding Vars_iter

Definition at line 533 of file DDS.cc.

string DataDDS::get_version (  )  const [inline]

Definition at line 106 of file DataDDS.h.

int DataDDS::get_version_major (  )  const [inline]

Definition at line 111 of file DataDDS.h.

int DataDDS::get_version_minor (  )  const [inline]

Definition at line 116 of file DataDDS.h.

BaseType * DDS::leaf_match ( const string &  name,
btp_stack s = 0 
) [protected, inherited]

Definition at line 454 of file DDS.cc.

References DBG2.

Referenced by DDS::var().

bool DDS::mark ( const string &  n,
bool  state 
) [inherited]

Mark the named variable by setting its SEND_P flag to STATE (true indicates that it is to be sent). Names must be fully qualified.

Note:
For aggregate types this sets each part to STATE when STATE is True. Thus, if State is True and N is `exp1.test', then both `exp1' and `test' have their SEND_P flag set to True. If STATE is False, then the SEND_P flag of the `test' is set to False, but `exp1' is left unchanged. This means that a single variable can be removed from the current projection without removing all the other children of its parent. See the mfunc set_send_p().
Returns:
True if the named variable was found, false otherwise.
Todo:
This should throw an exception on error!!!
Todo:
These methods that use the btp_stack to keep track of the path from the top of a dataset to a particular variable can be rewritten to use the parent field instead.
Todo:
All the methods that use names to identify variables should have counterparts that take BaseType pointers.

Definition at line 826 of file DDS.cc.

References DBG2, BaseType::name(), BaseType::set_send_p(), and DDS::var().

Here is the call graph for this function:

void DDS::mark_all ( bool  state  )  [inherited]

Mark the member variable send_p flags to state.

Returns:
Void

Definition at line 859 of file DDS.cc.

int DDS::num_var (  )  [inherited]

Definition at line 549 of file DDS.cc.

void DDS::parse ( FILE *  in = stdin  )  [inherited]

Parameters:
in Read the persistent DDS from this FILE*.
Exceptions:
InternalErr Thrown if in is null
Error Thrown if the parse fails.

Definition at line 648 of file DDS.cc.

References DBG2, dds_buffer(), dds_delete_buffer(), dds_switch_to_buffer(), and ddsparse().

Here is the call graph for this function:

void DDS::parse ( int  fd  )  [inherited]

Definition at line 619 of file DDS.cc.

References DDS::parse().

Here is the call graph for this function:

void DDS::parse ( string  fname  )  [inherited]

Definition at line 598 of file DDS.cc.

References can_not_read_file.

Referenced by DDS::parse(), DODSFilter::read_ancillary_dds(), Connect::request_dds(), Connect::request_dds_url(), Connect::request_ddx(), and Connect::request_ddx_url().

void DDS::print ( FILE *  out  )  [inherited]

Definition at line 675 of file DDS.cc.

References id2www().

Referenced by main(), and DODSFilter::send_dds().

Here is the call graph for this function:

void DDS::print_constrained ( FILE *  out  )  [inherited]

Print those parts (variables) of the DDS structure to OS that are marked to be sent after evaluating the constraint expression.

Note:
This function only works for scalars at the top level.
Returns:
true.

Definition at line 699 of file DDS.cc.

References id2www().

Referenced by DODSFilter::dataset_constraint(), and DODSFilter::send_dds().

Here is the call graph for this function:

void DDS::print_xml ( FILE *  out,
bool  constrained,
const string &  blob 
) [inherited]

Print an XML represnetation of this DDS. This method is used to generate the part of the DDX response. The Dataset tag is not written by this code. The caller of this method must handle writing that and including the dataBLOB tag.

Parameters:
out Destination.
constrained True if the output should be limited to just those variables that are in the projection of the current constraint expression.
blob The dataBLOB href.

Definition at line 740 of file DDS.cc.

References default_schema_location, dods_namespace, id2xml(), AttrTable::print_xml(), DDS::var_begin(), and DDS::var_end().

Referenced by main(), and DODSFilter::send_ddx().

Here is the call graph for this function:

void DDS::set_dataset_name ( const string &  n  )  [inherited]

Sets the dataset name.

Definition at line 306 of file DDS.cc.

Referenced by DDXParser::ddx_start_element().

BaseTypeFactory* DDS::set_factory ( BaseTypeFactory factory  )  [inline, inherited]

Set the factory class used to instantiate variables during the parse of a DDS.

Parameters:
factory The factory this DDS should use. Caller must free factory when done with this DDS.
See also:
BaseTypeFactory

Definition at line 244 of file DDS.h.

void DataDDS::set_protocol ( const string &  p  )  [inline]

Definition at line 121 of file DataDDS.h.

void DDS::set_timeout ( int  t  )  [inherited]

Definition at line 571 of file DDS.cc.

Referenced by DODSFilter::send_data().

void DataDDS::set_version ( const string &  v  )  [inline]

Sets the version string. This typically looks something like: DODS/2.15, where ``2'' is the major version number, and ``15'' the minor number.

Definition at line 100 of file DataDDS.h.

void DDS::tag_nested_sequences (  )  [inherited]

Definition at line 586 of file DDS.cc.

References dods_sequence_c, and dods_structure_c.

Referenced by DODSFilter::send_data().

void DDS::timeout_off (  )  [inherited]

Definition at line 563 of file DDS.cc.

Referenced by Sequence::read_row(), Vector::serialize(), UInt32::serialize(), UInt16::serialize(), Structure::serialize(), Str::serialize(), Int32::serialize(), Int16::serialize(), Grid::serialize(), Float64::serialize(), Float32::serialize(), and Byte::serialize().

void DDS::timeout_on (  )  [inherited]

Definition at line 555 of file DDS.cc.

Referenced by Sequence::read_row(), Vector::serialize(), UInt32::serialize(), UInt16::serialize(), Structure::serialize(), Str::serialize(), Int32::serialize(), Int16::serialize(), Grid::serialize(), Float64::serialize(), Float32::serialize(), and Byte::serialize().

void DDS::transfer_attributes ( DAS das  )  [virtual, inherited]

Given a DAS object, scavenge attributes from it and load them into this object and the variables it contains.

If a DAS contans attributes from the current (8/2006) HDF4 server with names like var_dim_0, var_dim_1, then make those attribute tables sub tables of the var table.

Todo:
Generalize the code that treats the _dim_? attributes or make is obsolete by fixing the HDF4 server.
Note:
This method is technically unnecessary because a server (or client) can easily add attributes directly using the DDS::get_attr_table or BaseType::get_attr_table methods and then poke values in using any of the methods AttrTable provides. This method exists to ease the transition to DDS objects which contain attribute information for the existing servers (Since they all make DAS objects separately from the DDS). They could be modified to use the same AttrTable methods but operate on the AttrTable instances in a DDS/BaseType instead of those in a DAS.
Parameters:
das Get attribute information from this DAS.

Definition at line 244 of file DDS.cc.

References AttrTable::append_attr(), AttrTable::append_container(), AttrTable::attr_begin(), Attr_container, AttrTable::attr_end(), AttrTable::entry::attributes, DBG, DDS::find_matching_container(), AttrTable::get_attr_vector(), AttrTable::get_name(), AttrTable::get_type(), and BaseType::is_constructor_type().

Referenced by main().

Here is the call graph for this function:

BaseType * DDS::var ( const string &  n,
btp_stack s = 0 
) [inherited]

Returns a pointer to the named variable. If the name contains one or more field separators then the function looks for a variable whose name matches exactly. If the name contains no field separators then the funciton looks first in the top level and then in all subsequent levels and returns the first occurrence found. In general, this function searches constructor types in the order in which they appear in the DDS, but there is no requirement that it do so.

Note:
If a dataset contains two constructor types which have field names that are the same (say point.x and pair.x) you should use fully qualified names to get each of those variables.
Parameters:
n The name of the variable to find.
s If given, this value-result parameter holds the path to the returned BaseType. Thus, this method can return the FQN for the variable n.
Returns:
A BaseType pointer to the variable or null if not found.

Definition at line 443 of file DDS.cc.

References DDS::exact_match(), DDS::leaf_match(), and www2id().

Here is the call graph for this function:

BaseType * DDS::var ( const string &  n,
btp_stack s 
) [inherited]

Search for for variable n as above but record all compound type variables which ultimately contain n on s. This stack can then be used to mark the contained compound-type variables as part of the current projection.

Returns:
A BaseType pointer to the variable n or 0 if n could not be found.

Definition at line 419 of file DDS.cc.

Referenced by DDS::exact_match(), DDS::find_matching_container(), and DDS::mark().

DDS::Vars_iter DDS::var_begin (  )  [inherited]

Definition at line 506 of file DDS.cc.

Referenced by DODSFilter::dataset_constraint(), DDS::duplicate(), and DDS::print_xml().

DDS::Vars_iter DDS::var_end (  )  [inherited]

Definition at line 518 of file DDS.cc.

Referenced by DODSFilter::dataset_constraint(), DDS::duplicate(), and DDS::print_xml().

DDS::Vars_riter DDS::var_rbegin (  )  [inherited]

Definition at line 512 of file DDS.cc.

DDS::Vars_riter DDS::var_rend (  )  [inherited]

Definition at line 524 of file DDS.cc.


The documentation for this class was generated from the following files:
Generated on Wed Jun 27 12:57:44 2007 for libdap++ by  doxygen 1.4.7