2 #ifndef _FUNCTION_NODE_CPP_ 3 #define _FUNCTION_NODE_CPP_ 5 #ifndef _MADARA_NO_KARL_ 21 #ifdef _MADARA_PYTHON_CALLBACKS_ 23 #include <boost/python/call.hpp> 29 #include "madara_jni.h" 67 bool is_double (
false);
68 ComponentNodes::size_type i = 0;
70 for (; i <
nodes_.size (); ++i)
72 bool arg_can_change =
false;
73 args[i] =
nodes_[i]->prune (arg_can_change);
81 if (!arg_can_change && dynamic_cast <LeafNode *> (
nodes_[i]) == 0)
86 else if (arg_can_change)
98 result.
set_index (i - 1, args[i - 1].to_double ());
100 result.
set_index (i - 1, args[i - 1].to_integer ());
102 for (i = 0; i < args.size () - 1; ++i)
105 result.
set_index (i, args[i].to_double ());
107 result.
set_index (i, args[i].to_integer ());
113 "KARL COMPILE ERROR: Array initialized with no elements\n");
130 bool is_double (
false);
134 for (ComponentNodes::iterator i =
nodes_.begin (); i !=
nodes_.end ();
137 args[j] = (*i)->evaluate (settings);
151 if (args.size () > 0)
155 result.
set_index (j - 1, args[j - 1].to_double ());
157 result.
set_index (j - 1, args[j - 1].to_integer ());
159 for (
size_t i = 0; i < args.size () - 1; ++i)
162 result.
set_index (i, args[i].to_double ());
164 result.
set_index (i, args[i].to_integer ());
175 visitor.
visit (*
this);
178 #endif // _MADARA_NO_KARL_ This class encapsulates an entry in a KnowledgeBase.
madara::knowledge::KnowledgeRecord KnowledgeRecord
std::deque< ComponentNode * > ComponentNodes
a vector of Component Nodes
virtual void accept(Visitor &visitor) const
Accepts a visitor subclassed from the Visitor class.
void clear_value(void) noexcept
clears any dynamic values.
logger::Logger * logger_
handle the context
virtual madara::knowledge::KnowledgeRecord prune(bool &can_change)
Prunes the expression tree of unnecessary nodes.
virtual madara::knowledge::KnowledgeRecord evaluate(const madara::knowledge::KnowledgeUpdateSettings &settings)
Evaluates the expression tree.
virtual madara::knowledge::KnowledgeRecord item(void) const
Returns the printable character of the node.
Defines a node that contains a madara::knowledge::KnowledgeRecord::Integer value. ...
Provides knowledge logging services to files and terminals.
std::vector< KnowledgeRecord > FunctionArguments
A multi-threaded logger for logging to one or more destinations.
#define madara_logger_ptr_log(logger, level,...)
Fast version of the madara::logger::log method for Logger pointers.
virtual ~CompositeConstArray(void)
Destructor.
Abstract base class for all visitors to all classes that derive from ComponentNode.
void set_index(size_t index, T value)
sets the value at the index to the specified value.
Settings for applying knowledge updates.
virtual void visit(const LeafNode &node)=0
Visit a LeafNode.
Copyright (c) 2015 Carnegie Mellon University.
void resize(size_t new_size)
resizes an array to a new size
CompositeConstArray(logger::Logger &logger, const ComponentNodes &nodes)
Constructor.