2 #ifndef _MADARA_NO_KARL_
36 for (ComponentNodes::iterator i = nodes_.begin(); i != nodes_.end(); ++i)
38 bool arg_can_change =
false;
39 result = (*i)->prune(arg_can_change);
41 if (!arg_can_change &&
dynamic_cast<LeafNode*
>(*i) == 0)
44 *i =
new LeafNode(*(this->logger_), result);
48 if (nodes_.size() != 2)
51 "madara::expression::SystemCallWriteFile: "
53 "System call write_file requires 2 arguments: "
54 "a knowledge record and a file name\n");
57 "madara::expression::SystemCallWriteFile: "
58 "KARL COMPILE ERROR: "
59 "System call write_file requires 2 arguments: "
60 "a knowledge record and a file name\n");
74 if (nodes_.size() == 2)
85 "madara::expression::SystemCallWriteFile: "
86 "System call write_file is attempting to open %s.\n",
91 if (bytes_written <= 0)
94 "madara::expression::SystemCallWriteFile: "
95 "KARL ERROR: System call write_file could not write to %s\n",
103 "madara::expression::SystemCallWriteFile: "
104 "System call write_file wrote %zd bytes to %s\n",
105 bytes_written, filename->
to_string().c_str());
111 "madara::expression::SystemCallWriteFile: "
112 "KARL RUNTIME ERROR:"
113 "System call write_file requires 2 arguments: "
114 "a knowledge record and a file name\n");
117 "madara::expression::SystemCallWriteFile: "
118 "KARL RUNTIME ERROR: "
119 "System call write_file requires 2 arguments: "
120 "a knowledge record and a file name\n");
130 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 void accept(Visitor &visitor) const
Accepts a visitor subclassed from the Visitor class.
virtual ~SystemCallWriteFile(void)
Destructor.
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 value of the node.
SystemCallWriteFile(madara::knowledge::ThreadSafeContext &context, const ComponentNodes &nodes)
Constructor.
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.
std::string to_string(const std::string &delimiter=", ") const
converts the value to a string.
ssize_t to_file(const std::string &filename) const
writes the value to a file
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