libdap++  Updated for version 3.8.2
libdap::ConstraintEvaluator Class Reference

Evaluate a constraint expression.

#include <ConstraintEvaluator.h>

Collaboration diagram for libdap::ConstraintEvaluator:
Collaboration graph

Classes

struct  function

Public Types

typedef std::vector< Clause * >
::const_iterator 
Clause_citer
typedef std::vector< Clause * >
::iterator 
Clause_iter
typedef std::vector< BaseType * >
::const_iterator 
Constants_citer
typedef std::vector< BaseType * >
::iterator 
Constants_iter
typedef std::list< function >
::const_iterator 
Functions_citer
typedef std::list< function >
::iterator 
Functions_iter

Public Member Functions

void append_clause (int op, rvalue *arg1, rvalue_list *arg2)
 Add a clause to a constraint expression.
void append_clause (bool_func func, rvalue_list *args)
 Add a clause to a constraint expression.
void append_clause (btp_func func, rvalue_list *args)
 Add a clause to a constraint expression.
void append_constant (BaseType *btp)
bool boolean_expression ()
 Does the current constraint expression return a boolean value?
Clause_iter clause_begin ()
Clause_iter clause_end ()
bool clause_value (Clause_iter &i, DDS &dds)
 ConstraintEvaluator ()
BaseTypeeval_function (DDS &dds, const string &dataset)
 Evaluate a function-valued constraint expression.
DDSeval_function_clauses (DDS &dds)
 Evaluate a function-valued constraint expression that contains several function calls.
DataDDSeval_function_clauses (DataDDS &dds)
 Evaluate a function-valued constraint expression that contains several function calls. Takes and returns a DataDDS.
bool eval_selection (DDS &dds, const string &dataset)
 Evaluate a boolean-valued constraint expression. This is main method for the evaluator ans is called by the BaseType::serialize() methods.
bool function_clauses ()
 Does the current constraint expression return a DDS pointer?
bool functional_expression ()
 Does the current constraint expression return a BaseType pointer? This method does not evaluate the clause, it provides information to the evaluator regarding how to evaluate the clause.
void parse_constraint (const string &constraint, DDS &dds)
 Parse the constraint expression given the current DDS.
virtual ~ConstraintEvaluator ()
External Function Accessors

The Constraint Evaluator carries with it a list of external functions it can use while evaluate a constraint expression. If a constraint contains any of these functions, the entries in the list allow the parser to evaluate it. The functions are of three types: those that return boolean values, those that return real (also called BaseType) values, and those that are applied during evaluation of the projection for side effect

Note
The add_function() methods will replace a function of the same name, so it is possible to overwrite functions in specific handlers if the handler need special behavior to implement one of the standard functions.
See Also
ce_functions for the standard functions

These methods are used to manipulate this list of known external functions.

void add_function (const string &name, bool_func f)
 Add a boolean function to the list.
void add_function (const string &name, btp_func f)
 Add a BaseType function to the list.
void add_function (const string &name, proj_func f)
 Add a projection function to the list.
bool find_function (const string &name, bool_func *f) const
 Find a Boolean function with a given name in the function list.
bool find_function (const string &name, btp_func *f) const
 Find a BaseType function with a given name in the function list.
bool find_function (const string &name, proj_func *f) const
 Find a projection function with a given name in the function list.

Friends

class func_name_is

Detailed Description

Definition at line 46 of file ConstraintEvaluator.h.

Member Typedef Documentation

typedef std::vector<Clause *>::const_iterator libdap::ConstraintEvaluator::Clause_citer

Definition at line 90 of file ConstraintEvaluator.h.

typedef std::vector<Clause *>::iterator libdap::ConstraintEvaluator::Clause_iter

Definition at line 91 of file ConstraintEvaluator.h.

typedef std::vector<BaseType *>::const_iterator libdap::ConstraintEvaluator::Constants_citer

Definition at line 93 of file ConstraintEvaluator.h.

typedef std::vector<BaseType *>::iterator libdap::ConstraintEvaluator::Constants_iter

Definition at line 94 of file ConstraintEvaluator.h.

typedef std::list<function>::const_iterator libdap::ConstraintEvaluator::Functions_citer

Definition at line 96 of file ConstraintEvaluator.h.

