libdap Updated for version 3.21.1
libdap4 is an implementation of OPeNDAP's DAP protocol.
libdap::DMR Class Reference

#include <DMR.h>

Inheritance diagram for libdap::DMR:
Inheritance graph
Collaboration diagram for libdap::DMR:
Collaboration graph

Public Member Functions

virtual void build_using_dds (DDS &dds)
 
int dap_major () const
 
int dap_minor () const
 
std::string dap_version () const
 
 DMR ()=default
 
 DMR (const DMR &dmr)
 
 DMR (D4BaseTypeFactory *factory, const std::string &name="")
 
 DMR (D4BaseTypeFactory *factory, DDS &dds)
 Build a DMR using a DAP2 DDS.
 
std::string dmr_version () const
 
void dump (std::ostream &strm) const override
 dumps information about this object
 
virtual D4BaseTypeFactoryfactory ()
 
std::string filename () const
 
bool get_ce_empty () const
 Get the flag that marks the expression constraint as empty.
 
bool get_global_dio_flag () const
 
std::string get_namespace () const
 Get the namespace associated with the DMR.
 
bool get_utf8_xml_encoding () const
 
virtual DDSgetDDS ()
 Build a DDS from a DMR.
 
virtual bool is_dap4_projected (std::vector< string > &inventory)
 Scans the inventory of projected variables and their attributes for projected DAP4 types. As it locates projected DAP4 types it adds a description of each to the vector inventory.
 
std::string name () const
 
bool OK () const
 
DMRoperator= (const DMR &rhs)
 
void print_dap4 (XMLWriter &xml, bool constrained=false)
 
long request_size (bool constrained)
 Get the estimated response size, in kilobytes.
 
uint64_t request_size_kb (bool constrained)
 Compute the estimated response size, in kilobytes.
 
std::string request_xml_base () const
 Get the URL that will return this DMR.
 
long response_limit () const
 Get the maximum response size, in KB. Zero indicates no limit.
 
uint64_t response_limit_kb () const
 Get the maximum response size, in KB. Zero indicates no limit.
 
D4Grouproot ()
 
void set_ce_empty (bool ce_empty)
 Set the flag that marks the expression constraint as empty.
 
void set_dap_version (const std::string &version_string)
 
void set_dmr_version (const std::string &v)
 
virtual void set_factory (D4BaseTypeFactory *f)
 
void set_filename (const std::string &fn)
 
void set_global_dio_flag (bool dio_flag_value=true)
 
void set_name (const std::string &n)
 
void set_namespace (const std::string &ns)
 Set the namespace for this DMR.
 
void set_request_xml_base (const std::string &xb)
 
void set_response_limit (long size)
 
void set_response_limit_kb (const uint64_t &size)
 
void set_utf8_xml_encoding (bool encoding_value=true)
 
bool too_big ()
 
 ~DMR () override
 

Protected Member Functions

void m_duplicate (const DMR &dmr)
 Copy the contents of the given DMR into this one. This is defined because the we perform a deep copy of the root group object.
 

Friends

class DMRTest
 
class MockDMR
 

Detailed Description

DMR is root object for a DAP4 dataset. It holds a D4Group and other information about the dataset (DAP protocol number, DMR version, etc.).

