MADARA  3.2.3
madara::expression::VariableNode Class Reference

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

#include <VariableNode.h>

Inheritance diagram for madara::expression::VariableNode:
madara::expression::ComponentNode

Public Member Functions

 VariableNode (const std::string &key, madara::knowledge::ThreadSafeContext &context)
 Ctor. More...
 
virtual void accept (Visitor &visitor) const
 Define the accept() operation used for the Visitor pattern. More...
 
madara::knowledge::KnowledgeRecord dec (const madara::knowledge::KnowledgeUpdateSettings &settings=knowledge::KnowledgeUpdateSettings())
 Atomically decrement the variable. 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...
 
madara::knowledge::KnowledgeRecordget_record (void)
 Retrieves the underlying knowledge::KnowledgeRecord in the context (useful for system calls). More...
 
madara::knowledge::KnowledgeRecord inc (const madara::knowledge::KnowledgeUpdateSettings &settings=knowledge::KnowledgeUpdateSettings())
 Atomically increment the variable. 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...
 
int set (const madara::knowledge::KnowledgeRecord::Integer &value, const madara::knowledge::KnowledgeUpdateSettings &settings=knowledge::KnowledgeUpdateSettings())
 Sets the value stored in the node. More...
 
int set (double value, const madara::knowledge::KnowledgeUpdateSettings &settings=knowledge::KnowledgeUpdateSettings())
 Sets the value stored in the node. More...
 
int set (const std::string &value, const madara::knowledge::KnowledgeUpdateSettings &settings=knowledge::KnowledgeUpdateSettings())
 Sets the value stored in the node. More...
 
int set (const madara::knowledge::KnowledgeRecord &value, const madara::knowledge::KnowledgeUpdateSettings &settings=knowledge::KnowledgeUpdateSettings())
 Sets the value stored in the node. 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 Member Functions

std::string expand_opener (size_t opener, size_t &closer) const
 

Private Attributes

madara::knowledge::ThreadSafeContextcontext_
 
const std::string key_
 Key for retrieving value of this variable. More...
 
bool key_expansion_necessary_
 Expansion necessary. More...
 
std::vector< size_t > markers_
 
madara::knowledge::VariableReference ref_
 

Detailed Description

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

Definition at line 28 of file VariableNode.h.

Constructor & Destructor Documentation

madara::expression::VariableNode::VariableNode ( const std::string &  key,
madara::knowledge::ThreadSafeContext context 
)

Ctor.

Definition at line 12 of file VariableNode.cpp.

Member Function Documentation

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

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

Reimplemented from madara::expression::ComponentNode.

Definition at line 224 of file VariableNode.cpp.

Atomically decrement the variable.

Definition at line 360 of file VariableNode.cpp.

madara::knowledge::KnowledgeRecord madara::expression::VariableNode::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 258 of file VariableNode.cpp.

std::string madara::expression::VariableNode::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)

Definition at line 156 of file VariableNode.cpp.

std::string madara::expression::VariableNode::expand_opener ( size_t  opener,
size_t &  closer 
) const
private

Definition at line 91 of file VariableNode.cpp.

madara::knowledge::KnowledgeRecord* madara::expression::VariableNode::get_record ( void  )
inline

Retrieves the underlying knowledge::KnowledgeRecord in the context (useful for system calls).

Returns
the knowledge::KnowledgeRecord inside of the context

Definition at line 95 of file VariableNode.h.

Atomically increment the variable.

Definition at line 389 of file VariableNode.cpp.

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

Return the item stored in the node.

Reimplemented from madara::expression::ComponentNode.

Definition at line 230 of file VariableNode.cpp.

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

Return the variable key.

Definition at line 268 of file VariableNode.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::VariableNode::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 242 of file VariableNode.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.

int madara::expression::VariableNode::set ( const madara::knowledge::KnowledgeRecord::Integer value,
const madara::knowledge::KnowledgeUpdateSettings settings = knowledge::KnowledgeUpdateSettings () 
)

Sets the value stored in the node.

Definition at line 324 of file VariableNode.cpp.

int madara::expression::VariableNode::set ( double  value,
const madara::knowledge::KnowledgeUpdateSettings settings = knowledge::KnowledgeUpdateSettings () 
)

Sets the value stored in the node.

Definition at line 336 of file VariableNode.cpp.

int madara::expression::VariableNode::set ( const std::string &  value,
const madara::knowledge::KnowledgeUpdateSettings settings = knowledge::KnowledgeUpdateSettings () 
)

Sets the value stored in the node.

Definition at line 348 of file VariableNode.cpp.

int madara::expression::VariableNode::set ( const madara::knowledge::KnowledgeRecord value,
const madara::knowledge::KnowledgeUpdateSettings settings = knowledge::KnowledgeUpdateSettings () 
)

Sets the value stored in the node.

Definition at line 274 of file VariableNode.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

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

Definition at line 111 of file VariableNode.h.

const std::string madara::expression::VariableNode::key_
private

Key for retrieving value of this variable.

Definition at line 108 of file VariableNode.h.

bool madara::expression::VariableNode::key_expansion_necessary_
private

Expansion necessary.

Definition at line 114 of file VariableNode.h.

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

handle the context

Definition at line 97 of file ComponentNode.h.

std::vector<size_t> madara::expression::VariableNode::markers_
private

Definition at line 116 of file VariableNode.h.

madara::knowledge::VariableReference madara::expression::VariableNode::ref_
private

Definition at line 109 of file VariableNode.h.


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