1 #ifndef _MADARA_EXTERNAL_FUNCTION_VARIABLES_CPP_
2 #define _MADARA_EXTERNAL_FUNCTION_VARIABLES_CPP_
36 "Variables::get. Context not set correctly\n");
55 "Variables::get. Context not set correctly\n");
73 "Variables::exists. Context not set correctly\n");
91 "Variables::exists. Context not set correctly\n");
107 "Variables::apply_modified. Context not set correctly\n");
123 "Variables::retrieve_index. Context not set correctly\n");
140 "Variables::retrieve_index. Context not set correctly\n");
156 "Variables::get_ref. Context not set correctly\n");
174 "Variables::set. Context not set correctly\n");
191 "Variables::set. Context not set correctly\n");
204 return context_->
set(variable, value, size, settings);
209 "Variables::set. Context not set correctly\n");
221 return context_->
set(variable, value, size, settings);
226 "Variables::set. Context not set correctly\n");
233 const std::vector<KnowledgeRecord::Integer>& value,
244 "Variables::set. Context not set correctly\n");
251 const std::vector<KnowledgeRecord::Integer>& value,
261 "Variables::set. Context not set correctly\n");
279 "Variables::set. Context not set correctly\n");
296 "Variables::set. Context not set correctly\n");
313 "Variables::set. Context not set correctly\n");
329 "Variables::set. Context not set correctly\n");
341 return context_->
set(variable, value, size, settings);
346 "Variables::set. Context not set correctly\n");
357 return context_->
set(variable, value, size, settings);
362 "Variables::set. Context not set correctly\n");
379 "Variables::set. Context not set correctly\n");
395 "Variables::set. Context not set correctly\n");
412 "Variables::set. Context not set correctly\n");
428 "Variables::set. Context not set correctly\n");
445 "Variables::inc. Context not set correctly\n");
461 "Variables::inc. Context not set correctly\n");
478 "Variables::dec. Context not set correctly\n");
494 "Variables::dec. Context not set correctly\n");
507 target, array_delimiter, record_delimiter, key_val_delimiter);
512 "Variables::to_string. Context not set correctly\n");
525 "Variables::print. Context not set correctly\n");
530 const std::string& statement,
unsigned int level)
const
539 "Variables::print. Context not set correctly\n");
553 "Variables::expand_statement. Context not set correctly\n");
559 #ifndef _MADARA_NO_KARL_
572 "Variables::define_function. Context not set correctly\n");
588 "Variables::define_function. Context not set correctly\n");
593 #ifdef _MADARA_PYTHON_CALLBACKS_
597 const std::string& name, boost::python::object callable)
606 "Variables::define_function. Context not set correctly\n");
627 "Variables::define_function. Context not set correctly\n");
646 "Variables::define_function. Context not set correctly\n");
660 "Variables::compile. Context not set correctly\n");
677 "Variables::evaluate. Context not set correctly\n");
693 "Variables::evaluate. Context not set correctly\n");
702 unsigned int start,
unsigned int end, std::vector<KnowledgeRecord>& target)
713 "Variables::to_vector. Context not set correctly\n");
729 "Variables::get_matches: Context not set correctly\n");
734 std::map<std::string, knowledge::KnowledgeRecord>& target)
745 "Variables::to_map. Context not set correctly\n");
762 "Variables::save_context. Context not set correctly\n");
780 "Variables::save_as_karl. Context not set correctly\n");
801 "Variables::save_checkpoint. Context not set correctly\n");
820 "Variables::load_context. Context not set correctly\n");
837 "Variables::write_file. Context not set correctly\n");
#define madara_logger_ptr_log(loggering, level,...)
Fast version of the madara::logger::log method for Logger pointers.
const ThreadSafeContext * context_
madara::knowledge::KnowledgeRecord KnowledgeRecord
madara::knowledge::KnowledgeRecord evaluate(const madara::knowledge::KnowledgeUpdateSettings &settings=knowledge::KnowledgeUpdateSettings())
Evaluates the expression tree.
Compiled, optimized KaRL logic.
madara::expression::ExpressionTree expression
the expression tree
This class encapsulates an entry in a KnowledgeBase.
ssize_t to_file(const std::string &filename) const
writes the value to a file
Settings for applying knowledge updates.
Settings for applying knowledge updates.
This class stores variables and their values for use by any entity needing state information in a thr...
CompiledExpression compile(const std::string &expression)
Compiles a KaRL expression into an expression tree.
bool exists(const std::string &key, const KnowledgeReferenceSettings &settings=KnowledgeReferenceSettings()) const
Atomically checks to see if a variable already exists.
void to_string(std::string &target, const std::string &array_delimiter=",", const std::string &record_delimiter=";\n", const std::string &key_val_delimiter="=") const
Saves all keys and values into a string, using the underlying knowledge::KnowledgeRecord::to_string f...
madara::knowledge::KnowledgeRecord get(const std::string &key, const KnowledgeReferenceSettings &settings=KnowledgeReferenceSettings()) const
Atomically returns the current value of a variable.
void apply_modified(void)
Changes all global variables to modified at current clock.
void define_function(const std::string &name, knowledge::KnowledgeRecord(*func)(FunctionArguments &, Variables &), const KnowledgeReferenceSettings &settings=KnowledgeReferenceSettings())
Defines an external function.
void get_matches(const std::string &prefix, const std::string &suffix, VariableReferences &matches)
Creates an iteration of VariableReferences to all keys matching the prefix and suffix.
int set(const std::string &key, T &&value, const KnowledgeUpdateSettings &settings=KnowledgeUpdateSettings())
Atomically sets the value of a variable to the specific record.
VariableReference get_ref(const std::string &key, const KnowledgeReferenceSettings &settings=KnowledgeReferenceSettings())
Atomically returns a reference to the variable.
int64_t save_context(const std::string &filename, const std::string &id="") const
Saves the context to a file.
madara::knowledge::KnowledgeRecord inc(const std::string &key, const KnowledgeUpdateSettings &settings=KnowledgeUpdateSettings())
Atomically increments the value of the variable.
KnowledgeRecord * get_record(const std::string &key, const KnowledgeReferenceSettings &settings=KnowledgeReferenceSettings())
Retrieves a knowledge record from the key.
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.
size_t to_map(const std::string &subject, std::map< std::string, knowledge::KnowledgeRecord > &target)
Fills a variable map with Knowledge Records that match an expression.
std::string expand_statement(const std::string &statement) const
Expands a string with variable expansion.
int64_t load_context(const std::string &filename, std::string &id, const KnowledgeUpdateSettings &settings=KnowledgeUpdateSettings(true, true, true, false))
Loads the context from a file.
madara::knowledge::KnowledgeRecord dec(const std::string &key, const KnowledgeUpdateSettings &settings=KnowledgeUpdateSettings())
Atomically decrements the value of the variable.
size_t to_vector(const std::string &subject, unsigned int start, unsigned int end, std::vector< KnowledgeRecord > &target)
Fills a vector with Knowledge Records that begin with a common subject and have a finite range of int...
void print(unsigned int level) const
Atomically prints all variables and values in the context.
void reset_modified(void)
Reset all variables to be unmodified.
int64_t save_as_karl(const std::string &filename) const
Saves the context to a file as karl assignments, rather than binary.
Optimized reference to a variable within the knowledge base.
Provides an interface for external functions into the MADARA KaRL variable settings.
madara::knowledge::KnowledgeRecord evaluate(const std::string &expression, const KnowledgeUpdateSettings &settings=knowledge::KnowledgeUpdateSettings())
Evaluates an expression (USE ONLY FOR PROTOTYPING; DO NOT USE IN PRODUCTION SYSTEMS).
knowledge::KnowledgeRecord dec(const std::string &key, const KnowledgeUpdateSettings &settings=knowledge::KnowledgeUpdateSettings(false, true, false, false))
Decrements the value of the variable.
void get_matches(const std::string &prefix, const std::string &suffix, VariableReferences &matches)
Creates an iteration of VariableReferences to all keys matching the prefix and suffix.
void operator=(Variables &rhs)
Assignment operator.
void to_string(std::string &target, const std::string &array_delimiter=",", const std::string &record_delimiter=";\n", const std::string &key_val_delimiter="=") const
Saves all keys and values into a string, using the underlying knowledge::KnowledgeRecord::to_string f...
int set(const std::string &key, madara::knowledge::KnowledgeRecord::Integer value, const KnowledgeUpdateSettings &settings=knowledge::KnowledgeUpdateSettings(false, true, false, false))
Sets the value of a variable.
size_t to_vector(const std::string &subject, unsigned int start, unsigned int end, std::vector< KnowledgeRecord > &target)
Fills a vector with Knowledge Records that begin with a common subject and have a finite range of int...
size_t to_map(const std::string &subject, std::map< std::string, knowledge::KnowledgeRecord > &target)
Fills a variable map with Knowledge Records that match an expression.
void define_function(const std::string &name, knowledge::KnowledgeRecord(*func)(FunctionArguments &, Variables &))
Defines a function.
void apply_modified(const KnowledgeUpdateSettings &settings=knowledge::KnowledgeUpdateSettings())
Applies modified to all global variables.
int64_t save_checkpoint(const std::string &filename, bool reset_modifieds=true)
Saves a checkpoint of a list of changes to a file.
ThreadSafeContext * context_
Variables context that is directly used by the KaRL engine.
void print(unsigned int level=0) const
Prints all variables and values in the context.
int64_t save_context(const std::string &filename)
Saves the context to a file.
std::string expand_statement(const std::string &statement) const
Expands a string with variable expansion.
bool exists(const std::string &key, const KnowledgeReferenceSettings &settings=KnowledgeReferenceSettings(false)) const
Checks if a knowledge location exists in the context.
int64_t save_as_karl(const std::string &filename) const
Saves the context to a file as karl assignments, rather than binary.
VariableReference get_ref(const std::string &key, const KnowledgeReferenceSettings &settings=knowledge::KnowledgeReferenceSettings(false))
Retrieves the value of a variable.
int64_t load_context(const std::string &filename, const KnowledgeUpdateSettings &settings=KnowledgeUpdateSettings(true, true, true, false))
Loads the context from a file.
CompiledExpression compile(const std::string &expression)
Compiles a KaRL expression into an expression tree.
madara::knowledge::KnowledgeRecord retrieve_index(const std::string &key, size_t index, const KnowledgeReferenceSettings &settings=knowledge::KnowledgeReferenceSettings(false))
Retrieves a value at a specified index within a knowledge array.
ThreadSafeContext * get_context(void)
Returns the ThreadSafeContext associated with this Variables facade.
knowledge::KnowledgeRecord inc(const std::string &key, const KnowledgeUpdateSettings &settings=knowledge::KnowledgeUpdateSettings(false, true, false, false))
Atomically increments the value of the variable.
knowledge::KnowledgeRecord get(const std::string &key, const KnowledgeReferenceSettings &settings=knowledge::KnowledgeReferenceSettings(false))
Retrieves the value of a variable.
ssize_t write_file(const std::string &knowledge_key, const std::string &filename)
Write a file from the context to a specified location.
T get(const KnowledgeRecord &kr)
Get the value of a KnowlegeRecord.
std::vector< KnowledgeRecord > FunctionArguments
std::vector< VariableReference > VariableReferences
a vector of variable references
MADARA_EXPORT utility::Refcounter< logger::Logger > global_logger