typedef std::list<function>::iterator libdap::ConstraintEvaluator::Functions_iter

Definition at line 97 of file ConstraintEvaluator.h.

Constructor & Destructor Documentation

libdap::ConstraintEvaluator::ConstraintEvaluator ( )

Definition at line 49 of file ConstraintEvaluator.cc.

References libdap::register_functions().

Here is the call graph for this function:

libdap::ConstraintEvaluator::~ConstraintEvaluator ( )
virtual

Definition at line 54 of file ConstraintEvaluator.cc.

Member Function Documentation

void libdap::ConstraintEvaluator::add_function ( const string &  name,
bool_func  f 
)

Definition at line 197 of file ConstraintEvaluator.cc.

References func_name_is.

Referenced by libdap::register_functions().

void libdap::ConstraintEvaluator::add_function ( const string &  name,
btp_func  f 
)

Definition at line 206 of file ConstraintEvaluator.cc.

References func_name_is.

void libdap::ConstraintEvaluator::add_function ( const string &  name,
proj_func  f 
)

Definition at line 215 of file ConstraintEvaluator.cc.

References func_name_is.

void libdap::ConstraintEvaluator::append_clause ( int  op,
rvalue arg1,
rvalue_list arg2 
)

This function adds an operator clause to the constraint expression.

Parameters
opAn integer indicating the operator in use. These values are generated by bison.
arg1A pointer to the argument on the left side of the operator.
arg2A pointer to a list of the arguments on the right side of the operator.

Definition at line 108 of file ConstraintEvaluator.cc.

void libdap::ConstraintEvaluator::append_clause ( bool_func  func,
rvalue_list args 
)

This function adds a boolean function clause to the constraint expression.

Parameters
funcA pointer to a boolean function from the list of supported functions.
argsA list of arguments to that function.

Definition at line 125 of file ConstraintEvaluator.cc.

void libdap::ConstraintEvaluator::append_clause ( btp_func  func,
rvalue_list args 
)

This function adds a real-valued (BaseType) function clause to the constraint expression.

Parameters
funcA pointer to a BaseType function from the list of supported functions.
argsA list of arguments to that function.

Definition at line 142 of file ConstraintEvaluator.cc.

void libdap::ConstraintEvaluator::append_constant ( BaseType btp)

The Constraint Evaluator maintains a list of BaseType pointers for all the constants that the constraint expression parser generates. These objects are deleted by the Constraint Evaluator destructor. Note that there are no list accessors; these constants are never accessed from the list. The list is simply a convenient way to make sure the constants are disposed of properly.

Definition at line 157 of file ConstraintEvaluator.cc.

bool libdap::ConstraintEvaluator::boolean_expression ( )

Definition at line 396 of file ConstraintEvaluator.cc.

ConstraintEvaluator::Clause_iter libdap::ConstraintEvaluator::clause_begin ( )

Returns the first clause in a parsed constraint expression.

Definition at line 70 of file ConstraintEvaluator.cc.

ConstraintEvaluator::Clause_iter libdap::ConstraintEvaluator::clause_end ( )

Returns a reference to the end of the list of clauses in a parsed constraint expression. It does not reference the last clause

Definition at line 78 of file ConstraintEvaluator.cc.

bool libdap::ConstraintEvaluator::clause_value ( Clause_iter iter,
DDS dds 
)

Returns the value of the indicated clause of a constraint expression.

Definition at line 86 of file ConstraintEvaluator.cc.

BaseType * libdap::ConstraintEvaluator::eval_function ( DDS dds,
const string &  dataset 
)

Definition at line 288 of file ConstraintEvaluator.cc.

References libdap::Clause::value().

Referenced by libdap::DODSFilter::send_data(), and libdap::DODSFilter::send_data_ddx().

Here is the call graph for this function:

DDS * libdap::ConstraintEvaluator::eval_function_clauses ( DDS dds)

This method can be called for any function-valued constraint expression. Unlike eval_function(), it will package the return value in a new DDS object. The server should free this object once it has been serialized and sent.

Note
While there is another type of function that can appear in a CE (a 'projection function') those are evaluated by the ce parser - they are used to insert new variables into the DDS as a side effect of CE evaluation. That kind of function can never appear here; these are all functions that return BaseType pointers.
Added for libdap 3.11

