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

#include <D4FunctionEvaluator.h>

Public Member Functions

 D4FunctionEvaluator (DMR *dmr, ServerFunctionsList *sf_list)
 
DMRdmr () const
 
void error (const libdap::location &l, const std::string &m)
 
void eval (DMR *dmr)
 
unsigned long long get_arg_length_hint () const
 
template<typename t >
std::vector< t > * init_arg_list (t val)
 
template<typename T >
std::vector< T > * init_arg_list (T val)
 
bool parse (const std::string &expr)
 
D4RValueListresult () const
 
void set_arg_length_hint (unsigned long long alh)
 
void set_dmr (DMR *dmr)
 
void set_result (D4RValueList *rv_list)
 
void set_sf_list (ServerFunctionsList *sf_list)
 
void set_trace_parsing (bool tp)
 
void set_trace_scanning (bool ts)
 
ServerFunctionsListsf_list () const
 
bool trace_parsing () const
 
bool trace_scanning () const
 

Friends

class D4FunctionParser
 

Detailed Description

Driver for the DAP4 Functional expression parser.

Definition at line 48 of file D4FunctionEvaluator.h.

Member Function Documentation

◆ eval()

void libdap::D4FunctionEvaluator::eval ( DMR function_result)

Evaluate the recently parsed function expression and put the resulting rvalues (which return values packaged in libdap BaseType objects) into the top-level Group of the DMR passed as a param here.

Note
The DMR passed to this method can (and usually will) be different from the DMR passed to the D4FunctionEvaluator constructor. That DMR is the 'source dataset' for values of variables used by the functions. It is not generally where the results of evaluating the functions wind up. Usually, you'll want those results in their own DMR; the functions effectively make a new dataset. However, you can pass the source dataset DMR into this method and in that case the new variables will be appended to its root Group.
This code is really just a place to package results. The actual evaluation happens in the D4RValue object when values are accessed. The parse() method here builds the list of D4RValue objects and this code accesses the values which triggers the function evaluation. Thus, if you'd like to build a system that performs lazy evaluation, you can work with the result() method from this class instead of this one.
Calling this method will delete the D4RValueList object built by the parse() method.
Parameters
dmrStore the results here
Exceptions
ThrowsError if the evaluation fails.

Definition at line 109 of file D4FunctionEvaluator.cc.

◆ parse()

bool libdap::D4FunctionEvaluator::parse ( const std::string &  expr)

Parse the DAP4 function expression.

Calling this method with a DAP4 function expression builds a D4RvalueList that can then be evaluated. The list of rvalues can be accessed or evaluated (using the result() or eval() methods). Note that the result is a list of rvalues because the input can be zero or more function expressions.

Parameters
exprThe function expression.
Returns
True if the parse succeeded, false otherwise.

Definition at line 66 of file D4FunctionEvaluator.cc.

◆ result()

D4RValueList* libdap::D4FunctionEvaluator::result ( ) const
inline

Get the result of parsing the function(s)

Returns
The result(s) packages in a D4RValueList

Definition at line 127 of file D4FunctionEvaluator.h.


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