30#include "ConstraintEvaluator.h"
32#include "ServerFunctionsList.h"
39struct yy_buffer_state;
44void ce_expr_switch_to_buffer(
void *new_buffer);
45void ce_expr_delete_buffer(
void *buffer);
46void *ce_expr_string(
const char *yy_str);
50ConstraintEvaluator::ConstraintEvaluator() {
58 d_functions_list = ServerFunctionsList::TheList();
61ConstraintEvaluator::~ConstraintEvaluator() {
63 for (Constants_iter j = constants.begin(); j != constants.end(); j++) {
69 for (Clause_iter k = expr.begin(); k != expr.end(); k++) {
87 throw InternalErr(__FILE__, __LINE__,
"There are no CE clauses for *this* DDS object.");
89 return (*iter)->value(dds);
107 expr.push_back(clause);
122 expr.push_back(clause);
137 expr.push_back(clause);
151 return d_functions_list->find_function(name, f);
156 return d_functions_list->find_function(name, f);
161 return d_functions_list->find_function(name, f);
185 if (expr.size() != 1)
186 throw InternalErr(__FILE__, __LINE__,
"The length of the list of CE clauses is not 1.");
190 if (cp->
value(dds, &result))
209 for (
unsigned int i = 0; i < expr.size(); ++i) {
235 throw InternalErr(__FILE__, __LINE__,
"The constraint expression is empty.");
238 for (
unsigned int i = 0; i < expr.size(); ++i) {
241 if (cp->
value(dds, &result)) {
247 throw Error(internal_error,
"A function was called but failed to return a value.");
261 throw InternalErr(__FILE__, __LINE__,
"The constraint expression is empty.");
266 for (
unsigned int i = 0; i < expr.size(); ++i) {
269 if (cp->
value(dds, &result)) {
273 throw Error(internal_error,
"A function was called but failed to return a value.");
286 for (Clause_iter i = expr.begin(); i != expr.end(); i++) {
287 boolean =
boolean && (*i)->boolean_clause();
302 DBG(cerr <<
"No selection recorded" << endl);
306 DBG(cerr <<
"Eval selection" << endl);
313 for (Clause_iter i = expr.begin(); i != expr.end() && result; i++) {
315 if (!((*i)->boolean_clause()))
316 throw InternalErr(__FILE__, __LINE__,
"A selection expression must contain only boolean clauses.");
317 result = result && (*i)->value(dds);
334 void *buffer = ce_expr_string(constraint.c_str());
336 ce_expr_switch_to_buffer(buffer);
343 ce_expr_delete_buffer(buffer);
346 ce_expr_delete_buffer(buffer);
The basic data type for the DODS DAP types.
bool boolean_expression()
Does the current constraint expression return a boolean value?
bool eval_selection(DDS &dds, const std::string &dataset)
Evaluate a boolean-valued constraint expression. This is main method for the evaluator and is called ...
bool find_function(const std::string &name, bool_func *f) const
Find a Boolean function with a given name in the function list.
bool clause_value(Clause_iter &i, DDS &dds)
void parse_constraint(const std::string &constraint, DDS &dds)
Parse the constraint expression given the current DDS.
void append_clause(int op, rvalue *arg1, rvalue_list *arg2)
Add a clause to a constraint expression.
Clause_iter clause_begin()
BaseType * eval_function(DDS &dds, const std::string &dataset)
Evaluate a function-valued constraint expression.
bool function_clauses()
Does the current constraint expression contain function clauses.
DDS * eval_function_clauses(DDS &dds)
Evaluate a function-valued constraint expression that contains several function calls.
void append_constant(BaseType *btp)
bool functional_expression()
Does the current constraint expression return a BaseType pointer? This method does not evaluate the c...
void add_var_nocopy(BaseType *bt)
Adds the variable to the DDS.
string get_dataset_name() const
BaseTypeFactory * get_factory() const
string get_version() const
Get the server version string, unparsed.
A class for error processing.
A class for software fault reporting.
top level DAP object to house generic methods
Holds a fragment of a constraint expression.
bool value_clause()
Return true if the clause returns a value in a BaseType pointer.
bool value(DDS &dds)
Evaluate a clause which returns a boolean value This method must only be evaluated for clauses with r...