2 #ifndef _MADARA_NO_KARL_
38 for (ComponentNodes::iterator i = nodes_.begin(); i != nodes_.end(); ++i)
40 bool arg_can_change =
false;
41 result = (*i)->prune(arg_can_change);
43 if (!arg_can_change &&
dynamic_cast<LeafNode*
>(*i) == 0)
46 *i =
new LeafNode(*(this->logger_), result);
50 if (nodes_.size() > 2 || nodes_.size() == 0)
53 "madara::expression::SystemCallSetClock: "
54 "KARL COMPILE ERROR: System call set_clock requires 1-2 arguments, "
55 "e.g., set_clock (5) or set_clock (var, 5)\n");
69 if (nodes_.size() == 1)
72 "madara::expression::SystemCallSetClock: "
73 "System call set_clock is setting the system clock\n");
75 context_.set_clock(nodes_[0]->evaluate(settings).to_integer());
79 else if (nodes_.size() == 2)
82 "madara::expression::SystemCallSetClock: "
83 "System call set_clock is setting a variable clock\n");
89 (uint64_t)nodes_[1]->evaluate(settings).to_integer();
96 "madara::expression::SystemCallSetClock: "
98 "System call set_clock with 2 arguments "
99 "requires the first argument to be a variable\n");
102 "madara::expression::SystemCallSetClock: "
103 "KARL RUNTIME ERROR: "
104 "System call set_clock with 2 arguments "
105 "requires the first argument to be a variable\n");
111 "madara::expression::SystemCallSetClock: "
112 "KARL RUNTIME ERROR:"
113 "System call set_clock requires 1-2 arguments, "
114 "e.g., set_clock (5) or set_clock (var, 5)\n");
117 "madara::expression::SystemCallSetClock: "
118 "KARL RUNTIME ERROR: "
119 "System call set_clock requires 1-2 arguments, "
120 "e.g., set_clock (5) or set_clock (var, 5)\n");
130 visitor.
visit(*
this);
#define madara_logger_ptr_log(loggering, level,...)
Fast version of the madara::logger::log method for Logger pointers.
const ThreadSafeContext * context_
madara::knowledge::KnowledgeRecord KnowledgeRecord
An exception for unrecoverable KaRL compilation issues.
Defines a node that contains a madara::knowledge::KnowledgeRecord::Integer value.
Interface for a MADARA system call.
virtual madara::knowledge::KnowledgeRecord prune(bool &can_change)
Prunes the expression tree of unnecessary nodes.
virtual ~SystemCallSetClock(void)
Destructor.
SystemCallSetClock(madara::knowledge::ThreadSafeContext &context, const ComponentNodes &nodes)
Constructor.
virtual madara::knowledge::KnowledgeRecord item(void) const
Returns the value of the node.
virtual void accept(Visitor &visitor) const
Accepts a visitor subclassed from the Visitor class.
virtual madara::knowledge::KnowledgeRecord evaluate(const madara::knowledge::KnowledgeUpdateSettings &settings)
Evaluates the expression tree.
Defines a terminal node of that references the current value stored in a variable.
madara::knowledge::KnowledgeRecord * get_record(void)
Retrieves the underlying knowledge::KnowledgeRecord in the context (useful for system calls).
Abstract base class for all visitors to all classes that derive from ComponentNode.
virtual void visit(const LeafNode &node)=0
Visit a LeafNode.
This class encapsulates an entry in a KnowledgeBase.
uint64_t clock
last modification lamport clock time
Settings for applying knowledge updates.
This class stores variables and their values for use by any entity needing state information in a thr...
std::deque< ComponentNode * > ComponentNodes
a vector of Component Nodes