Note
This class holds the dataset name and filename (which might actually be a database name, but it's usually a filename). The variables of a DAP4 dataset are held by the D4Group instance (which is a child of Constructor).

Definition at line 56 of file DMR.h.

Constructor & Destructor Documentation

◆ DMR() [1/4]

libdap::DMR::DMR ( )
default

◆ DMR() [2/4]

libdap::DMR::DMR ( const DMR & rhs)

The DMR copy constructor.

Definition at line 127 of file DMR.cc.

◆ DMR() [3/4]

libdap::DMR::DMR ( D4BaseTypeFactory * factory,
const std::string & name = "" )
explicit

Make a DMR which uses the given BaseTypeFactory to create variables.

Note
The default DAP version is 4.0 - use the DDS class to make DAP2 things. The default DMR version is 1.0
Parameters
factoryThe D4BaseTypeFactory to use when creating instances of DAP4 variables. The caller must ensure the factory's lifetime is at least that of the DMR instance.
nameThe name of the DMR - usually derived from the name of the pathname or table name of the dataset.

Definition at line 99 of file DMR.cc.

◆ DMR() [4/4]

libdap::DMR::DMR ( D4BaseTypeFactory * factory,
DDS & dds )

Build a DMR using a DAP2 DDS.

Given a DDS from code written for DAP2, build a DAP4 DMR object. This works because DAP4 subsumes DAP2, but there are a few quirks... For each variable in the DDS, transform it to the equivalent DAP4 variable type and then copy the variable's attributes. Most types convert easily. Types that need special treatment are: Array: DAP2 array dimensions must be morphed to DAP4 Sequence: Make a D4Sequence Grid: Make a coverage; assume Grids with the same dimension names have 'shared dimensions' and that maps with the same names are shared too.

Note
Assume that a DDS has only a root group. This is not actually true for a DDS from the HDF5 handler, because it has Groups encoded into the variable names. jhrg 3/18/14
Parameters
factoryFactory class used to make new variables
ddsGet the variables to convert from this DAP2 DDS.
See also
BaseType::transform_to_dap4()

Definition at line 121 of file DMR.cc.

◆ ~DMR()

libdap::DMR::~DMR ( )
override

Delete a DMR. The BaseType factory is not freed, while the contained group is.

Definition at line 132 of file DMR.cc.

Member Function Documentation

◆ build_using_dds()

void libdap::DMR::build_using_dds ( DDS & dds)
virtual

If we have a DDS that includes Attributes, use it to build the DMR. This will copy all of the variables in the DDS into the DMR using BaseType::transform_to_dap4(), so the actual types added can be controlled by code that specializes the various type classes.

Parameters
ddsRead variables and Attributes from this DDS

Definition at line 151 of file DMR.cc.

◆ dap_major()

int libdap::DMR::dap_major ( ) const
inline

Definition at line 148 of file DMR.h.

◆ dap_minor()

int libdap::DMR::dap_minor ( ) const
inline

Definition at line 149 of file DMR.h.

◆ dap_version()

std::string libdap::DMR::dap_version ( ) const
inline

Definition at line 146 of file DMR.h.

◆ dmr_version()

std::string libdap::DMR::dmr_version ( ) const
inline

Definition at line 151 of file DMR.h.

◆ dump()

void libdap::DMR::dump ( std::ostream & strm) const
overridevirtual

dumps information about this object

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

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

Implements libdap::DapObj.

Definition at line 362 of file DMR.cc.

◆ factory()

virtual D4BaseTypeFactory * libdap::DMR::factory ( )
inlinevirtual

Get/set the factory which makes instances of the variables. Specialize D4BaseTypeFactory so that a DMR will be populated with your client's or server's specialized types.

Definition at line 133 of file DMR.h.

◆ filename()

std::string libdap::DMR::filename ( ) const
inline

get/set the dataset's 'filename.' The filename is a string that can be used to access the dataset via some data store (it's usually a pathname to a file, but it might be a database key).

Definition at line 142 of file DMR.h.

◆ get_ce_empty()

bool libdap::DMR::get_ce_empty ( ) const
inline

Get the flag that marks the expression constraint as empty.

Definition at line 213 of file DMR.h.

◆ get_global_dio_flag()

bool libdap::DMR::get_global_dio_flag ( ) const
inline

Definition at line 230 of file DMR.h.

◆ get_namespace()

std::string libdap::DMR::get_namespace ( ) const
inline

Get the namespace associated with the DMR.

Definition at line 161 of file DMR.h.

◆ get_utf8_xml_encoding()

bool libdap::DMR::get_utf8_xml_encoding ( ) const
inline

Definition at line 234 of file DMR.h.

◆ getDDS()

DDS * libdap::DMR::getDDS ( )
virtual

Build a DDS from a DMR.

Build a DDS from a DMR, collapsing DAP4 Groups, transforming Arrays to Grids as needed, and moving the attributes around to match the new variables. All of the variables in the returned DDS object are newly allocated with separate lifetimes from the objects in the DMR. They are made using ptr_duplicate() so that all of the variables mirror specializations for the various types. That is, if the HDF5 handler built the DMR, then the resulting DDS will hold instances of H5Int32, etc.

Note
The caller is responsible for deleting the resulting DDS object.
Returns
A pointer to the newly allocated DDS.

Definition at line 194 of file DMR.cc.

◆ is_dap4_projected()

bool libdap::DMR::is_dap4_projected ( std::vector< string > & inventory)
virtual

Scans the inventory of projected variables and their attributes for projected DAP4 types. As it locates projected DAP4 types it adds a description of each to the vector inventory.

Parameters
inventory
Returns
true when dap4 types have been requested, false otherwise.

Definition at line 343 of file DMR.cc.

◆ m_duplicate()

void libdap::DMR::m_duplicate ( const DMR & dmr)
protected

Copy the contents of the given DMR into this one. This is defined because the we perform a deep copy of the root group object.

Parameters
dmr

Definition at line 60 of file DMR.cc.

◆ name()

std::string libdap::DMR::name ( ) const
inline

Get and set the DMR's name. This is effectively the 'dataset' name. It should not be used to reference the dataset's data store (e.g., it should not be a pathname to a file). This will be used in error messages.

Definition at line 125 of file DMR.h.

◆ OK()

bool libdap::DMR::OK ( ) const
inline

Class invariant. If true, any method can be used.

Returns
True if the instance is OK to use, false otherwise.

Definition at line 117 of file DMR.h.

◆ operator=()

DMR & libdap::DMR::operator= ( const DMR & rhs)

Definition at line 134 of file DMR.cc.

◆ print_dap4()

void libdap::DMR::print_dap4 ( XMLWriter & xml,
bool constrained = false )

Print the DAP4 DMR object.

