libdap++
Updated for version 3.14.0
|
#include <DDS.h>
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. More... | |
void | add_var_nocopy (BaseType *bt) |
Adds the variable to the DDS. More... | |
bool | check_semantics (bool all=false) |
Check the semantics of each of the variables represented in the DDS. More... | |
DDS (BaseTypeFactory *factory, const string &name="") | |
DDS (BaseTypeFactory *factory, const string &name, const string &version) | |
DDS (const DDS &dds) | |
void | del_var (const string &n) |
Removes a variable from the DDS. More... | |
void | del_var (Vars_iter i) |
Removes a variable from the DDS. More... | |
void | del_var (Vars_iter i1, Vars_iter i2) |
Removes a range of variables from the DDS. More... | |
virtual void | dump (ostream &strm) const |
dumps information about this object More... | |
virtual AttrTable & | get_attr_table () |
int | get_dap_major () const |
Get the DAP major version as sent by the client. More... | |
int | get_dap_minor () const |
Get the DAP minor version as sent by the client. More... | |
string | get_dap_version () const |
string | get_dmr_version () const |
BaseTypeFactory * | get_factory () const |
Keywords & | get_keywords () |
string | get_namespace () const |
Get the namespace associated with the DDS - likely set only by DDX responses. More... | |
int | get_request_size (bool constrained) |
Get the estimated response size. More... | |
string | get_request_xml_base () const |
Get the URL that will return this DDS/DDX/DataThing. More... | |
long | get_response_limit () |
Get the maximum response size, in KB. Zero indicates no limit. More... | |
int | get_timeout () |
BaseType * | get_var_index (int i) |
Get a variable. More... | |
Vars_iter | get_vars_iter (int i) |
Get an iterator. More... | |
void | insert_var (Vars_iter i, BaseType *ptr) |
Insert a variable before the referenced element. More... | |
void | insert_var_nocopy (Vars_iter i, BaseType *ptr) |
bool | mark (const string &name, bool state) |
Mark the send_p flag of the named variable to state. More... | |
void | mark_all (bool state) |
int | num_var () |
Returns the number of variables in the DDS. More... | |
DDS & | operator= (const DDS &rhs) |
void | parse (string fname) |
Parse a DDS from a file with the given d_name. More... | |
void | parse (int fd) |
Parse a DDS from a file indicated by the input file descriptor. More... | |
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. More... | |
void | print (FILE *out) |
Print the entire DDS to the specified file. More... | |
void | print (ostream &out) |
Print the entire DDS to the specified ostream. More... | |
void | print_constrained (FILE *out) |
Print a constrained DDS to the specified file. More... | |
void | print_constrained (ostream &out) |
Print a constrained DDS to the specified ostream. More... | |
void | print_das (ostream &out) |
void | print_dmr (ostream &out, bool constrained) |
void | print_xml (FILE *out, bool constrained, const string &blob="") |
void | print_xml (ostream &out, bool constrained, const string &blob="") |
void | print_xml_writer (ostream &out, bool constrained, const string &blob="") |
void | set_dap_major (int p) |
void | set_dap_minor (int p) |
void | set_dap_version (const string &version_string="2.0") |
void | set_dap_version (double d) |
BaseTypeFactory * | set_factory (BaseTypeFactory *factory) |
void | set_namespace (const string &ns) |
Set the namespace for this DDS/DDX object/response. More... | |
void | set_request_xml_base (const string &xb) |
void | set_response_limit (long size) |
void | set_timeout (int t) |
void | tag_nested_sequences () |
Traverse DDS, set Sequence leaf nodes. More... | |
void | timeout_off () |
void | timeout_on () |
virtual void | transfer_attributes (DAS *das) |
BaseType * | var (const string &n, BaseType::btp_stack &s) |
BaseType * | var (const string &n, BaseType::btp_stack *s=0) |
Find the variable with the given d_name. More... | |
Vars_iter | var_begin () |
Return an iterator to the first variable. More... | |
Vars_iter | var_end () |
Return an iterator. More... | |
Vars_riter | var_rbegin () |
Return a reverse iterator. More... | |
Vars_riter | var_rend () |
Return a reverse iterator. More... | |
virtual | ~DDS () |
string | get_dataset_name () const |
void | set_dataset_name (const string &n) |
string | filename () const |
void | filename (const string &fn) |
string | container_name () |
void | container_name (const string &cn) |
Structure * | container () |
Protected Member Functions | |
void | duplicate (const DDS &dds) |
BaseType * | exact_match (const string &name, BaseType::btp_stack *s=0) |
BaseType * | leaf_match (const string &name, BaseType::btp_stack *s=0) |
Friends | |
class | DDSTest |
The DAP2 Data Descriptor Object (DDS) is a data structure used by the DAP2 software to describe datasets and subsets of those datasets. The DDS may be thought of as the declarations for the data structures that will hold data requested by some DAP2 client. Part of the job of a DAP2 server is to build a suitable DDS for a specific dataset and to send it to the client. Depending on the data access API in use, this may involve reading part of the dataset and inferring the DDS. Other APIs may require the server simply to read some ancillary data file with the DDS in it.
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.
typedef std::vector<BaseType *>::const_iterator libdap::DDS::Vars_citer |
typedef std::vector<BaseType *>::iterator libdap::DDS::Vars_iter |
typedef std::vector<BaseType *>::reverse_iterator libdap::DDS::Vars_riter |
libdap::DDS::DDS | ( | BaseTypeFactory * | factory, |
const string & | name = "" |
||
) |
Make a DDS which uses the given BaseTypeFactory to create variables.
factory | The BaseTypeFactory to use when creating instances of DAP variables. The caller must ensure the factory's lifetime is at least that of the DDS instance. |
name | The name of the DDS - usually derived from the name of the pathname or table name of the dataset. |
Definition at line 206 of file DDS.cc.
References DBG, and set_dap_version().
libdap::DDS::DDS | ( | BaseTypeFactory * | factory, |
const string & | name, | ||
const string & | version | ||
) |
Make a DDS with the DAP protocol set to a specific value. This method provides an easy way to build DDS objects for use in a server or client that will process DAP4, for example. It's roughly equivalent to calling set_dap_version() after making an instance using DDS::DDS(BaseTypeFactory *, const string &).
factory | The BaseTypeFactory to use when creating instances of DAP variables. The caller must ensure the factory's lifetime is at least that of the DDS instance. |
name | The name of the DDS - usually derived from the name of the pathname or table name of the dataset. |
version | The DAP version to support. This sets the DAP version, as well as a number of other dependent constants. |
Definition at line 233 of file DDS.cc.
References DBG, and set_dap_version().
libdap::DDS::DDS | ( | const DDS & | rhs | ) |
The DDS copy constructor.
Definition at line 246 of file DDS.cc.
References DBG, and duplicate().
void libdap::DDS::add_var | ( | BaseType * | bt | ) |
bt | Source variable. |
Definition at line 588 of file DDS.cc.
References libdap::Constructor::add_var(), DBG2, and libdap::BaseType::ptr_duplicate().
Referenced by container_name(), and libdap::DDXParser::ddx_end_document().
void libdap::DDS::add_var_nocopy | ( | BaseType * | bt | ) |
bt | Source variable. |
Definition at line 615 of file DDS.cc.
References libdap::Constructor::add_var_nocopy(), and DBG2.
Referenced by libdap::ConstraintEvaluator::eval_function_clauses().
bool libdap::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 recursively all ctor types in the THIS->TABLE. By default, ALL is false since parsing a DDS input file runs semantic checks on all variables (but not the dataset itself.
all | If true, recursively check the individual members of compound variables. |
Definition at line 1384 of file DDS.cc.
References libdap::unique_names().
Structure * libdap::DDS::container | ( | ) |
string libdap::DDS::container_name | ( | ) |
void libdap::DDS::container_name | ( | const string & | cn | ) |
void libdap::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 d_name given.
n | The d_name of the variable to remove. |
Definition at line 643 of file DDS.cc.
References libdap::Constructor::del_var().
void libdap::DDS::del_var | ( | Vars_iter | i | ) |
|
virtual |
Displays the pointer value of this instance and then calls parent dump
strm | C++ i/o stream to dump the information to |
Implements libdap::DapObj.
Reimplemented in libdap::DataDDS.
Definition at line 1491 of file DDS.cc.
References libdap::AttrTable::dump(), libdap::DapIndent::Indent(), libdap::DapIndent::LMarg(), and libdap::DapIndent::UnIndent().
|
protected |
Definition at line 133 of file DDS.cc.
References DBG, var_begin(), and var_end().
Referenced by DDS(), and operator=().
|
protected |
Definition at line 773 of file DDS.cc.
References DBG2, libdap::BaseType::name(), libdap::BaseType::var(), and var().
Referenced by var().
string libdap::DDS::filename | ( | ) | const |
Get and set the dataset's filename. This is the physical location on a disk where the dataset exists. The dataset d_name is simply a title.
File Name Accessor
Definition at line 389 of file DDS.cc.
Referenced by libdap::DMR::build_using_dds().
void libdap::DDS::filename | ( | const string & | fn | ) |
|
virtual |
Get the attribute table for the global attributes.
Definition at line 374 of file DDS.cc.
Referenced by libdap::DMR::build_using_dds(), libdap::DDXParser::ddx_start_document(), and libdap::DMR::DMR().
|
inline |
Definition at line 263 of file DDS.h.
Referenced by print_dmr(), and print_xml_writer().
|
inline |
Definition at line 265 of file DDS.h.
Referenced by print_xml_writer().
|
inline |
Definition at line 268 of file DDS.h.
Referenced by print_dmr(), print_xml_writer(), and libdap::Connect::read_data_no_mime().
string libdap::DDS::get_dataset_name | ( | ) | const |
Get and set the dataset's d_name. This is the d_name of the dataset itself, and is not to be confused with the d_name of the file or disk on which it is stored.
Dataset Name Accessors Returns the dataset's d_name.
Definition at line 358 of file DDS.cc.
Referenced by libdap::DMR::build_using_dds(), and libdap::ConstraintEvaluator::eval_function_clauses().
|
inline |
Definition at line 269 of file DDS.h.
Referenced by print_dmr().
|
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 239 of file DDS.h.
Referenced by libdap::ConstraintEvaluator::eval_function_clauses(), libdap::Connect::request_ddx(), and libdap::Connect::request_ddx_url().
|
inline |
Definition at line 287 of file DDS.h.
Referenced by print_dmr(), and print_xml_writer().
int libdap::DDS::get_request_size | ( | bool | constrained | ) |
Get the size of a response. This method looks at the variables in the DDS a computes the number of bytes in the response.
constrained | Should the size of the whole DDS be used or should the current constraint be taken into account? |
|
inline |
Definition at line 281 of file DDS.h.
Referenced by print_dmr(), and print_xml_writer().
BaseType * libdap::DDS::get_var_index | ( | int | i | ) |
DDS::Vars_iter libdap::DDS::get_vars_iter | ( | int | i | ) |
Insert a copy of the BaseType before the position given.
i | The iterator that marks the position |
ptr | The BaseType object to copy and insert |
Definition at line 852 of file DDS.cc.
References libdap::BaseType::ptr_duplicate().
|
protected |
Definition at line 737 of file DDS.cc.
References DBG, libdap::BaseType::is_constructor_type(), libdap::BaseType::is_vector_type(), libdap::BaseType::name(), and libdap::BaseType::var().
Referenced by var().
bool libdap::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 1430 of file DDS.cc.
References DBG2, libdap::BaseType::set_send_p(), libdap::BaseType::type_name(), and var().
void libdap::DDS::mark_all | ( | bool | state | ) |
Definition at line 263 of file DDS.cc.
References DBG, and duplicate().
void libdap::DDS::parse | ( | string | fname | ) |
Definition at line 929 of file DDS.cc.
References cannot_read_file.
Referenced by parse(), libdap::Ancillary::read_ancillary_dds(), libdap::Connect::request_dds(), and libdap::Connect::request_dds_url().
void libdap::DDS::parse | ( | int | fd | ) |
void libdap::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 979 of file DDS.cc.
References DBG2, dds_buffer(), dds_delete_buffer(), dds_switch_to_buffer(), ddsparse(), libdap::parser_arg::error(), and libdap::parser_arg::status().
void libdap::DDS::print | ( | FILE * | out | ) |
Definition at line 1006 of file DDS.cc.
Referenced by main(), and libdap::DODSFilter::send_dds().
void libdap::DDS::print | ( | ostream & | out | ) |
Definition at line 1015 of file DDS.cc.
References libdap::id2www().
void libdap::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 1061 of file DDS.cc.
Referenced by libdap::DODSFilter::dataset_constraint(), and libdap::DODSFilter::send_dds().
void libdap::DDS::print_constrained | ( | ostream & | 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 1079 of file DDS.cc.
References libdap::id2www().
void libdap::DDS::print_das | ( | ostream & | out | ) |
Print the DAP2 DAS object using attribute information recorded this DDS object.
out | Write the DAS here. |
Definition at line 1038 of file DDS.cc.
References libdap::AttrTable::print().
void libdap::DDS::print_dmr | ( | ostream & | out, |
bool | constrained | ||
) |
Print the DAP4 DMR object. This method prints the DMR. If the dap version is not >= 4.0, it's an error to call this method.
out | Write the XML to this stream |
constrained | Should the DMR be subject to a constraint? |
Definition at line 1295 of file DDS.cc.
References c_dap_40_n_sl, c_xml_namespace, c_xml_xsi, get_dap_major(), get_dap_version(), get_dmr_version(), libdap::XMLWriter::get_doc(), get_namespace(), get_request_xml_base(), libdap::XMLWriter::get_writer(), libdap::AttrTable::print_xml_writer(), var_begin(), and var_end().
void libdap::DDS::print_xml | ( | FILE * | out, |
bool | constrained, | ||
const string & | blob = "" |
||
) |
Print an XML representation 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 1107 of file DDS.cc.
References print_xml_writer().
Referenced by main().
void libdap::DDS::print_xml | ( | ostream & | out, |
bool | constrained, | ||
const string & | blob = "" |
||
) |
Print an XML representation 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 ostream. |
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 1126 of file DDS.cc.
References print_xml_writer().
void libdap::DDS::print_xml_writer | ( | ostream & | out, |
bool | constrained, | ||
const string & | blob = "" |
||
) |
Print the DDX. This code uses the libxml2 'TextWriter' interface; something that seems to be a good compromise between doing it by hand (although more verbose it is also more reliable) and DOM.
out | Write the XML to this output sink |
constrained | True if the only variables to print are those in the current projection. If true, this will also suppress printing attributes. |
blob | This is an href (DAP2) or a cid (DAP3.4 and 4). The href points to the binary data; the cid is the M-MIME separator for the binary data. |
Definition at line 1162 of file DDS.cc.
References c_dap20_namespace, c_dap32_namespace, c_dap_20_n_sl, c_dap_32_n_sl, c_xml_namespace, get_dap_major(), get_dap_minor(), get_dap_version(), libdap::XMLWriter::get_doc(), get_namespace(), get_request_xml_base(), libdap::XMLWriter::get_writer(), grddl_transformation_dap32, libdap::AttrTable::print_xml_writer(), var_begin(), and var_end().
Referenced by libdap::DODSFilter::dataset_constraint_ddx(), print_xml(), and libdap::DODSFilter::send_ddx().
void libdap::DDS::set_dap_major | ( | int | p | ) |
void libdap::DDS::set_dap_minor | ( | int | p | ) |
void libdap::DDS::set_dap_version | ( | const string & | v = "2.0" | ) |
Given the DAP protocol version, parse that string and set the DDS fields.
v | The version string. |
Definition at line 442 of file DDS.cc.
References c_dap20_namespace, c_dap32_namespace, and c_dap40_namespace.
Referenced by DDS(), libdap::DDXParser::ddx_sax2_start_element(), and set_dap_version().
void libdap::DDS::set_dap_version | ( | double | d | ) |
Old way to set the DAP version.
d | The protocol version requested by the client, as a double. |
Definition at line 490 of file DDS.cc.
References DBG, and set_dap_version().
void libdap::DDS::set_dataset_name | ( | const string & | n | ) |
Sets the dataset d_name.
Definition at line 365 of file DDS.cc.
Referenced by libdap::DDXParser::ddx_sax2_start_element().
|
inline |
|
inline |
|
inline |
void libdap::DDS::set_timeout | ( | int | t | ) |
Definition at line 902 of file DDS.cc.
Referenced by libdap::DODSFilter::send_data(), and libdap::DODSFilter::send_data_ddx().
void libdap::DDS::tag_nested_sequences | ( | ) |
Definition at line 917 of file DDS.cc.
References libdap::dods_sequence_c, and libdap::dods_structure_c.
Referenced by libdap::DODSFilter::send_data(), and libdap::DODSFilter::send_data_ddx().
void libdap::DDS::timeout_off | ( | ) |
Definition at line 894 of file DDS.cc.
Referenced by libdap::BaseType::intern_data(), libdap::Sequence::read_row(), libdap::UInt16::serialize(), libdap::Int16::serialize(), libdap::Float64::serialize(), libdap::UInt32::serialize(), libdap::Byte::serialize(), libdap::Float32::serialize(), libdap::Int32::serialize(), libdap::Str::serialize(), libdap::Constructor::serialize(), and libdap::Vector::serialize().
void libdap::DDS::timeout_on | ( | ) |
Definition at line 886 of file DDS.cc.
Referenced by libdap::BaseType::intern_data(), libdap::Sequence::read_row(), libdap::UInt16::serialize(), libdap::Int16::serialize(), libdap::Float64::serialize(), libdap::UInt32::serialize(), libdap::Byte::serialize(), libdap::Float32::serialize(), libdap::Int32::serialize(), libdap::Str::serialize(), libdap::Constructor::serialize(), and libdap::Vector::serialize().
|
virtual |
This is the main method used to transfer attributes from a DAS object into a DDS. This uses the BaseType::transfer_attributes() method and the various implementations found here (in the constructors classes) and in handlers.
This method uses a deep copy to transfer the attributes, so it is safe to delete the source DAS object passed to this method once it is done.
das | Transfer (copy) attributes from this DAS object. |
Definition at line 288 of file DDS.cc.
References libdap::AttrTable::append_container(), libdap::AttrTable::attr_begin(), libdap::Attr_container, libdap::AttrTable::attr_end(), libdap::DAS::container_name(), DBG, libdap::Error::get_error_message(), libdap::AttrTable::get_name(), libdap::DAS::get_top_level_attributes(), var(), var_begin(), and var_end().
Referenced by main().
BaseType * libdap::DDS::var | ( | const string & | n, |
BaseType::btp_stack & | s | ||
) |
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 699 of file DDS.cc.
Referenced by container_name(), exact_match(), mark(), and transfer_attributes().
BaseType * libdap::DDS::var | ( | const string & | n, |
BaseType::btp_stack * | s = 0 |
||
) |
Returns a pointer to the named variable. If the d_name contains one or more field separators then the function looks for a variable whose name matches exactly. If the d_name contains no field separators then the function 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 723 of file DDS.cc.
References exact_match(), leaf_match(), libdap::Constructor::var(), and libdap::www2id().
DDS::Vars_iter libdap::DDS::var_begin | ( | ) |
Returns the first variable in the DDS.
Definition at line 806 of file DDS.cc.
Referenced by libdap::DMR::build_using_dds(), libdap::DODSFilter::dataset_constraint(), libdap::DODSFilter::dataset_constraint_ddx(), libdap::DMR::DMR(), duplicate(), print_dmr(), print_xml_writer(), and transfer_attributes().
DDS::Vars_iter libdap::DDS::var_end | ( | ) |
Definition at line 818 of file DDS.cc.
Referenced by libdap::DMR::build_using_dds(), libdap::DODSFilter::dataset_constraint(), libdap::DODSFilter::dataset_constraint_ddx(), libdap::DMR::DMR(), duplicate(), print_dmr(), print_xml_writer(), and transfer_attributes().
DDS::Vars_riter libdap::DDS::var_rbegin | ( | ) |
DDS::Vars_riter libdap::DDS::var_rend | ( | ) |