OPeNDAP Hyrax Back End Server (BES)  Updated for version 3.8.3
BESDapResponseBuilder Class Reference

This class is used to build responses for/by the BES. More...

#include <BESDapResponseBuilder.h>

Collaboration diagram for BESDapResponseBuilder:
Collaboration graph

Public Member Functions

 BESDapResponseBuilder ()
 Make an empty instance. More...
 
virtual void dataset_constraint (std::ostream &out, libdap::DDS &dds, libdap::ConstraintEvaluator &eval, bool ce_eval=true)
 Build/return the BLOB part of the DAP2 data response. More...
 
virtual void dataset_constraint_ddx (std::ostream &out, libdap::DDS &dds, libdap::ConstraintEvaluator &eval, const std::string &boundary, const std::string &start, bool ce_eval=true)
 Build/return the DDX and the BLOB part of the DAP3.x data response. More...
 
virtual void establish_timeout (std::ostream &stream) const
 Use values of this instance to establish a timeout alarm for the server. More...
 
virtual std::string get_btp_func_ce () const
 
virtual std::string get_ce () const
 Return the entire constraint expression in a string. More...
 
virtual std::string get_dataset_name () const
 The ``dataset name'' is the filename or other string that the filter program will use to access the data. More...
 
int get_timeout () const
 Get the server's timeout value. More...
 
virtual BESDapResponseCacheresponseCache ()
 Lazy getter for the ResponseCache. More...
 
virtual void send_das (std::ostream &out, libdap::DAS &das, bool with_mime_headers=true) const
 
virtual void send_das (std::ostream &out, libdap::DDS &dds, libdap::ConstraintEvaluator &eval, bool constrained=false, bool with_mime_headers=true)
 
virtual void send_data (std::ostream &data_stream, libdap::DDS &dds, libdap::ConstraintEvaluator &eval, bool with_mime_headers=true)
 Send the data in the DDS object back to the client program. More...
 
virtual void send_data_ddx (std::ostream &data_stream, libdap::DDS &dds, libdap::ConstraintEvaluator &eval, const std::string &start, const std::string &boundary, bool with_mime_headers=true)
 Send the data in the DDS object back to the client program. More...
 
virtual void send_dds (std::ostream &out, libdap::DDS &dds, libdap::ConstraintEvaluator &eval, bool constrained=false, bool with_mime_headers=true)
 This function formats and prints an ASCII representation of a DDS on stdout. More...
 
virtual void send_ddx (std::ostream &out, libdap::DDS &dds, libdap::ConstraintEvaluator &eval, bool with_mime_headers=true)
 Send the DDX response. More...
 
virtual void set_btp_func_ce (std::string _ce)
 
virtual void set_ce (std::string _ce)
 Set the constraint expression. More...
 
virtual void set_dataset_name (const std::string _dataset)
 Set the dataset name, which is a string used to access the dataset on the machine running the server. More...
 
void set_timeout (int timeout=0)
 Set the server's timeout value. More...
 
virtual void split_ce (libdap::ConstraintEvaluator &eval, const std::string &expr="")
 Split the CE so that the server functions that compute new values are separated into their own string and can be evaluated separately from the rest of the CE (which can contain simple and slicing projection as well as other types of function calls). More...
 
virtual ~BESDapResponseBuilder ()
 

Protected Member Functions

void initialize ()
 Called when initializing a ResponseBuilder that's not going to be passed command line arguments. More...
 

Protected Attributes

std::string d_btp_func_ce
 Constraint expression. More...
 
std::string d_ce
 Name of the dataset/database. More...
 
std::string d_dataset
 
std::string d_default_protocol
 Response timeout after N seconds. More...
 
BESDapResponseCached_response_cache
 Version std::string for the library's default protocol version. More...
 
int d_timeout
 The BTP functions, extracted from the CE. More...
 

Friends

class ResponseBuilderTest
 

Detailed Description

This class is used to build responses for/by the BES.

This class replaces DODSFilter (although DODSFilter is still included in the library, its use is deprecated). and it does not have a provision for command line arguments.

Author
jhrg 1/28/2011

Definition at line 45 of file BESDapResponseBuilder.h.

Constructor & Destructor Documentation

BESDapResponseBuilder::BESDapResponseBuilder ( )
inline

Make an empty instance.

Use the set_*() methods to load with needed values. You must call at least set_dataset_name() or be requesting version information.

Definition at line 65 of file BESDapResponseBuilder.h.

References initialize().

Here is the call graph for this function:

BESDapResponseBuilder::~BESDapResponseBuilder ( )
virtual

Definition at line 107 of file BESDapResponseBuilder.cc.

Member Function Documentation

void BESDapResponseBuilder::dataset_constraint ( std::ostream &  out,
libdap::DDS &  dds,
libdap::ConstraintEvaluator &  eval,
bool  ce_eval = true 
)
virtual

