MADARA
3.1.8
|
Encapsulates a MADARA KaRL expression into an evaluatable tree. More...
#include <ExpressionTree.h>
Public Types | |
typedef ExpressionTreeConstIterator | const_iterator |
typedef ExpressionTreeIterator | iterator |
typedef madara::knowledge::KnowledgeRecord | value_type |
Public Member Functions | |
ExpressionTree (logger::Logger &logger=*logger::global_logger.get()) | |
Constructor. More... | |
ExpressionTree (logger::Logger &logger, ComponentNode *root, bool increase_count=false) | |
Constructor for copying a root node. More... | |
ExpressionTree (logger::Logger &logger, const ExpressionTree &tree) | |
Constructor for copying an expression tree. More... | |
~ExpressionTree (void) | |
Destructor. More... | |
void | accept (Visitor &visitor) const |
Accepts a visitor subclassed from the Visitor class. More... | |
iterator | begin (const std::string &traversal_order) |
Returns an iterator to the beginning of the expression tree. More... | |
const_iterator | begin (const std::string &traversal_order) const |
Returns a const iterator to the beginning of the expression tree. More... | |
iterator | end (const std::string &traversal_order) |
Returns an iterator to the end of the expression tree. More... | |
const_iterator | end (const std::string &traversal_order) const |
Returns a const iterator to the end of the expression tree. More... | |
madara::knowledge::KnowledgeRecord | evaluate (const madara::knowledge::KnowledgeUpdateSettings &settings=knowledge::KnowledgeUpdateSettings()) |
Evaluates the expression tree. More... | |
ComponentNode * | get_root (void) |
Returns the root node of the expression tree. More... | |
bool | is_null (void) const |
Checks if root pointer is null. More... | |
madara::knowledge::KnowledgeRecord | item (void) const |
Returns value of tree. More... | |
ExpressionTree | left (void) |
Returns the left expression of this tree. More... | |
void | operator= (const ExpressionTree &tree) |
Non-deep copies an expression tree into this instance. More... | |
madara::knowledge::KnowledgeRecord | prune (void) |
Prunes the expression tree of unnecessary nodes. More... | |
ExpressionTree | right (void) |
Returns the right expression of this tree. More... | |
Private Attributes | |
logger::Logger * | logger_ |
handle for logging information More... | |
madara::utility::Refcounter< ComponentNode > | root_ |
root of the expression tree More... | |
Encapsulates a MADARA KaRL expression into an evaluatable tree.
Definition at line 28 of file ExpressionTree.h.
Definition at line 35 of file ExpressionTree.h.
Definition at line 34 of file ExpressionTree.h.
Definition at line 33 of file ExpressionTree.h.
madara::expression::ExpressionTree::ExpressionTree | ( | logger::Logger & | logger = *logger::global_logger.get () | ) |
Constructor.
logger | logger for printing information |
Definition at line 153 of file ExpressionTree.cpp.
madara::expression::ExpressionTree::ExpressionTree | ( | logger::Logger & | logger, |
ComponentNode * | root, | ||
bool | increase_count = false |
||
) |
Constructor for copying a root node.
logger | logger for printing information |
root | root of the tree to copy |
increase_count | whether or not to increase the ref count |
Definition at line 161 of file ExpressionTree.cpp.
madara::expression::ExpressionTree::ExpressionTree | ( | logger::Logger & | logger, |
const ExpressionTree & | tree | ||
) |
Constructor for copying an expression tree.
logger | logger for printing information |
tree | expression tree to copy |
Definition at line 170 of file ExpressionTree.cpp.
madara::expression::ExpressionTree::~ExpressionTree | ( | void | ) |
Destructor.
Definition at line 194 of file ExpressionTree.cpp.
void madara::expression::ExpressionTree::accept | ( | Visitor & | visitor | ) | const |
Accepts a visitor subclassed from the Visitor class.
Accept a visitor to perform some action on the ExpressionTree.
visitor | visitor instance to use |
Definition at line 322 of file ExpressionTree.cpp.
madara::expression::ExpressionTree::iterator madara::expression::ExpressionTree::begin | ( | const std::string & | traversal_order | ) |
Returns an iterator to the beginning of the expression tree.
traversal_order | in-order, post-order, pre-order, level-order |
Definition at line 278 of file ExpressionTree.cpp.
madara::expression::ExpressionTreeConstIterator madara::expression::ExpressionTree::begin | ( | const std::string & | traversal_order | ) | const |
Returns a const iterator to the beginning of the expression tree.
traversal_order | in-order, post-order, pre-order, level-order |
Definition at line 300 of file ExpressionTree.cpp.
madara::expression::ExpressionTree::iterator madara::expression::ExpressionTree::end | ( | const std::string & | traversal_order | ) |
Returns an iterator to the end of the expression tree.
traversal_order | in-order, post-order, pre-order, level-order |
Definition at line 289 of file ExpressionTree.cpp.
madara::expression::ExpressionTreeConstIterator madara::expression::ExpressionTree::end | ( | const std::string & | traversal_order | ) | const |
Returns a const iterator to the end of the expression tree.
traversal_order | in-order, post-order, pre-order, level-order |
Definition at line 311 of file ExpressionTree.cpp.
madara::knowledge::KnowledgeRecord madara::expression::ExpressionTree::evaluate | ( | const madara::knowledge::KnowledgeUpdateSettings & | settings = knowledge::KnowledgeUpdateSettings () | ) |
Evaluates the expression tree.
Evaluates the node and its children.
settings | Settings for evaluating and setting knowledge |
This does not prune any of the expression tree, and is much faster than the prune function
Definition at line 234 of file ExpressionTree.cpp.
madara::expression::ComponentNode * madara::expression::ExpressionTree::get_root | ( | void | ) |
Returns the root node of the expression tree.
Definition at line 246 of file ExpressionTree.cpp.
bool madara::expression::ExpressionTree::is_null | ( | void | ) | const |
Checks if root pointer is null.
Definition at line 202 of file ExpressionTree.cpp.
madara::knowledge::KnowledgeRecord madara::expression::ExpressionTree::item | ( | void | ) | const |
Returns value of tree.
Definition at line 254 of file ExpressionTree.cpp.
madara::expression::ExpressionTree madara::expression::ExpressionTree::left | ( | void | ) |
Returns the left expression of this tree.
Definition at line 262 of file ExpressionTree.cpp.
void madara::expression::ExpressionTree::operator= | ( | const ExpressionTree & | tree | ) |
Non-deep copies an expression tree into this instance.
tree | tree to copy from |
Definition at line 180 of file ExpressionTree.cpp.
madara::knowledge::KnowledgeRecord madara::expression::ExpressionTree::prune | ( | void | ) |
Prunes the expression tree of unnecessary nodes.
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.
Definition at line 212 of file ExpressionTree.cpp.
madara::expression::ExpressionTree madara::expression::ExpressionTree::right | ( | void | ) |
Returns the right expression of this tree.
Definition at line 270 of file ExpressionTree.cpp.
|
private |
handle for logging information
Definition at line 157 of file ExpressionTree.h.
|
private |
root of the expression tree
Definition at line 160 of file ExpressionTree.h.