28 {
"$Id: ConstraintEvaluator.cc 24370 2011-03-28 16:21:32Z jimg $"
38 struct yy_buffer_state;
57 for (
Constants_iter j = constants.begin(); j != constants.end(); j++) {
62 for (
Clause_iter k = expr.begin(); k != expr.end(); k++) {
90 "There are no CE clauses for *this* DDS object.");
92 return (*iter)->value(dds);
112 expr.push_back(clause);
129 expr.push_back(clause);
146 expr.push_back(clause);
159 constants.push_back(btp);
168 func_name_is(
const string &name): d_name(name)
170 bool operator()(
const ConstraintEvaluator::function f)
172 return f.name == d_name;
200 function func(name, f);
201 functions.push_back(func);
209 function func(name, f);
210 functions.push_back(func);
218 function func(name, f);
219 functions.push_back(func);
226 if (functions.empty())
229 for (
Functions_citer i = functions.begin(); i != functions.end(); i++) {
230 if (name == (*i).name && (*f = (*i).b_func)) {
242 if (functions.empty())
245 for (
Functions_citer i = functions.begin(); i != functions.end(); i++) {
246 if (name == (*i).name && (*f = (*i).bt_func)) {
258 if (functions.empty())
262 if (name == (*i).name && (*f = (*i).p_func)) {
290 if (expr.size() != 1)
292 "The length of the list of CE clauses is not 1.");
296 if (cp->
value(dds, &result))
316 for (
unsigned int i = 0; i < expr.size(); ++i) {
344 throw InternalErr(__FILE__, __LINE__,
"The constraint expression is empty.");
347 for (
unsigned int i = 0; i < expr.size(); ++i) {
350 if (cp->
value(dds, &result)) {
356 throw Error(
"A function was called but failed to return a value.");
372 throw InternalErr(__FILE__, __LINE__,
"The constraint expression is empty.");
378 for (
unsigned int i = 0; i < expr.size(); ++i) {
381 if (cp->
value(dds, &result)) {
387 throw Error(
"A function was called but failed to return a value.");
402 for (
Clause_iter i = expr.begin(); i != expr.end(); i++) {
403 boolean =
boolean && (*i)->boolean_clause();
421 DBG(cerr <<
"No selection recorded" << endl);
425 DBG(cerr <<
"Eval selection" << endl);
432 for (
Clause_iter i = expr.begin(); i != expr.end() && result; i++) {
434 if (!((*i)->boolean_clause()))
436 "A selection expression must contain only boolean clauses.");
437 result = result && (*i)->value(dds);
virtual ~ConstraintEvaluator()
void ce_expr_delete_buffer(void *buffer)
yy_buffer_state * ce_expr_scan_string(const char *str)
std::vector< rvalue * > rvalue_list
bool boolean_expression()
Does the current constraint expression return a boolean value?
std::list< function >::const_iterator Functions_citer
BaseType * eval_function(DDS &dds, const string &dataset)
Evaluate a function-valued constraint expression.
void parse_constraint(const string &constraint, DDS &dds)
Parse the constraint expression given the current DDS.
void register_functions(ConstraintEvaluator &ce)
void * ce_expr_string(const char *yy_str)
A class for software fault reporting.
bool eval_selection(DDS &dds, const string &dataset)
Evaluate a boolean-valued constraint expression. This is main method for the evaluator ans is called ...
bool value(DDS &dds)
Evaluate a clause which returns a boolean value This method must only be evaluated for clauses with r...
virtual void set_send_p(bool state)
DDS * eval_function_clauses(DDS &dds)
Evaluate a function-valued constraint expression that contains several function calls.
void ce_expr_switch_to_buffer(void *new_buffer)
string get_version() const
Get the server version string, unparsed.
std::vector< BaseType * >::iterator Constants_iter
BaseTypeFactory * get_factory() const
friend class func_name_is
bool functional_expression()
Does the current constraint expression return a BaseType pointer? This method does not evaluate the c...
Clause_iter clause_begin()
void add_function(const string &name, bool_func f)
Add a boolean function to the list.
int ce_exprparse(void *arg)
The basic data type for the DODS DAP types.
void append_constant(BaseType *btp)
bool clause_value(Clause_iter &i, DDS &dds)
string get_protocol() const
Holds a fragment of a constraint expression.
bool function_clauses()
Does the current constraint expression return a DDS pointer?
A class for error processing.
string get_dataset_name() const
bool value_clause()
Return true if the clause returns a value in a BaseType pointer.
std::vector< Clause * >::iterator Clause_iter
void append_clause(int op, rvalue *arg1, rvalue_list *arg2)
Add a clause to a constraint expression.
void add_var(BaseType *bt)
Adds a copy of the variable to the DDS. Using the ptr_duplicate() method, perform a deep copy on the ...
bool find_function(const string &name, bool_func *f) const
Find a Boolean function with a given name in the function list.