Build/return the BLOB part of the DAP2 data response.

Definition at line 475 of file BESDapResponseBuilder.cc.

void BESDapResponseBuilder::dataset_constraint_ddx ( std::ostream &  out,
libdap::DDS &  dds,
libdap::ConstraintEvaluator &  eval,
const std::string &  boundary,
const std::string &  start,
bool  ce_eval = true 
)
virtual

Build/return the DDX and the BLOB part of the DAP3.x data response.

This was never actually used by any server or client, but it has been used to cache responses for some of the OPULS unstructured grid work. It was originally intended to be used for DAP4.

Definition at line 504 of file BESDapResponseBuilder.cc.

Referenced by BESDapResponseCache::cache_dataset(), and BESStoredDapResultCache::cache_dataset().

void BESDapResponseBuilder::establish_timeout ( std::ostream &  stream) const
virtual

Use values of this instance to establish a timeout alarm for the server.

If the timeout value is zero, do nothing.

Definition at line 190 of file BESDapResponseBuilder.cc.

virtual std::string BESDapResponseBuilder::get_btp_func_ce ( ) const
inlinevirtual

Definition at line 75 of file BESDapResponseBuilder.h.

References d_btp_func_ce.

string BESDapResponseBuilder::get_ce ( ) const
virtual

Return the entire constraint expression in a string.

This includes both the projection and selection clauses, but not the question mark.

Get the constraint expression.

Returns
A string object that contains the constraint expression.

Definition at line 123 of file BESDapResponseBuilder.cc.

string BESDapResponseBuilder::get_dataset_name ( ) const
virtual

The ``dataset name'' is the filename or other string that the filter program will use to access the data.

In some cases this will indicate a disk file containing the data. In others, it may represent a database query or some other exotic data access method.

Get the dataset name.

Returns
A string object that contains the name of the dataset.

Definition at line 151 of file BESDapResponseBuilder.cc.

Referenced by BESDapResponseCache::cache_dataset(), and BESStoredDapResultCache::cache_dataset().

int BESDapResponseBuilder::get_timeout ( ) const

Get the server's timeout value.

Definition at line 182 of file BESDapResponseBuilder.cc.

void BESDapResponseBuilder::initialize ( )
protected

Called when initializing a ResponseBuilder that's not going to be passed command line arguments.

Definition at line 83 of file BESDapResponseBuilder.cc.

References DAP_PROTOCOL_VERSION.

Referenced by BESDapResponseBuilder().

BESDapResponseCache * BESDapResponseBuilder::responseCache ( )
virtual

Lazy getter for the ResponseCache.

Definition at line 99 of file BESDapResponseBuilder.cc.

References BESDapResponseCache::get_instance().

Here is the call graph for this function:

virtual void BESDapResponseBuilder::send_das ( std::ostream &  out,
libdap::DAS &  das,
bool  with_mime_headers = true 
) const
virtual
virtual void BESDapResponseBuilder::send_das ( std::ostream &  out,
libdap::DDS &  dds,
libdap::ConstraintEvaluator &  eval,
bool  constrained = false,
bool  with_mime_headers = true 
)
virtual
void BESDapResponseBuilder::send_data ( std::ostream &  data_stream,
libdap::DDS &  dds,
libdap::ConstraintEvaluator &  eval,
bool  with_mime_headers = true 
)
virtual

Send the data in the DDS object back to the client program.

The data is encoded using a Marshaller, and enclosed in a MIME document which is all sent to data_stream.

Note
This is the DAP2 data response.

Transmit data.

Parameters
ddsA DDS object containing the data to be sent.
evalA reference to the ConstraintEvaluator to use.
data_streamWrite the response to this stream.
anc_locationA directory to search for ancillary files (in addition to the CWD). This is used in a call to get_data_last_modified_time().
with_mime_headersIf true, include the MIME headers in the response. Defaults to true.
Returns
void

Definition at line 554 of file BESDapResponseBuilder.cc.

References BESDEBUG.

void BESDapResponseBuilder::send_data_ddx ( std::ostream &  data_stream,
libdap::DDS &  dds,
libdap::ConstraintEvaluator &  eval,
const std::string &  start,
const std::string &  boundary,
bool  with_mime_headers = true 
)
virtual

Send the data in the DDS object back to the client program.

The data is encoded using a Marshaller, and enclosed in a MIME document which is all sent to data_stream.

Note
This is not the DAP4 data response, although that was the original intent.

Transmit data.

Parameters
ddsA DDS object containing the data to be sent.
evalA reference to the ConstraintEvaluator to use.
data_streamWrite the response to this stream.
anc_locationA directory to search for ancillary files (in addition to the CWD). This is used in a call to get_data_last_modified_time().
with_mime_headersIf true, include the MIME headers in the response. Defaults to true.
Returns
void

Definition at line 868 of file BESDapResponseBuilder.cc.

References CRLF.

