2 #ifndef _MADARA_NO_KARL_
35 for (ComponentNodes::iterator i = nodes_.begin(); i != nodes_.end(); ++i)
37 bool arg_can_change =
false;
38 result = (*i)->prune(arg_can_change);
40 if (!arg_can_change &&
dynamic_cast<LeafNode*
>(*i) == 0)
43 *i =
new LeafNode(*(this->logger_), result);
47 if (nodes_.size() > 3)
50 "madara::expression::SystemCallRandDouble: "
52 "System call rand_double"
53 " can have up to three arguments, 1) floor, "
54 "2) ceiling and 3) whether to set the random seed\n");
57 "madara::expression::SystemCallRandDouble: "
58 "KARL COMPILE ERROR: "
59 "System call rand_double"
60 " can have up to three arguments, 1) floor, "
61 "2) ceiling and 3) whether to set the random seeds\n");
73 double floor(0.0), ceiling(1.0);
74 bool update_srand =
true;
76 if (nodes_.size() > 0)
78 floor = nodes_[0]->evaluate(settings).to_double();
80 if (nodes_.size() > 1)
82 ceiling = nodes_[1]->evaluate(settings).to_double();
84 if (nodes_.size() > 2)
86 update_srand = nodes_[2]->evaluate(settings).to_integer() != 0;
92 "madara::expression::SystemCallRandDouble: "
93 "System call rand_double called with %f, %f, %d\n",
94 floor, ceiling, update_srand);
104 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 ~SystemCallRandDouble(void)
Destructor.
virtual madara::knowledge::KnowledgeRecord item(void) const
Returns the value of the node.
SystemCallRandDouble(madara::knowledge::ThreadSafeContext &context, const ComponentNodes &nodes)
Constructor.
virtual madara::knowledge::KnowledgeRecord evaluate(const madara::knowledge::KnowledgeUpdateSettings &settings)
Evaluates the expression tree.
virtual void accept(Visitor &visitor) const
Accepts a visitor subclassed from the Visitor class.
virtual madara::knowledge::KnowledgeRecord prune(bool &can_change)
Prunes the expression tree of unnecessary nodes.
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.
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
double rand_double(double floor, double ceiling, bool set_seed_to_time)
Returns a random double between floor and ceiling.