Definition at line 341 of file ConstraintEvaluator.cc.

References libdap::DDS::add_var(), libdap::DDS::get_dataset_name(), libdap::DDS::get_factory(), libdap::BaseType::set_send_p(), and libdap::Clause::value().

Referenced by libdap::ResponseBuilder::send_data(), libdap::DODSFilter::send_data(), libdap::ResponseBuilder::send_data_ddx(), and libdap::DODSFilter::send_data_ddx().

Here is the call graph for this function:

DataDDS * libdap::ConstraintEvaluator::eval_function_clauses ( DataDDS dds)
bool libdap::ConstraintEvaluator::eval_selection ( DDS dds,
const string &  dataset 
)
Parameters
ddsUse these variables when evaluating the expressions.
datasetThis string is passed to the read() methods.
Returns
True if the expression is true, false otherwise.

Definition at line 418 of file ConstraintEvaluator.cc.

References DBG.

Referenced by libdap::Sequence::read_row(), libdap::Str::serialize(), libdap::UInt16::serialize(), libdap::Int16::serialize(), libdap::Float32::serialize(), libdap::UInt32::serialize(), libdap::Float64::serialize(), libdap::Int32::serialize(), libdap::Byte::serialize(), libdap::Vector::serialize(), libdap::Structure::serialize(), and libdap::Grid::serialize().

bool libdap::ConstraintEvaluator::find_function ( const string &  name,
bool_func *  f 
) const

Definition at line 224 of file ConstraintEvaluator.cc.

bool libdap::ConstraintEvaluator::find_function ( const string &  name,
btp_func *  f 
) const

Definition at line 240 of file ConstraintEvaluator.cc.

bool libdap::ConstraintEvaluator::find_function ( const string &  name,
proj_func *  f 
) const

Definition at line 256 of file ConstraintEvaluator.cc.

bool libdap::ConstraintEvaluator::function_clauses ( )

This method does not evaluate the clauses, it provides information to the evaluator regarding how to evaluate the clause.

Note
Added for libdap 3.11
Returns
True if the clause is a function that returns a DDS* and false otherwise

Definition at line 311 of file ConstraintEvaluator.cc.

References libdap::Clause::value_clause().

Referenced by libdap::ResponseBuilder::send_data(), libdap::DODSFilter::send_data(), libdap::ResponseBuilder::send_data_ddx(), and libdap::DODSFilter::send_data_ddx().

Here is the call graph for this function:

bool libdap::ConstraintEvaluator::functional_expression ( )
Returns
True if the clause is a function that returns a BaseType* and false otherwise

Definition at line 277 of file ConstraintEvaluator.cc.

References libdap::Clause::value_clause().

Referenced by libdap::DODSFilter::send_data(), libdap::DODSFilter::send_data_ddx(), libdap::ResponseBuilder::send_dds(), libdap::DODSFilter::send_dds(), libdap::ResponseBuilder::send_ddx(), and libdap::DODSFilter::send_ddx().

Here is the call graph for this function:

void libdap::ConstraintEvaluator::parse_constraint ( const string &  constraint,
DDS dds 
)

Evaluate the constraint expression; return the value of the expression. As a side effect, mark the DDS so that BaseType's mfuncs can be used to correctly read the variable's value and send it to the client.

Parameters
constraintA string containing the constraint expression.
ddsThe DDS that provides the environment within which the constraint is evaluated.
Exceptions
ThrowsError if the constraint does not parse.

Definition at line 454 of file ConstraintEvaluator.cc.

References ce_expr_delete_buffer(), ce_expr_string(), ce_expr_switch_to_buffer(), and ce_exprparse().

Referenced by libdap::ResponseBuilder::send_data(), libdap::DODSFilter::send_data(), libdap::ResponseBuilder::send_data_ddx(), libdap::DODSFilter::send_data_ddx(), libdap::ResponseBuilder::send_dds(), libdap::DODSFilter::send_dds(), libdap::ResponseBuilder::send_ddx(), and libdap::DODSFilter::send_ddx().

Here is the call graph for this function:

Friends And Related Function Documentation

friend class func_name_is
friend

Definition at line 87 of file ConstraintEvaluator.h.

Referenced by add_function().


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