void BESDapResponseBuilder::send_dds ( std::ostream &  out,
libdap::DDS &  dds,
libdap::ConstraintEvaluator &  eval,
bool  constrained = false,
bool  with_mime_headers = true 
)
virtual

This function formats and prints an ASCII representation of a DDS on stdout.

Either an entire DDS or a constrained DDS may be sent. This function looks in the local cache and uses a DDS object there if it's valid. Otherwise, if the request CE contains server functions that build data for the response, the resulting DDS will be cached.

Transmit a DDS.

Parameters
outThe output stream to which the DAS is to be sent.
ddsThe DDS to send back to a client.
evalA reference to the ConstraintEvaluator to use.
constrainedIf this argument is true, evaluate the current constraint expression and send the `constrained DDS' back to the client.
constrainedIf true, apply the constraint bound to this instance of ResponseBuilder
with_mime_headersIf true (default) send MIME headers.
Returns
void
See also
DDS

Definition at line 403 of file BESDapResponseBuilder.cc.

void BESDapResponseBuilder::send_ddx ( std::ostream &  out,
libdap::DDS &  dds,
libdap::ConstraintEvaluator &  eval,
bool  with_mime_headers = true 
)
virtual

Send the DDX response.

The DDX never contains data, instead it holds a reference to a Blob response which is used to get the data values. The DDS and DAS objects are built using code that already exists in the servers.

Note
This is the DAP3.x metadata response; it is supported by most DAP2 servers as well. The DAP4 DDX will contain types not present in DAP2 or 3.x
Parameters
ddsThe dataset's DDS with attributes in the variables.
evalA reference to the ConstraintEvaluator to use.
outDestination
with_mime_headersIf true, include the MIME headers in the response. Defaults to true.

Definition at line 652 of file BESDapResponseBuilder.cc.

virtual void BESDapResponseBuilder::set_btp_func_ce ( std::string  _ce)
inlinevirtual

Definition at line 79 of file BESDapResponseBuilder.h.

References d_btp_func_ce.

void BESDapResponseBuilder::set_ce ( std::string  _ce)
virtual

Set the constraint expression.

This will filter the CE text removing any 'WWW' escape characters except space. Spaces are left in the CE because the CE parser uses whitespace to delimit tokens while some datasets have identifiers that contain spaces. It's possible to use double quotes around identifiers too, but most client software doesn't know about that.

@brief Set the CE

Parameters
_ceThe constraint expression

Definition at line 138 of file BESDapResponseBuilder.cc.

void BESDapResponseBuilder::set_dataset_name ( const std::string  _dataset)
virtual

Set the dataset name, which is a string used to access the dataset on the machine running the server.

That is, this is typically a pathname to a data file, although it doesn't have to be. This is not echoed in error messages (because that would reveal server storage patterns that data providers might want to hide). All WWW-style escapes are replaced except for spaces.

Set the dataset pathname.

Parameters
dsThe pathname (or equivalent) to the dataset.

Definition at line 166 of file BESDapResponseBuilder.cc.

void BESDapResponseBuilder::set_timeout ( int  t = 0)

Set the server's timeout value.

A value of zero (the default) means no timeout.

See also
To establish a timeout, call establish_timeout(ostream &)
Parameters
tServer timeout in seconds. Default is zero (no timeout).

Definition at line 176 of file BESDapResponseBuilder.cc.

void BESDapResponseBuilder::split_ce ( libdap::ConstraintEvaluator &  eval,
const std::string &  expr = "" 
)
virtual

Split the CE so that the server functions that compute new values are separated into their own string and can be evaluated separately from the rest of the CE (which can contain simple and slicing projection as well as other types of function calls).

Definition at line 231 of file BESDapResponseBuilder.cc.

Friends And Related Function Documentation

friend class ResponseBuilderTest
friend

Definition at line 47 of file BESDapResponseBuilder.h.

Member Data Documentation

std::string BESDapResponseBuilder::d_btp_func_ce
protected

Constraint expression.

Definition at line 52 of file BESDapResponseBuilder.h.

Referenced by get_btp_func_ce(), and set_btp_func_ce().

std::string BESDapResponseBuilder::d_ce
protected

Name of the dataset/database.

Definition at line 51 of file BESDapResponseBuilder.h.

std::string BESDapResponseBuilder::d_dataset
protected

Definition at line 50 of file BESDapResponseBuilder.h.

std::string BESDapResponseBuilder::d_default_protocol
protected

Response timeout after N seconds.

Definition at line 54 of file BESDapResponseBuilder.h.

BESDapResponseCache* BESDapResponseBuilder::d_response_cache
protected

Version std::string for the library's default protocol version.

Definition at line 56 of file BESDapResponseBuilder.h.

int BESDapResponseBuilder::d_timeout
protected

The BTP functions, extracted from the CE.

Definition at line 53 of file BESDapResponseBuilder.h.


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