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

#include <D4FunctionEvaluator.h>

Collaboration diagram for libdap::D4FunctionEvaluator:
Collaboration graph

Public Member Functions

 D4FunctionEvaluator ()=default
 
 D4FunctionEvaluator (DMR *dmr, ServerFunctionsList *sf_list)
 
DMRdmr () const
 
void eval (DMR *dmr)
 
unsigned long long get_arg_length_hint () const
 
template<typename T>
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
 
virtual ~D4FunctionEvaluator ()=default
 

Static Public Member Functions

static void error (const libdap::location &l, const std::string &m)
 

Friends

class D4FunctionParser
 

Detailed Description

Driver for the DAP4 Functional expression parser.

Definition at line 48 of file D4FunctionEvaluator.h.

Constructor & Destructor Documentation

◆ D4FunctionEvaluator() [1/2]

libdap::D4FunctionEvaluator::D4FunctionEvaluator ( )
default

◆ D4FunctionEvaluator() [2/2]

libdap::D4FunctionEvaluator::D4FunctionEvaluator ( DMR * dmr,
ServerFunctionsList * sf_list )
inline

Definition at line 76 of file D4FunctionEvaluator.h.

◆ ~D4FunctionEvaluator()

virtual libdap::D4FunctionEvaluator::~D4FunctionEvaluator ( )
virtualdefault

Member Function Documentation

◆ dmr()

DMR * libdap::D4FunctionEvaluator::dmr ( ) const
inline

Definition at line 100 of file D4FunctionEvaluator.h.

◆ error()

void libdap::D4FunctionEvaluator::error ( const libdap::location & l,
const std::string & m )
static

Definition at line 251 of file D4FunctionEvaluator.cc.

◆ 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 104 of file D4FunctionEvaluator.cc.

◆ get_arg_length_hint()

unsigned long long libdap::D4FunctionEvaluator::get_arg_length_hint ( ) const
inline

Definition at line 97 of file D4FunctionEvaluator.h.

◆ init_arg_list() [1/2]

template<typename T>
vector< T > * libdap::D4FunctionEvaluator::init_arg_list ( T val)

Definition at line 225 of file D4FunctionEvaluator.cc.

◆ init_arg_list() [2/2]

template<typename t>
std::vector< t > * libdap::D4FunctionEvaluator::init_arg_list ( t val)

◆ 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 62 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 92 of file D4FunctionEvaluator.h.

◆ set_arg_length_hint()

void libdap::D4FunctionEvaluator::set_arg_length_hint ( unsigned long long alh)
inline

Definition at line 98 of file D4FunctionEvaluator.h.

◆ set_dmr()

void libdap::D4FunctionEvaluator::set_dmr ( DMR * dmr)
inline

Definition at line 101 of file D4FunctionEvaluator.h.

◆ set_result()

void libdap::D4FunctionEvaluator::set_result ( D4RValueList * rv_list)
inline

Definition at line 93 of file D4FunctionEvaluator.h.

◆ set_sf_list()

void libdap::D4FunctionEvaluator::set_sf_list ( ServerFunctionsList * sf_list)
inline

Definition at line 104 of file D4FunctionEvaluator.h.

◆ set_trace_parsing()

void libdap::D4FunctionEvaluator::set_trace_parsing ( bool tp)
inline

Definition at line 86 of file D4FunctionEvaluator.h.

◆ set_trace_scanning()

void libdap::D4FunctionEvaluator::set_trace_scanning ( bool ts)
inline

Definition at line 83 of file D4FunctionEvaluator.h.

◆ sf_list()

ServerFunctionsList * libdap::D4FunctionEvaluator::sf_list ( ) const
inline

Definition at line 103 of file D4FunctionEvaluator.h.

◆ trace_parsing()

bool libdap::D4FunctionEvaluator::trace_parsing ( ) const
inline

Definition at line 85 of file D4FunctionEvaluator.h.

◆ trace_scanning()

bool libdap::D4FunctionEvaluator::trace_scanning ( ) const
inline

Definition at line 82 of file D4FunctionEvaluator.h.

Friends And Related Symbol Documentation

◆ D4FunctionParser

friend class D4FunctionParser
friend

Definition at line 72 of file D4FunctionEvaluator.h.


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