27 static char rcsid[]
not_used = {
"$Id: ConstraintEvaluator.cc 25915 2012-10-24 00:14:58Z jimg $" };
44 struct yy_buffer_state;
63 for (
Constants_iter j = constants.begin(); j != constants.end(); j++) {
69 for (
Clause_iter k = expr.begin(); k != expr.end(); k++) {
94 throw InternalErr(__FILE__, __LINE__,
"There are no CE clauses for *this* DDS object.");
96 return (*iter)->value(dds);
115 expr.push_back(clause);
131 expr.push_back(clause);
147 expr.push_back(clause);
159 constants.push_back(btp);
167 func_name_is(
const string &name) :
171 bool operator()(
const ConstraintEvaluator::function f)
173 return f.name == d_name;
200 function func(name, f);
201 functions.push_back(func);
208 function func(name, f);
209 functions.push_back(func);
216 function func(name, f);
217 functions.push_back(func);
223 if (functions.empty())
226 for (
Functions_citer i = functions.begin(); i != functions.end(); i++) {
227 if (name == (*i).name && (*f = (*i).b_func)) {
238 if (functions.empty())
241 for (
Functions_citer i = functions.begin(); i != functions.end(); i++) {
242 if (name == (*i).name && (*f = (*i).bt_func)) {
253 if (functions.empty())
257 if (name == (*i).name && (*f = (*i).p_func)) {
288 if (expr.size() != 1)
289 throw InternalErr(__FILE__, __LINE__,
"The length of the list of CE clauses is not 1.");
293 if (cp->
value(dds, &result))
313 for (
unsigned int i = 0; i < expr.size(); ++i) {
341 throw InternalErr(__FILE__, __LINE__,
"The constraint expression is empty.");
344 for (
unsigned int i = 0; i < expr.size(); ++i) {
347 if (cp->
value(dds, &result)) {
350 DBG(cerr <<
"In CE 1 Grid send_p: " << result->
send_p() << endl);
351 DBG(cerr <<
"In CE 1 Grid Array send_p: " << static_cast<Grid*>(result)->get_array()->send_p() << endl);
356 throw Error(
"A function was called but failed to return a value.");
381 throw InternalErr(__FILE__, __LINE__,
"The constraint expression is empty.");
386 for (
unsigned int i = 0; i < expr.size(); ++i) {
389 if (cp->
value(dds, &result)) {
391 DBG(cerr <<
"In CE 2 Grid send_p: " << result->
send_p() << endl);
392 DBG(cerr <<
"In CE 2 Grid Array send_p: " << static_cast<Grid*>(result)->get_array()->send_p() << endl);
398 throw Error(
"A function was called but failed to return a value.");
412 for (
Clause_iter i = expr.begin(); i != expr.end(); i++) {
413 boolean =
boolean && (*i)->boolean_clause();
429 DBG(cerr <<
"No selection recorded" << endl);
433 DBG(cerr <<
"Eval selection" << endl);
440 for (
Clause_iter i = expr.begin(); i != expr.end() && result; i++) {
442 if (!((*i)->boolean_clause()))
443 throw InternalErr(__FILE__, __LINE__,
"A selection expression must contain only boolean clauses.");
444 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 add_var_nocopy(BaseType *bt)
Adds the variable to the DDS.
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...
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 contain function clauses.
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.
virtual bool send_p()
Should this variable be sent?
bool find_function(const string &name, bool_func *f) const
Find a Boolean function with a given name in the function list.