#include <DDS.h>
Inheritance diagram for DDS:
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. | |
DDS (const DDS &dds) | |
DDS (BaseTypeFactory *factory, const string &n="") | |
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 AttrTable & | get_attr_table () |
BaseTypeFactory * | get_factory () const |
int | get_timeout () |
BaseType * | get_var_index (int i) |
Get a variable. | |
Vars_iter | get_vars_iter (int i) |
Get an iterator. | |
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. | |
DDS & | operator= (const DDS &rhs) |
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) |
BaseTypeFactory * | set_factory (BaseTypeFactory *factory) |
void | set_timeout (int t) |
void | tag_nested_sequences () |
Traverse DDS, set Sequence leaf nodes. | |
void | timeout_off () |
void | timeout_on () |
virtual void | transfer_attributes (DAS *das) |
BaseType * | var (const string &n, btp_stack *s=0) |
Find the variable with the given name. | |
BaseType * | var (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 | ~DDS () |
Protected Member Functions | |
void | duplicate (const DDS &dds) |
BaseType * | exact_match (const string &name, btp_stack *s=0) |
virtual AttrTable * | find_matching_container (AttrTable::entry *source, BaseType **dest_variable) |
BaseType * | leaf_match (const string &name, btp_stack *s=0) |
Friends | |
class | DDSTest |
On the server side, in addition to the data declarations, the DDS holds the clauses of any constraint expression that may have accompanied the data request from the DAP2 client. The DDS object includes methods for modifying the DDS according to the given constraint expression. It also has methods for directly modifying a DDS, and for transmitting it from a server to a client.
For the client, the DDS object includes methods for reading the persistent form of the object sent from a server. This includes parsing the ASCII representation of the object and, possibly, reading data received from a server into a data object.
Note that the class DDS is used to instantiate both DDS and DataDDS objects. A DDS that is empty (contains no actual data) is used by servers to send structural information to the client. The same DDS can becomes a DataDDS when data values are bound to the variables it defines.
For a complete description of the DDS layout and protocol, please refer to The OPeNDAP User Guide.
The DDS has an ASCII representation, which is what is transmitted from a DAP2 server to a client. Here is the DDS representation of an entire dataset containing a time series of worldwide grids of sea surface temperatures:
Dataset { Float64 lat[lat = 180]; Float64 lon[lon = 360]; Float64 time[time = 404]; Grid { ARRAY: Int32 sst[time = 404][lat = 180][lon = 360]; MAPS: Float64 time[time = 404]; Float64 lat[lat = 180]; Float64 lon[lon = 360]; } sst; } weekly;
If the data request to this dataset includes a constraint expression, the corresponding DDS might be different. For example, if the request was only for northern hemisphere data at a specific time, the above DDS might be modified to appear like this:
Dataset { Grid { ARRAY: Int32 sst[time = 1][lat = 90][lon = 360]; MAPS: Float64 time[time = 1]; Float64 lat[lat = 90]; Float64 lon[lon = 360]; } sst; } weekly;
Since the constraint has narrowed the area of interest, the range of latitude values has been halved, and there is only one time value in the returned array. Note that the simple arrays (lat
, lon
, and time
) described in the dataset are also part of the sst
Grid object. They can be requested by themselves or as part of that larger object.
See the The OPeNDAP User Guide, or the documentation of the BaseType class for descriptions of the DAP2 data types.
Update: I removed the DEFAULT_BASETYPE_FACTORY switch because it caused more confusion than it avoided. See Trac #130. jhrg
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.
Definition at line 172 of file DDS.h.
typedef std::vector<BaseType *>::const_iterator DDS::Vars_citer |
typedef std::vector<BaseType *>::iterator DDS::Vars_iter |
typedef std::vector<BaseType *>::reverse_iterator DDS::Vars_riter |
DDS::DDS | ( | BaseTypeFactory * | factory, | |
const string & | n = "" | |||
) |
Make a DDS which uses the given BaseTypeFactory to create variables.
n | The name of the dataset. Can also be set using the set_dataset_name() method. | |
factory | BaseTypeFactory which instantiates Byte, ..., Grid. The caller is responsible for freeing the object after deleting this DDS. Can also be set using set_factory(). Never delete until just before deleting the DDS itself unless you intend to replace the factory with a new instance. | |
n | The name of the data set. Can also be set using set_dataset_name(). |
DDS::DDS | ( | const DDS & | rhs | ) |
The DDS copy constructor.
Definition at line 112 of file DDS.cc.
References duplicate().
Here is the call graph for this function:
void DDS::add_var | ( | BaseType * | bt | ) |
bt | Source variable. |
Definition at line 349 of file DDS.cc.
References DBG2, and BaseType::ptr_duplicate().
Referenced by duplicate().
Here is the call graph for this function:
bool DDS::check_semantics | ( | bool | all = false |
) |
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.
all | If true, recursively check the individual members of compound variables. |
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 | i | ) |
void DDS::del_var | ( | const string & | n | ) |
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.
n | The name of the variable to remove. |
void DDS::dump | ( | ostream & | strm | ) | const [virtual] |
Displays the pointer value of this instance and then calls parent dump
strm | C++ i/o stream to dump the information to |
Implements DapObj.
Reimplemented in DataDDS.
Definition at line 873 of file DDS.cc.
References AttrTable::dump(), DapIndent::Indent(), DapIndent::LMarg(), and DapIndent::UnIndent().
Referenced by DataDDS::dump().
Here is the call graph for this function:
void DDS::duplicate | ( | const DDS & | dds | ) | [protected] |
Definition at line 84 of file DDS.cc.
References add_var(), d_factory, name, var_begin(), and var_end().
Referenced by DDS(), and operator=().
Here is the call graph for this function:
Definition at line 473 of file DDS.cc.
References DBG2, BaseType::name(), BaseType::var(), and var().
Referenced by var().
Here is the call graph for this function:
void DDS::filename | ( | const string & | fn | ) |
AttrTable * DDS::find_matching_container | ( | AttrTable::entry * | source, | |
BaseType ** | dest_variable | |||
) | [protected, virtual] |
Given an attribute container from a DAS, find or make a destination for its contents in the DDS.
source | Attribute table | |
dest_variable | result param that holds the BaseType |
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 var().
Referenced by transfer_attributes().
Here is the call graph for this function:
AttrTable & DDS::get_attr_table | ( | ) | [virtual] |
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 |
BaseTypeFactory* DDS::get_factory | ( | ) | const [inline] |
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.
Definition at line 234 of file DDS.h.
Referenced by Connect::request_ddx().
BaseType * DDS::get_var_index | ( | int | i | ) |
DDS::Vars_iter DDS::get_vars_iter | ( | int | i | ) |
bool DDS::mark | ( | const string & | n, | |
bool | state | |||
) |
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.
Definition at line 826 of file DDS.cc.
References DBG2, BaseType::name(), BaseType::set_send_p(), and var().
Here is the call graph for this function:
void DDS::mark_all | ( | bool | state | ) |
Definition at line 127 of file DDS.cc.
References duplicate().
Here is the call graph for this function:
void DDS::parse | ( | FILE * | in = stdin |
) |
in | Read the persistent DDS from this FILE*. |
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 | ) |
void DDS::parse | ( | string | fname | ) |
Definition at line 598 of file DDS.cc.
References can_not_read_file.
Referenced by 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 | ) |
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 | ) |
Print those parts (variables) of the DDS structure to OS that are marked to be sent after evaluating the constraint expression.
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 | |||
) |
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.
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(), var_begin(), and 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 | ) |
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] |
void DDS::set_timeout | ( | int | t | ) |
void DDS::tag_nested_sequences | ( | ) |
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 | ( | ) |
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 | ( | ) |
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] |
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.
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, 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:
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.
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. |
Definition at line 443 of file DDS.cc.
References exact_match(), leaf_match(), and www2id().
Here is the call graph for this function:
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.
Definition at line 419 of file DDS.cc.
Referenced by exact_match(), find_matching_container(), and mark().
DDS::Vars_iter DDS::var_begin | ( | ) |
Definition at line 506 of file DDS.cc.
Referenced by DODSFilter::dataset_constraint(), duplicate(), and print_xml().
DDS::Vars_iter DDS::var_end | ( | ) |
Definition at line 518 of file DDS.cc.
Referenced by DODSFilter::dataset_constraint(), duplicate(), and print_xml().
DDS::Vars_riter DDS::var_rbegin | ( | ) |
DDS::Vars_riter DDS::var_rend | ( | ) |