2 #ifndef _MADARA_NO_KARL_
34 if (nodes_.size() == 2)
36 bool base_can_change =
false, power_can_change =
false;
38 double base = nodes_[0]->prune(base_can_change).
to_double();
39 double power = nodes_[1]->prune(power_can_change).to_double();
41 if (!base_can_change &&
dynamic_cast<LeafNode*
>(nodes_[0]) == 0)
44 nodes_[0] =
new LeafNode(*(this->logger_), base);
47 if (!power_can_change &&
dynamic_cast<LeafNode*
>(nodes_[1]) == 0)
50 nodes_[1] =
new LeafNode(*(this->logger_), power);
55 can_change = can_change || base_can_change || power_can_change;
60 "madara::expression::SystemCallPow: "
62 "System call pow requires 2 arguments,"
63 "e.g., #pow (4,2), which would return 16.\n");
66 "madara::expression::SystemCallPow: "
67 "KARL COMPILE ERROR: "
68 "System call pow requires 2 arguments,"
69 "e.g., #pow (4,2), which would return 16.\n");
82 if (nodes_.size() == 2)
85 "madara::expression::SystemCallPow: "
86 "System call pow is returning the base taken to the power\n");
89 pow(nodes_[0]->evaluate(settings).to_double(),
90 nodes_[1]->evaluate(settings).to_double()));
95 "madara::expression::SystemCallPow: "
97 "System call pow requires 2 arguments,"
98 "e.g., #pow (4,2), which would return 16.\n");
101 "madara::expression::SystemCallPow: "
102 "KARL RUNTIME ERROR: "
103 "System call pow requires 2 arguments,"
104 "e.g., #pow (4,2), which would return 16.\n");
114 visitor.
visit(*
this);
#define madara_logger_ptr_log(loggering, level,...)
Fast version of the madara::logger::log method for Logger pointers.
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 item(void) const
Returns the value of the node.
virtual void accept(Visitor &visitor) const
Accepts a visitor subclassed from the Visitor class.
SystemCallPow(madara::knowledge::ThreadSafeContext &context, const ComponentNodes &nodes)
Constructor.
virtual madara::knowledge::KnowledgeRecord evaluate(const madara::knowledge::KnowledgeUpdateSettings &settings)
Evaluates the expression tree.
virtual madara::knowledge::KnowledgeRecord prune(bool &can_change)
Prunes the expression tree of unnecessary nodes.
virtual ~SystemCallPow(void)
Destructor.
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.
double to_double(void) const
converts the value to a float/double.
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