MADARA  3.2.3
madara::expression::CompositeForLoop Class Reference

A composite node that iterates until a condition is met. More...

#include <CompositeForLoop.h>

Inheritance diagram for madara::expression::CompositeForLoop:
madara::expression::ComponentNode

Public Member Functions

 CompositeForLoop (ComponentNode *precondition, ComponentNode *condition, ComponentNode *postcondition, ComponentNode *body, madara::knowledge::ThreadSafeContext &context)
 Constructor. More...
 
virtual ~CompositeForLoop (void)
 Destructor. More...
 
virtual void accept (Visitor &visitor) const
 Accepts a visitor subclassed from the Visitor class. More...
 
virtual madara::knowledge::KnowledgeRecord evaluate (const madara::knowledge::KnowledgeUpdateSettings &settings)
 Evaluates the expression tree. More...
 
virtual madara::knowledge::KnowledgeRecord item (void) const
 Returns the printable character of the node. More...
 
virtual ComponentNodeleft (void) const
 Returns the left expression. More...
 
virtual madara::knowledge::KnowledgeRecord prune (bool &can_change)
 Prunes the expression tree of unnecessary nodes. More...
 
virtual ComponentNoderight (void) const
 Returns the right expression. More...
 
void set_logger (logger::Logger &logger)
 Sets the logger for printing errors and debugging info. More...
 

Protected Attributes

logger::Loggerlogger_
 handle the context More...
 

Private Attributes

ComponentNodebody_
 
ComponentNodecondition_
 
ComponentNodepostcondition_
 
ComponentNodeprecondition_
 

Detailed Description

A composite node that iterates until a condition is met.

Definition at line 23 of file CompositeForLoop.h.

Constructor & Destructor Documentation

madara::expression::CompositeForLoop::CompositeForLoop ( ComponentNode precondition,
ComponentNode condition,
ComponentNode postcondition,
ComponentNode body,
madara::knowledge::ThreadSafeContext context 
)

Constructor.

Parameters
preconditionexecuted before loop
conditionwhat must be true for the loop to continue
postconditionexecuted after a successful loop body
bodyexecuted if loop condition is true
contextcontext for variable lookups

Definition at line 20 of file CompositeForLoop.cpp.

madara::expression::CompositeForLoop::~CompositeForLoop ( void  )
virtual

Destructor.

Definition at line 34 of file CompositeForLoop.cpp.

Member Function Documentation

void madara::expression::CompositeForLoop::accept ( Visitor visitor) const
virtual

Accepts a visitor subclassed from the Visitor class.

Parameters
visitorvisitor instance to use

Reimplemented from madara::expression::ComponentNode.

Definition at line 96 of file CompositeForLoop.cpp.

madara::knowledge::KnowledgeRecord madara::expression::CompositeForLoop::evaluate ( const madara::knowledge::KnowledgeUpdateSettings settings)
virtual

Evaluates the expression tree.

Evaluates the node and its children.

Parameters
settingssettings for evaluating the node
Returns
negation of the right expression

This does not prune any of the expression tree, and is much faster than the prune function

Implements madara::expression::ComponentNode.

Definition at line 64 of file CompositeForLoop.cpp.

madara::knowledge::KnowledgeRecord madara::expression::CompositeForLoop::item ( void  ) const
virtual

Returns the printable character of the node.

Returns
value of the node

Reimplemented from madara::expression::ComponentNode.

Definition at line 39 of file CompositeForLoop.cpp.

madara::expression::ComponentNode * madara::expression::ComponentNode::left ( void  ) const
virtualinherited

Returns the left expression.

Returns
a pointer to the left expression

Reimplemented in madara::expression::CompositeBinaryNode.

Definition at line 34 of file ComponentNode.cpp.

madara::knowledge::KnowledgeRecord madara::expression::CompositeForLoop::prune ( bool &  can_change)
virtual

Prunes the expression tree of unnecessary nodes.

Prune the tree of unnecessary nodes.

Parameters
can_changeset to true if variable nodes are contained
Returns
negation of the right expression

Returns evaluation of the node and sets can_change appropriately. if this node can be changed, that means it shouldn't be pruned.

Implements madara::expression::ComponentNode.

Definition at line 50 of file CompositeForLoop.cpp.

madara::expression::ComponentNode * madara::expression::ComponentNode::right ( void  ) const
virtualinherited

Returns the right expression.

Returns
a pointer to the right expression

Reimplemented in madara::expression::CompositeUnaryNode.

Definition at line 41 of file ComponentNode.cpp.

void madara::expression::ComponentNode::set_logger ( logger::Logger logger)
inherited

Sets the logger for printing errors and debugging info.

Parameters
loggerthe logger to use

Definition at line 53 of file ComponentNode.cpp.

Member Data Documentation

ComponentNode* madara::expression::CompositeForLoop::body_
private

Definition at line 88 of file CompositeForLoop.h.

ComponentNode* madara::expression::CompositeForLoop::condition_
private

Definition at line 82 of file CompositeForLoop.h.

logger::Logger* madara::expression::ComponentNode::logger_
protectedinherited

handle the context

Definition at line 97 of file ComponentNode.h.

ComponentNode* madara::expression::CompositeForLoop::postcondition_
private

Definition at line 85 of file CompositeForLoop.h.

ComponentNode* madara::expression::CompositeForLoop::precondition_
private

Definition at line 79 of file CompositeForLoop.h.


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