MADARA  3.2.3
madara::expression::VariableCompareNode Class Reference

Defines a terminal node of that references the current value stored in a variable. More...

#include <VariableCompareNode.h>

Inheritance diagram for madara::expression::VariableCompareNode:
madara::expression::ComponentNode

Public Types

enum  Comparators {
  LESS_THAN = 0, LESS_THAN_EQUAL = 1, EQUAL = 2, GREATER_THAN = 3,
  GREATER_THAN_EQUAL = 4
}
 

Public Member Functions

 VariableCompareNode (ComponentNode *lhs, madara::knowledge::KnowledgeRecord value, int type, ComponentNode *rhs, madara::knowledge::ThreadSafeContext &context)
 Ctor. More...
 
virtual ~VariableCompareNode (void)
 Dtor. More...
 
virtual void accept (Visitor &visitor) const
 Define the accept() operation used for the Visitor pattern. More...
 
virtual madara::knowledge::KnowledgeRecord evaluate (const madara::knowledge::KnowledgeUpdateSettings &settings)
 Evaluates the node and its children. More...
 
std::string expand_key (void) const
 Expands the key (if necessary). More...
 
virtual madara::knowledge::KnowledgeRecord item (void) const
 Return the item stored in the node. More...
 
const std::string & key (void) const
 Return the variable key. More...
 
virtual ComponentNodeleft (void) const
 Returns the left expression. More...
 
virtual madara::knowledge::KnowledgeRecord prune (bool &can_change)
 Prune the 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

CompositeArrayReferencearray_
 variable index holder More...
 
int compare_type_
 comparison function More...
 
madara::knowledge::ThreadSafeContextcontext_
 
ComponentNoderhs_
 holds a right hand side argument if it is not value_ More...
 
madara::knowledge::KnowledgeRecord value_
 amount to increment by. Note that this can also do decrement. More...
 
VariableNodevar_
 variable holder More...
 

Detailed Description

Defines a terminal node of that references the current value stored in a variable.

Definition at line 29 of file VariableCompareNode.h.

Member Enumeration Documentation

Enumerator
LESS_THAN 
LESS_THAN_EQUAL 
EQUAL 
GREATER_THAN 
GREATER_THAN_EQUAL 

Definition at line 38 of file VariableCompareNode.h.

Constructor & Destructor Documentation

madara::expression::VariableCompareNode::VariableCompareNode ( ComponentNode lhs,
madara::knowledge::KnowledgeRecord  value,
int  type,
ComponentNode rhs,
madara::knowledge::ThreadSafeContext context 
)

Ctor.

Definition at line 13 of file VariableCompareNode.cpp.

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

Dtor.

Definition at line 27 of file VariableCompareNode.cpp.

Member Function Documentation

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

Define the accept() operation used for the Visitor pattern.

Reimplemented from madara::expression::ComponentNode.

Definition at line 33 of file VariableCompareNode.cpp.

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

Evaluates the node and its children.

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

Implements madara::expression::ComponentNode.

Definition at line 102 of file VariableCompareNode.cpp.

std::string madara::expression::VariableCompareNode::expand_key ( void  ) const

Expands the key (if necessary).

This allow for keys to be defined with other variables inserted (e.g. var{.id} with .id = 2 expands to var2)

KnowledgeRecord madara::expression::VariableCompareNode::item ( void  ) const
virtual

Return the item stored in the node.

Reimplemented from madara::expression::ComponentNode.

Definition at line 39 of file VariableCompareNode.cpp.

const std::string& madara::expression::VariableCompareNode::key ( void  ) const

Return the variable key.

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.

KnowledgeRecord madara::expression::VariableCompareNode::prune ( bool &  can_change)
virtual

Prune the tree of unnecessary nodes.

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 55 of file VariableCompareNode.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

CompositeArrayReference* madara::expression::VariableCompareNode::array_
private

variable index holder

Definition at line 79 of file VariableCompareNode.h.

int madara::expression::VariableCompareNode::compare_type_
private

comparison function

Definition at line 90 of file VariableCompareNode.h.

madara::knowledge::ThreadSafeContext& madara::expression::VariableCompareNode::context_
private

Definition at line 87 of file VariableCompareNode.h.

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

handle the context

Definition at line 97 of file ComponentNode.h.

ComponentNode* madara::expression::VariableCompareNode::rhs_
private

holds a right hand side argument if it is not value_

Definition at line 85 of file VariableCompareNode.h.

madara::knowledge::KnowledgeRecord madara::expression::VariableCompareNode::value_
private

amount to increment by. Note that this can also do decrement.

Definition at line 82 of file VariableCompareNode.h.

VariableNode* madara::expression::VariableCompareNode::var_
private

variable holder

Definition at line 76 of file VariableCompareNode.h.


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