1 #ifndef _MADARA_EXTERNAL_FUNCTION_VARIABLES_CPP_     2 #define _MADARA_EXTERNAL_FUNCTION_VARIABLES_CPP_    38       "Variables::get. Context not set correctly\n");
    57       "Variables::get. Context not set correctly\n");
    76       "Variables::exists. Context not set correctly\n");
    95       "Variables::exists. Context not set correctly\n");
   112       "Variables::apply_modified. Context not set correctly\n");
   130       "Variables::retrieve_index. Context not set correctly\n");
   149       "Variables::retrieve_index. Context not set correctly\n");
   166       "Variables::get_ref. Context not set correctly\n");
   185       "Variables::set. Context not set correctly\n");
   203       "Variables::set. Context not set correctly\n");
   219     return context_->
set (variable, value, size, settings);
   224       "Variables::set. Context not set correctly\n");
   239     return context_->
set (variable, value, size, settings);
   244       "Variables::set. Context not set correctly\n");
   253   const std::vector <KnowledgeRecord::Integer> & value,
   264       "Variables::set. Context not set correctly\n");
   273   const std::vector <KnowledgeRecord::Integer> & value,
   283       "Variables::set. Context not set correctly\n");
   303       "Variables::set. Context not set correctly\n");
   322       "Variables::set. Context not set correctly\n");
   342       "Variables::set. Context not set correctly\n");
   361       "Variables::set. Context not set correctly\n");
   370   const double * value,
   377     return context_->
set (variable, value, size, settings);
   382       "Variables::set. Context not set correctly\n");
   391   const double * value,
   397     return context_->
set (variable, value, size, settings);
   402       "Variables::set. Context not set correctly\n");
   411   const std::vector <double> & value,
   422       "Variables::set. Context not set correctly\n");
   431   const std::vector <double> & value,
   441       "Variables::set. Context not set correctly\n");
   460       "Variables::set. Context not set correctly\n");
   479       "Variables::set. Context not set correctly\n");
   497       "Variables::inc. Context not set correctly\n");
   515       "Variables::inc. Context not set correctly\n");
   534       "Variables::dec. Context not set correctly\n");
   552       "Variables::dec. Context not set correctly\n");
   568       array_delimiter, record_delimiter, key_val_delimiter);
   573       "Variables::to_string. Context not set correctly\n");
   587       "Variables::print. Context not set correctly\n");
   594                                    unsigned int level)
 const   603       "Variables::print. Context not set correctly\n");
   618       "Variables::expand_statement. Context not set correctly\n");
   625 #ifndef _MADARA_NO_KARL_   639       "Variables::define_function. Context not set correctly\n");
   655       "Variables::define_function. Context not set correctly\n");
   660 #ifdef _MADARA_PYTHON_CALLBACKS_   664   const std::string & name, boost::python::object callable)
   673       "Variables::define_function. Context not set correctly\n");
   695       "Variables::define_function. Context not set correctly\n");
   715       "Variables::define_function. Context not set correctly\n");
   730       "Variables::compile. Context not set correctly\n");
   749       "Variables::evaluate. Context not set correctly\n");
   767       "Variables::evaluate. Context not set correctly\n");
   773 #endif // _MADARA_NO_KARL_   780                               std::vector <KnowledgeRecord> & target)
   791       "Variables::to_vector. Context not set correctly\n");
   810       "Variables::get_matches: Context not set correctly\n");
   817   std::map <std::string, knowledge::KnowledgeRecord> & target)
   828       "Variables::to_map. Context not set correctly\n");
   849       "Variables::save_context. Context not set correctly\n");
   868       "Variables::save_as_karl. Context not set correctly\n");
   877   bool reset_modifieds)
   891       "Variables::save_checkpoint. Context not set correctly\n");
   912       "Variables::load_context. Context not set correctly\n");
   930       "Variables::write_file. Context not set correctly\n");
 This class encapsulates an entry in a KnowledgeBase. 
