OpenDDS::DCPS::FilterEvaluator Class Reference

#include <FilterEvaluator.h>

Inheritance diagram for OpenDDS::DCPS::FilterEvaluator:
Inheritance graph
[legend]
Collaboration diagram for OpenDDS::DCPS::FilterEvaluator:
Collaboration graph
[legend]

List of all members.

Classes

struct  AstNodeWrapper
 keeps the details of yard out of the FilterEvaluator header file More...
struct  DataForEval
struct  DeserializedForEval
class  EvalNode
class  Operand
struct  SerializedForEval

Public Member Functions

 FilterEvaluator (const char *filter, bool allowOrderBy)
 FilterEvaluator (const AstNodeWrapper &yardNode)
 ~FilterEvaluator ()
 OPENDDS_VECTOR (OPENDDS_STRING) getOrderBys() const
bool hasFilter () const
bool usesExtendedGrammar () const
size_t number_parameters () const
template<typename T >
bool eval (const T &sample, const DDS::StringSeq &params) const
bool eval (ACE_Message_Block *serializedSample, bool swap_bytes, bool cdr_encap, const MetaStruct &meta, const DDS::StringSeq &params) const

Private Member Functions

 FilterEvaluator (const FilterEvaluator &)
FilterEvaluatoroperator= (const FilterEvaluator &)
EvalNodewalkAst (const AstNodeWrapper &node)
OperandwalkOperand (const AstNodeWrapper &node)
bool eval_i (DataForEval &data) const
 OPENDDS_VECTOR (OPENDDS_STRING) order_bys_

Private Attributes

bool extended_grammar_
EvalNodefilter_root_
size_t number_parameters_

Detailed Description

Definition at line 76 of file FilterEvaluator.h.


Constructor & Destructor Documentation

OpenDDS::DCPS::FilterEvaluator::FilterEvaluator ( const char *  filter,
bool  allowOrderBy 
)

Definition at line 43 of file FilterEvaluator.cpp.

References filter_root_, parser, OpenDDS::DCPS::reportErrors(), OpenDDS::DCPS::toString(), and walkAst().

00044   : extended_grammar_(false)
00045   , filter_root_(0)
00046   , number_parameters_(0)
00047 {
00048   const char* out = filter + std::strlen(filter);
00049   yard::SimpleTextParser parser(filter, out);
00050   if (!(allowOrderBy ? parser.Parse<QueryCompleteInput>()
00051       : parser.Parse<FilterCompleteInput>())) {
00052     reportErrors(parser, filter);
00053   }
00054 
00055   bool found_order_by = false;
00056   for (AstNode* iter = parser.GetAstRoot()->GetFirstChild(); iter;
00057       iter = iter->GetSibling()) {
00058     if (iter->TypeMatches<ORDERBY>()) {
00059       found_order_by = true;
00060     } else if (found_order_by && iter->TypeMatches<FieldName>()) {
00061       order_bys_.push_back(toString(iter));
00062     } else {
00063       filter_root_ = walkAst(iter);
00064     }
00065   }
00066 }

Here is the call graph for this function:

OpenDDS::DCPS::FilterEvaluator::FilterEvaluator ( const AstNodeWrapper yardNode  )  [explicit]

Definition at line 68 of file FilterEvaluator.cpp.

00069   : extended_grammar_(false)
00070   , filter_root_(walkAst(yardNode))
00071 {
00072 }

OpenDDS::DCPS::FilterEvaluator::~FilterEvaluator (  ) 

Definition at line 127 of file FilterEvaluator.cpp.

References filter_root_.

00128 {
00129   delete filter_root_;
00130 }

OpenDDS::DCPS::FilterEvaluator::FilterEvaluator ( const FilterEvaluator  )  [private]

Member Function Documentation

bool OpenDDS::DCPS::FilterEvaluator::eval ( ACE_Message_Block serializedSample,
bool  swap_bytes,
bool  cdr_encap,
const MetaStruct meta,
const DDS::StringSeq params 
) const [inline]

Definition at line 102 of file FilterEvaluator.h.

00105   {
00106     SerializedForEval data(serializedSample, meta, params,
00107                            swap_bytes, cdr_encap);
00108     return eval_i(data);
00109   }

template<typename T >
bool OpenDDS::DCPS::FilterEvaluator::eval ( const T &  sample,
const DDS::StringSeq params 
) const [inline]

Definition at line 96 of file FilterEvaluator.h.

Referenced by OpenDDS::DCPS::DataReaderImpl_T< MessageType >::contains_sample_filtered(), and OpenDDS::DCPS::DataWriterImpl::filter_out().

00097   {
00098     DeserializedForEval data(&sample, getMetaStruct<T>(), params);
00099     return eval_i(data);
00100   }

Here is the caller graph for this function:

bool OpenDDS::DCPS::FilterEvaluator::eval_i ( DataForEval data  )  const [private]

Definition at line 509 of file FilterEvaluator.cpp.

References OpenDDS::DCPS::Value::b_, OpenDDS::DCPS::FilterEvaluator::EvalNode::eval(), and filter_root_.

00510 {
00511   return filter_root_->eval(data).b_;
00512 }

Here is the call graph for this function:

bool OpenDDS::DCPS::FilterEvaluator::hasFilter (  )  const

