2 #ifndef _MADARA_NO_KARL_ 41 for (ComponentNodes::iterator i =
nodes_.begin (); i !=
nodes_.end ();
44 bool arg_can_change =
false;
45 result = (*i)->prune (arg_can_change);
47 if (!arg_can_change && dynamic_cast <LeafNode *> (*i) == 0)
57 "KARL COMPILE ERROR: System call rand_int" 58 " can have up to three arguments, 1) floor, " 59 "2) ceiling and 3) whether to set the random seed");
71 int64_t floor (0), ceiling (1);
72 bool update_srand =
true;
76 floor =
nodes_[0]->evaluate (settings).to_integer ();
80 ceiling =
nodes_[1]->evaluate (settings).to_integer ();
84 update_srand = bool (
nodes_[2]->
evaluate (settings).to_integer ());
90 "System call rand_int called with %" PRId64
", %" PRId64
", %d.\n",
91 floor, ceiling, update_srand);
102 visitor.
visit (*
this);
105 #endif // _MADARA_NO_KARL_ This class encapsulates an entry in a KnowledgeBase.
virtual void accept(Visitor &visitor) const
Accepts a visitor subclassed from the Visitor class.
SystemCallRandInt(madara::knowledge::ThreadSafeContext &context, const ComponentNodes &nodes)
Constructor.
MADARA_Export int64_t rand_int(int64_t floor=0, int64_t ceiling=RAND_MAX, bool set_seed_to_time=true)
Returns a random integer between a floor and ceiling.
madara::knowledge::KnowledgeRecord KnowledgeRecord
std::deque< ComponentNode * > ComponentNodes
a vector of Component Nodes
virtual ~SystemCallRandInt(void)
Destructor.
virtual madara::knowledge::KnowledgeRecord prune(bool &can_change)
Prunes the expression tree of unnecessary nodes.
logger::Logger * logger_
handle the context
virtual madara::knowledge::KnowledgeRecord evaluate(const madara::knowledge::KnowledgeUpdateSettings &settings)
Evaluates the expression tree.
This class stores variables and their values for use by any entity needing state information in a thr...
Defines a node that contains a madara::knowledge::KnowledgeRecord::Integer value. ...
#define madara_logger_ptr_log(logger, level,...)
Fast version of the madara::logger::log method for Logger pointers.
Abstract base class for all visitors to all classes that derive from ComponentNode.
Interface for a MADARA system call.
virtual madara::knowledge::KnowledgeRecord item(void) const
Returns the value of the node.
Settings for applying knowledge updates.
virtual void visit(const LeafNode &node)=0
Visit a LeafNode.