int64_t save_as_karl(const std::string &filename) const 
Saves the context to a file as karl assignments, rather than binary. 
madara::knowledge::KnowledgeRecord dec(const std::string &key, const KnowledgeUpdateSettings &settings=KnowledgeUpdateSettings())
Atomically decrements the value of the variable. 
int set(const std::string &key, T &&value, const KnowledgeUpdateSettings &settings=KnowledgeUpdateSettings())
Atomically sets the value of a variable to the specific record. 
int64_t save_checkpoint(const std::string &filename, bool reset_modifieds=true)
Saves a checkpoint of a list of changes to a file. 
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. 
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. 
VariableReference get_ref(const std::string &key, const KnowledgeReferenceSettings &settings=knowledge::KnowledgeReferenceSettings(false))
Retrieves the value of a variable. 
int64_t save_context(const std::string &filename)
Saves the context to a file. 
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...
madara::knowledge::KnowledgeRecord get(const std::string &key, const KnowledgeReferenceSettings &settings=KnowledgeReferenceSettings()) const 
Atomically returns the value of a variable. 
int64_t save_context(const std::string &filename, const std::string &id="") const 
Saves the context to a file. 
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. 
madara::knowledge::KnowledgeRecord KnowledgeRecord
int64_t load_context(const std::string &filename, const KnowledgeUpdateSettings &settings=KnowledgeUpdateSettings(true, true, true, false))
Loads the context from a file. 
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). 
void define_function(const std::string &name, knowledge::KnowledgeRecord(*func)(FunctionArguments &, Variables &))
Defines a function. 
std::string expand_statement(const std::string &statement) const 
Expands a string with variable expansion. 
ssize_t to_file(const std::string &filename) const 
writes the value to a file 
This class stores variables and their values for use by any entity needing state information in a thr...
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. 
void print(unsigned int level) const 
Atomically prints all variables and values in the context. 
knowledge::KnowledgeRecord dec(const std::string &key, const KnowledgeUpdateSettings &settings=knowledge::KnowledgeUpdateSettings(false, true, false, false))
Decrements the value of the variable. 
MADARA_Export utility::Refcounter< logger::Logger > global_logger
int64_t save_as_karl(const std::string &filename) const 
Saves the context to a file as karl assignments, rather than binary. 
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...
Optimized reference to a variable within the knowledge base. 
Compiled, optimized KaRL logic. 
std::vector< KnowledgeRecord > FunctionArguments
void define_function(const std::string &name, knowledge::KnowledgeRecord(*func)(FunctionArguments &, Variables &), const KnowledgeReferenceSettings &settings=KnowledgeReferenceSettings())
Defines an external function. 
bool exists(const std::string &key, const KnowledgeReferenceSettings &settings=KnowledgeReferenceSettings()) const 
Atomically checks to see if a variable already exists. 
void operator=(Variables &rhs)
Assignment operator. 
void apply_modified(void)
Changes all global variables to modified at current clock. 
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. 
madara::expression::ExpressionTree expression
the expression tree 
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...
#define madara_logger_ptr_log(logger, level,...)
Fast version of the madara::logger::log method for Logger pointers. 
madara::knowledge::KnowledgeRecord inc(const std::string &key, const KnowledgeUpdateSettings &settings=KnowledgeUpdateSettings())
Atomically increments the value of the variable. 
bool exists(const std::string &key, const KnowledgeReferenceSettings &settings=KnowledgeReferenceSettings(false)) const 
Checks if a knowledge location exists in the context. 
ThreadSafeContext * context_
Variables context that is directly used by the KaRL engine. 
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...
std::vector< VariableReference > VariableReferences
a vector of variable references 
ssize_t write_file(const std::string &knowledge_key, const std::string &filename)
Write a file from the context to a specified location. 
CompiledExpression compile(const std::string &expression)
Compiles a KaRL expression into an expression tree. 
std::string expand_statement(const std::string &statement) const 
Expands a string with variable expansion. 
KnowledgeRecord * get_record(const std::string &key, const KnowledgeReferenceSettings &settings=KnowledgeReferenceSettings())
Retrieves a knowledge record from the key. 
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. 
void apply_modified(const KnowledgeUpdateSettings &settings=knowledge::KnowledgeUpdateSettings())
Applies modified to all global variables. 
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. 
VariableReference get_ref(const std::string &key, const KnowledgeReferenceSettings &settings=KnowledgeReferenceSettings())
Atomically returns a reference to the variable. 
knowledge::KnowledgeRecord inc(const std::string &key, const KnowledgeUpdateSettings &settings=knowledge::KnowledgeUpdateSettings(false, true, false, false))
Atomically increments the value of the variable. 
Settings for applying knowledge updates. 
Settings for applying knowledge updates. 
knowledge::KnowledgeRecord get(const std::string &key, const KnowledgeReferenceSettings &settings=knowledge::KnowledgeReferenceSettings(false))
Retrieves the value of a variable. 
Provides an interface for external functions into the MADARA KaRL variable settings. 
void print(unsigned int level=0) const 
Prints all variables and values in the context. 
madara::knowledge::KnowledgeRecord evaluate(const madara::knowledge::KnowledgeUpdateSettings &settings=knowledge::KnowledgeUpdateSettings())
Evaluates the expression tree. 
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. 
CompiledExpression compile(const std::string &expression)
Compiles a KaRL expression into an expression tree. 
ThreadSafeContext * get_context(void)
Returns the ThreadSafeContext associated with this Variables facade. 
void reset_modified(void)
Reset all variables to be unmodified.