2 #ifndef _MADARA_NO_KARL_ 19 key_expansion_necessary_ (false)
32 "Variable %s requires variable expansion\n",
35 unsigned int count = 0;
38 std::stringstream builder;
39 std::vector< std::string>::const_iterator token =
tokens_.begin ();
43 for (++token, ++count; token !=
tokens_.end (); ++token, ++count)
60 return builder.str ();
72 visitor.
visit (*
this);
103 "CompositeArrayReference::prune: " 104 "KARL COMPILE ERROR:" 105 "Reserved word 'nan' used as an array reference.\n",
110 "KARL COMPILE ERROR: " 111 "Reserved word 'nan' used as an array reference.");
113 else if (key ==
"inf")
116 "CompositeArrayReference::prune: " 117 "KARL COMPILE ERROR:" 118 "Reserved word 'inf' used as an array reference.\n",
123 "KARL COMPILE ERROR: " 124 "Reserved word 'inf' used as an array reference.");
176 if (record->write_quality != record->quality)
177 record->
quality = record->write_quality;
217 if (record->write_quality != record->quality)
218 record->
quality = record->write_quality;
246 int return_value = 0;
249 return_value =
set (value.
to_integer (), settings);
251 return_value =
set (value.
to_double (), settings);
273 if (record->write_quality != record->quality)
274 record->
quality = record->write_quality;
276 record->set_index (index, value);
303 if (record->write_quality != record->quality)
304 record->
quality = record->write_quality;
306 record->set_index (index, value);
316 #endif // _MADARA_NO_KARL_ This class encapsulates an entry in a KnowledgeBase.
std::vector< std::string > splitters_
virtual madara::knowledge::KnowledgeRecord prune(bool &can_change)
Prune the tree of unnecessary nodes.
int32_t type(void) const
returns the size of the value
int set(const madara::knowledge::KnowledgeRecord::Integer &value, const madara::knowledge::KnowledgeUpdateSettings &settings=knowledge::KnowledgeUpdateSettings())
Sets the value stored in the node.
ComponentNode * right_
Right expression.
uint32_t quality
priority of the update
madara::knowledge::KnowledgeRecord KnowledgeRecord
void mark_and_signal(VariableReference ref, const KnowledgeUpdateSettings &settings=KnowledgeUpdateSettings())
method for marking a record modified and signaling changes
double to_double(void) const
converts the value to a float/double.
KnowledgeRecord * get_record_unsafe(void) const
Returns a pointer to the variable's KnowledgeRecord Do not use this pointer unless you've locked the ...
knowledge::KnowledgeRecord inc(const madara::knowledge::KnowledgeUpdateSettings &settings=knowledge::KnowledgeUpdateSettings())
Sets the value stored in the node.
virtual madara::knowledge::KnowledgeRecord item(void) const
Returns the value of the node.
logger::Logger * logger_
handle the context
const std::string & key(void) const
Return the variable key.
This class stores variables and their values for use by any entity needing state information in a thr...
virtual madara::knowledge::KnowledgeRecord evaluate(const madara::knowledge::KnowledgeUpdateSettings &settings)=0
Evaluates the expression tree.
madara::knowledge::VariableReference expand(const std::string &key, const std::string &print_prefix, madara::knowledge::ThreadSafeContext &context, madara::logger::Logger *cur_logger, bool &key_expansion_necessary, std::vector< std::string > &splitters, std::vector< std::string > &tokens, std::vector< std::string > &pivot_list)
Expands a key into either a VariableReference or tokens.
int set_index(const std::string &key, size_t index, T &&value, const KnowledgeUpdateSettings &settings=KnowledgeUpdateSettings())
Atomically sets the value of an array index to a value.
bool is_valid(void) const
Checks to see if the variable reference has been initialized.
virtual void accept(Visitor &visitor) const
Define the accept() operation used for the Visitor pattern.
std::vector< std::string > pivot_list_
virtual madara::knowledge::KnowledgeRecord item(void) const
Return the item stored in the node.
bool key_expansion_necessary_
Expansion necessary.
#define madara_logger_ptr_log(logger, level,...)
Fast version of the madara::logger::log method for Logger pointers.
An abstract base class defines a simple abstract implementation of an expression tree node...
Abstract base class for all visitors to all classes that derive from ComponentNode.
Integer to_integer(void) const
converts the value to an integer.
An exception for unrecoverable KaRL compilation issues.
virtual madara::knowledge::KnowledgeRecord evaluate(const madara::knowledge::KnowledgeUpdateSettings &settings)
Evaluates the node and its children.
CompositeArrayReference(const std::string &key, ComponentNode *index, madara::knowledge::ThreadSafeContext &context)
Constructor.
knowledge::KnowledgeRecord dec(const madara::knowledge::KnowledgeUpdateSettings &settings=knowledge::KnowledgeUpdateSettings())
Sets the value stored in the node.
bool always_overwrite
Toggle for always overwriting records, regardless of quality, clock values, etc.
std::vector< std::string > tokens_
madara::knowledge::ThreadSafeContext & context_
KnowledgeRecord * get_record(const std::string &key, const KnowledgeReferenceSettings &settings=KnowledgeReferenceSettings())
Retrieves a knowledge record from the key.
Settings for applying knowledge updates.
Encapsulates a single expression tree.
virtual void visit(const LeafNode &node)=0
Visit a LeafNode.
madara::knowledge::KnowledgeRecord get(const std::string &key, const KnowledgeReferenceSettings &settings=KnowledgeReferenceSettings()) const
Atomically returns the value of a variable.
KnowledgeRecord retrieve_index(size_t index) const
retrieves the value at an array index.
KnowledgeRecord retrieve_index(const std::string &key, size_t index, const KnowledgeReferenceSettings &settings=KnowledgeReferenceSettings())
Retrieves a value at a specified index within a knowledge array.
std::string key_
Key for retrieving value of this variable.
std::string to_string(const std::string &delimiter=", ") const
converts the value to a string.
madara::knowledge::VariableReference ref_
std::string expand_key(void) const
Expands the key (if necessary).