Parameters
xmluse this XMLWriter to build the XML.
constrainedShould the DMR be subject to a constraint? Defaults to False

Definition at line 306 of file DMR.cc.

◆ request_size()

long libdap::DMR::request_size ( bool constrained)

Get the estimated response size, in kilobytes.

Get the size of a response, in kilobytes. This method looks at the variables in the DMR a computes the number of bytes in the response.

Note
This version of the method does a poor job with Arrays that have varying dimensions.
Parameters
constrainedShould the size of the whole DMR be used or should the current constraint be taken into account?
Returns
The size of the request in kilobytes
Deprecated
"Use DMR::request_size_kb()"

Definition at line 285 of file DMR.cc.

◆ request_size_kb()

uint64_t libdap::DMR::request_size_kb ( bool constrained)

Compute the estimated response size, in kilobytes.

Parameters
constrained
Returns
The estimated response size, in kilobytes.

Get the size of a response, in kilobytes. This method looks at the variables in the DMR a computes the number of bytes in the response.

Note
This version of the method does a poor job with Arrays that have varying dimensions.
Parameters
constrainedShould the size of the whole DMR be used or should the current constraint be taken into account?
Returns
The size of the request in kilobytes

Definition at line 297 of file DMR.cc.

◆ request_xml_base()

std::string libdap::DMR::request_xml_base ( ) const
inline

Get the URL that will return this DMR.

Definition at line 155 of file DMR.h.

◆ response_limit()

long libdap::DMR::response_limit ( ) const
inline

Get the maximum response size, in KB. Zero indicates no limit.

Returns
The maximum allowable response size. A value of 0 means there is no limit (default).

Definition at line 171 of file DMR.h.

◆ response_limit_kb()

uint64_t libdap::DMR::response_limit_kb ( ) const
inline

Get the maximum response size, in KB. Zero indicates no limit.

Returns
The maximum allowable response size. A value of 0 means there is no limit (default).

Definition at line 178 of file DMR.h.

◆ root()

D4Group * libdap::DMR::root ( )

Return the root group of this Dataset. If no root group has been set, use the D4BaseType factory to make it.

Returns
The root group of the dataset.

Get the root group for this DMR. This accessor allocates the root group if one does not exist using the factory class bound to this DMR

Returns
A pointer to the root group.

Definition at line 228 of file DMR.cc.

◆ set_ce_empty()

void libdap::DMR::set_ce_empty ( bool ce_empty)
inline

Set the flag that marks the expression constraint as empty.

Definition at line 210 of file DMR.h.

◆ set_dap_version()

void libdap::DMR::set_dap_version ( const std::string & version_string)

Given the DAP protocol version, parse that string and set the DMR fields.

Parameters
vThe version string.

Definition at line 239 of file DMR.cc.

◆ set_dmr_version()

void libdap::DMR::set_dmr_version ( const std::string & v)
inline

Definition at line 152 of file DMR.h.

◆ set_factory()

virtual void libdap::DMR::set_factory ( D4BaseTypeFactory * f)
inlinevirtual

Definition at line 134 of file DMR.h.

◆ set_filename()

void libdap::DMR::set_filename ( const std::string & fn)
inline

Definition at line 143 of file DMR.h.

◆ set_global_dio_flag()

void libdap::DMR::set_global_dio_flag ( bool dio_flag_value = true)
inline

Definition at line 231 of file DMR.h.

◆ set_name()

void libdap::DMR::set_name ( const std::string & n)
inline

Definition at line 126 of file DMR.h.

◆ set_namespace()

void libdap::DMR::set_namespace ( const std::string & ns)
inline

Set the namespace for this DMR.

Definition at line 164 of file DMR.h.

◆ set_request_xml_base()

void libdap::DMR::set_request_xml_base ( const std::string & xb)
inline
See also
get_request_xml_base

Definition at line 158 of file DMR.h.

◆ set_response_limit()

void libdap::DMR::set_response_limit ( long size)
inline

Set the maximum response size. Zero is the default value. The size is given in kilobytes.

Parameters
sizeThe maximum size of the response in kilobytes.

Definition at line 185 of file DMR.h.

◆ set_response_limit_kb()

void libdap::DMR::set_response_limit_kb ( const uint64_t & size)
inline

Set the maximum response size. Zero is the default value and indicates there is no limit. The size is given in kilobytes.

Parameters
sizeThe maximum size of the response in kilobytes.

Definition at line 192 of file DMR.h.

◆ set_utf8_xml_encoding()

void libdap::DMR::set_utf8_xml_encoding ( bool encoding_value = true)
inline

Definition at line 235 of file DMR.h.

◆ too_big()

bool libdap::DMR::too_big ( )
inline
Returns
Returns true if the total data bytes requested exceeds the set limit, false otherwise.

Definition at line 207 of file DMR.h.

Friends And Related Symbol Documentation

◆ DMRTest

friend class DMRTest
friend

Definition at line 94 of file DMR.h.

◆ MockDMR

friend class MockDMR
friend

Definition at line 95 of file DMR.h.


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