Definition at line 521 of file FilterEvaluator.cpp.

References filter_root_.

Referenced by OpenDDS::DCPS::QueryConditionImpl::hasFilter().

00522 {
00523   return filter_root_ != 0;
00524 }

Here is the caller graph for this function:

size_t OpenDDS::DCPS::FilterEvaluator::number_parameters (  )  const [inline]
OpenDDS::DCPS::FilterEvaluator::OPENDDS_VECTOR ( OPENDDS_STRING   )  [private]
OpenDDS::DCPS::FilterEvaluator::OPENDDS_VECTOR ( OPENDDS_STRING   )  const
FilterEvaluator& OpenDDS::DCPS::FilterEvaluator::operator= ( const FilterEvaluator  )  [private]

Reimplemented from OpenDDS::DCPS::RcObject.

bool OpenDDS::DCPS::FilterEvaluator::usesExtendedGrammar (  )  const [inline]

Definition at line 91 of file FilterEvaluator.h.

00091 { return extended_grammar_; }

FilterEvaluator::EvalNode * OpenDDS::DCPS::FilterEvaluator::walkAst ( const AstNodeWrapper node  )  [private]

Definition at line 437 of file FilterEvaluator.cpp.

References OpenDDS::DCPS::arity(), OpenDDS::DCPS::child(), extended_grammar_, OpenDDS::DCPS::FilterEvaluator::Operand::isParameter(), and walkOperand().

Referenced by FilterEvaluator().

00438 {
00439   if (node->TypeMatches<CompPredDef>()) {
00440     Operand* left = walkOperand(child(node, 0));
00441     const FilterEvaluator::AstNodeWrapper& op = child(node, 1);
00442     Operand* right = walkOperand(child(node, 2));
00443     if (left->isParameter() && right->isParameter()) {
00444       extended_grammar_ = true;
00445     }
00446     return new Comparison(op, left, right);
00447   } else if (node->TypeMatches<BetweenPredDef>()) {
00448     Operand* field = walkOperand(child(node, 0));
00449     const FilterEvaluator::AstNodeWrapper& op = child(node, 1);
00450     Operand* low = walkOperand(child(node, 2));
00451     Operand* high = walkOperand(child(node, 3));
00452     return new Between(field, op, low, high);
00453   } else if (node->TypeMatches<CondDef>() || node->TypeMatches<Cond>()) {
00454     size_t a = arity(node);
00455     if (a == 1) {
00456       return walkAst(child(node, 0));
00457     } else if (a == 2) {
00458       assert(child(node, 0)->TypeMatches<NOT>());
00459       return new Logical(walkAst(child(node, 1)));
00460     } else if (a == 3) {
00461       EvalNode* left = walkAst(child(node, 0));
00462       const FilterEvaluator::AstNodeWrapper& op = child(node, 1);
00463       EvalNode* right = walkAst(child(node, 2));
00464       return new Logical(op, left, right);
00465     }
00466   }
00467 
00468   assert(0);
00469   return 0;
00470 }

Here is the call graph for this function:

Here is the caller graph for this function:

FilterEvaluator::Operand * OpenDDS::DCPS::FilterEvaluator::walkOperand ( const AstNodeWrapper node  )  [private]

Definition at line 473 of file FilterEvaluator.cpp.

References OpenDDS::DCPS::arity(), OpenDDS::DCPS::child(), extended_grammar_, number_parameters_, and OpenDDS::DCPS::toString().

Referenced by walkAst().

00474 {
00475   if (node->TypeMatches<FieldName>()) {
00476     return new FieldLookup(node);
00477   } else if (node->TypeMatches<IntVal>()) {
00478     return new LiteralInt(node);
00479   } else if (node->TypeMatches<CharVal>()) {
00480     return new LiteralChar(node);
00481   } else if (node->TypeMatches<FloatVal>()) {
00482     return new LiteralFloat(node);
00483   } else if (node->TypeMatches<StrVal>()) {
00484     return new LiteralString(node);
00485   } else if (node->TypeMatches<ParamVal>()) {
00486     Parameter* retval = new Parameter(node);
00487     // Keep track of the highest parameter number
00488     if (retval->param() + 1 > number_parameters_) {
00489       number_parameters_ = retval->param() + 1;
00490     }
00491     return retval;
00492   } else if (node->TypeMatches<CallDef>()) {
00493     if (arity(node) == 1) {
00494       return walkOperand(child(node, 0));
00495     } else {
00496       extended_grammar_ = true;
00497       Call* call = new Call(toString(child(node, 0)));
00498       for (AstNode* iter = child(node, 1); iter != 0; iter = iter->GetSibling()) {
00499         call->addChild(walkOperand(iter));
00500       }
00501       return call;
00502     }
00503   }
00504   assert(0);
00505   return 0;
00506 }

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 154 of file FilterEvaluator.h.

Referenced by walkAst(), and walkOperand().

Definition at line 155 of file FilterEvaluator.h.

Referenced by eval_i(), FilterEvaluator(), hasFilter(), and ~FilterEvaluator().

Number of parameter used in the filter, this should match the number of values passed when evaluating the filter

Definition at line 159 of file FilterEvaluator.h.

Referenced by walkOperand().


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 10 Aug 2018 for OpenDDS by  doxygen 1.6.1