MADARA  3.4.1
madara::knowledge::ThreadSafeContext Class Reference

This class stores variables and their values for use by any entity needing state information in a thread safe way. More...

#include <ThreadSafeContext.h>

Public Member Functions

 ThreadSafeContext ()
 Constructor. More...
 
 ~ThreadSafeContext (void)
 Destructor. More...
 
void add_logger (const std::string &filename)
 Adds a file to the logger. More...
 
void add_modifieds (const VariableReferences &modifieds) const
 Adds a list of VariableReferences to the current modified list. More...
 
void apply_modified (void)
 Changes all global variables to modified at current clock. More...
 
void attach_logger (logger::Logger &logger) const
 Attaches a logger to be used for printing. More...
 
std::unique_ptr< BaseStreamerattach_streamer (std::unique_ptr< BaseStreamer > streamer)
 Attach a streaming provider object, inherited from BaseStreamer, such as CheckpointStreamer. More...
 
template<typename Callable >
auto cinvoke (const std::string &key, Callable &&callable, const KnowledgeReferenceSettings &settings=KnowledgeReferenceSettings()) const -> decltype(utility::invoke_(std::forward< Callable >(callable), std::declval< KnowledgeRecord & >()))
 
template<typename Callable >
auto cinvoke (const VariableReference &key, Callable &&callable, const KnowledgeReferenceSettings &settings=KnowledgeReferenceSettings()) const -> decltype(utility::invoke_(std::forward< Callable >(callable), std::declval< KnowledgeRecord & >()))
 
void clear (bool erase=false)
 Clears the context. More...
 
bool clear (const std::string &key, const KnowledgeReferenceSettings &settings=KnowledgeReferenceSettings())
 Clears a variable. More...
 
bool clear (const VariableReference &variable)
 Clears a variable. More...
 
CompiledExpression compile (const std::string &expression)
 Compiles a KaRL expression into an expression tree. More...
 
void copy (const ThreadSafeContext &source, const CopySet &copy_set=CopySet(), bool clean_copy=false, const KnowledgeUpdateSettings &settings=KnowledgeUpdateSettings())
 Copies variables and values from source to this context. More...
 
void copy (const ThreadSafeContext &source, const KnowledgeRequirements &reqs, const KnowledgeUpdateSettings &settings)
 Copies variables and values from source to this context. More...
 
std::string debug_modifieds (void) const
 Retrieves a stringified list of all modified variables that are ready to send over transport on next send_modifieds call. More...
 
madara::knowledge::KnowledgeRecord dec (const std::string &key, const KnowledgeUpdateSettings &settings=KnowledgeUpdateSettings())
 Atomically decrements the value of the variable. More...
 
madara::knowledge::KnowledgeRecord dec (const VariableReference &variable, const KnowledgeUpdateSettings &settings=KnowledgeUpdateSettings())
 Atomically decrements the value of the variable. More...
 
void define_function (const std::string &name, boost::python::object callable, const KnowledgeReferenceSettings &settings=KnowledgeReferenceSettings())
 Defines a named python function. More...
 
void define_function (const std::string &name, const CompiledExpression &expression, const KnowledgeReferenceSettings &settings=KnowledgeReferenceSettings())
 Defines a MADARA KaRL function. More...
 
void define_function (const std::string &name, const std::string &expression, const KnowledgeReferenceSettings &settings=KnowledgeReferenceSettings())
 Defines a MADARA KaRL function. More...
 
void define_function (const std::string &name, jobject callable, const KnowledgeReferenceSettings &settings=KnowledgeReferenceSettings())
 Defines a named java function. More...
 
void define_function (const std::string &name, knowledge::KnowledgeRecord(*func)(const char *, FunctionArguments &, Variables &), const KnowledgeReferenceSettings &settings=KnowledgeReferenceSettings())
 Defines a named function that can distinguish the name it was called with in MADARA. More...
 
void define_function (const std::string &name, knowledge::KnowledgeRecord(*func)(FunctionArguments &, Variables &), const KnowledgeReferenceSettings &settings=KnowledgeReferenceSettings())
 Defines an external function. More...
 
bool delete_expression (const std::string &expression)
 Deletes the expression from the interpreter cache. More...
 
void delete_prefix (const std::string &prefix, const KnowledgeReferenceSettings &settings=KnowledgeReferenceSettings())
 Deletes keys starting with the given prefix. More...
 
bool delete_variable (const std::string &key, const KnowledgeReferenceSettings &settings=KnowledgeReferenceSettings())
 Deletes the key. More...
 
bool delete_variable (const VariableReference &var, const KnowledgeReferenceSettings &settings=KnowledgeReferenceSettings())
 Deletes the variable. More...
 
void delete_variables (KnowledgeMap::iterator begin, KnowledgeMap::iterator end, const KnowledgeReferenceSettings &settings=KnowledgeReferenceSettings())
 Deletes variables. More...
 
knowledge::KnowledgeRecord evaluate (CompiledExpression expression, const KnowledgeUpdateSettings &settings=KnowledgeUpdateSettings())
 Evaluate a compiled expression. More...
 
knowledge::KnowledgeRecord evaluate (expression::ComponentNode *root, const KnowledgeUpdateSettings &settings=KnowledgeUpdateSettings())
 Evaluate a component node-rooted tree. More...
 
KnowledgeRecord evaluate_file (CheckpointSettings &checkpoint_settings, const KnowledgeUpdateSettings &update_settings=KnowledgeUpdateSettings(true, true, true, false))
 Loads and evaluates a karl script from a file. More...
 
bool exists (const std::string &key, const KnowledgeReferenceSettings &settings=KnowledgeReferenceSettings()) const
 Atomically checks to see if a variable already exists. More...
 
bool exists (const VariableReference &variable, const KnowledgeReferenceSettings &settings=KnowledgeReferenceSettings(false)) const
 Checks if a knowledge variable exists in the context. More...
 
std::string expand_statement (const std::string &statement) const
 Expands a string with variable expansion. More...
 
std::string file_to_string (CheckpointSettings &checkpoint_settings)
 Loads and returns a karl script from a file with encode/decode. More...
 
template<typename Func >
void for_each (Func &&func) const
 Call given Callable on each element in this context. More...
 
madara::knowledge::KnowledgeRecord get (const std::string &key, const KnowledgeReferenceSettings &settings=KnowledgeReferenceSettings()) const
 Atomically returns the current value of a variable. More...
 
madara::knowledge::KnowledgeRecord get (const VariableReference &variable, const KnowledgeReferenceSettings &settings=KnowledgeReferenceSettings()) const
 Atomically returns the current value of a variable. More...
 
madara::knowledge::KnowledgeRecord get_actual (const std::string &key, const KnowledgeReferenceSettings &settings=KnowledgeReferenceSettings()) const
 Atomically returns the underlying value of a variable, including history. More...
 
madara::knowledge::KnowledgeRecord get_actual (const VariableReference &variable, const KnowledgeReferenceSettings &settings=KnowledgeReferenceSettings()) const
 Atomically returns the underlying value of a variable, including history. More...
 
uint64_t get_clock (const std::string &key, const KnowledgeReferenceSettings &settings=KnowledgeReferenceSettings()) const
 Atomically gets the Lamport clock of a variable. More...
 
uint64_t get_clock (void) const
 Atomically gets the Lamport clock. More...
 
const VariableReferenceMapget_local_modified (void) const
 Retrieves a list of modified local variables. More...
 
int get_log_level (void)
 Gets the log level. More...
 
logger::Loggerget_logger (void) const
 Gets the logger used for information printing. More...
 
KnowledgeMapget_map_unsafe (void)
 NOT THREAD SAFE! More...
 
const KnowledgeMapget_map_unsafe (void) const
 NOT THREAD SAFE! More...
 
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. More...
 
const VariableReferenceMapget_modifieds (void) const
 Retrieves a list of modified variables. More...
 
KnowledgeMap get_modifieds_current (const std::map< std::string, bool > &send_list, bool reset=true)
 Retrieves the current modifieds map. More...
 
uint32_t get_quality (const std::string &key, const KnowledgeReferenceSettings &settings=KnowledgeReferenceSettings())
 Atomically gets quality of a variable. More...
 
KnowledgeRecordget_record (const std::string &key, const KnowledgeReferenceSettings &settings=KnowledgeReferenceSettings())
 Retrieves a knowledge record from the key. More...
 
VariableReference get_ref (const std::string &key, const KnowledgeReferenceSettings &settings=KnowledgeReferenceSettings())
 Atomically returns a reference to the variable. More...
 
VariableReference get_ref (const std::string &key, const KnowledgeReferenceSettings &settings=KnowledgeReferenceSettings()) const
 Atomically returns a reference to the variable. More...
 
uint32_t get_write_quality (const std::string &key, const KnowledgeReferenceSettings &settings=KnowledgeReferenceSettings())
 Atomically gets write quality of this process for a variable. More...
 
madara::knowledge::KnowledgeRecord inc (const std::string &key, const KnowledgeUpdateSettings &settings=KnowledgeUpdateSettings())
 Atomically increments the value of the variable. More...
 
madara::knowledge::KnowledgeRecord inc (const VariableReference &variable, const KnowledgeUpdateSettings &settings=KnowledgeUpdateSettings())
 Atomically increments the value of the variable. More...
 
uint64_t inc_clock (const KnowledgeUpdateSettings &settings=KnowledgeUpdateSettings())
 Atomically increments the Lamport clock and returns the new clock time (intended for sending knowledge updates). More...
 
uint64_t inc_clock (const std::string &key, const KnowledgeUpdateSettings &settings=KnowledgeUpdateSettings())
 Atomically increments the Lamport clock of a variable and returns the new clock time (intended for sending knowledge updates). More...
 
template<typename Callable >
auto invoke (const std::string &key, Callable &&callable, const KnowledgeReferenceSettings &settings=KnowledgeReferenceSettings()) const -> decltype(utility::invoke_(std::forward< Callable >(callable), std::declval< KnowledgeRecord & >()))
 
template<typename Callable >
auto invoke (const std::string &key, Callable &&callable, const KnowledgeUpdateSettings &settings=KnowledgeUpdateSettings()) -> decltype(utility::invoke_(std::forward< Callable >(callable), std::declval< KnowledgeRecord & >()))
 
template<typename Callable >
auto invoke (const VariableReference &key, Callable &&callable, const KnowledgeReferenceSettings &settings=KnowledgeReferenceSettings()) const -> decltype(utility::invoke_(std::forward< Callable >(callable), std::declval< KnowledgeRecord & >()))
 
template<typename Callable >
auto invoke (const VariableReference &key, Callable &&callable, const KnowledgeUpdateSettings &settings=KnowledgeUpdateSettings()) -> decltype(utility::invoke_(std::forward< Callable >(callable), std::declval< KnowledgeRecord & >()))
 
int64_t load_context (CheckpointSettings &checkpoint_settings, const KnowledgeUpdateSettings &update_settings=KnowledgeUpdateSettings(true, true, true, false))
 Loads the context from a file. More...
 
int64_t load_context (const std::string &filename, FileHeader &meta, const KnowledgeUpdateSettings &settings=KnowledgeUpdateSettings(true, true, true, false))
 Loads the context from a file. More...
 
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. More...
 
void lock (void) const
 Locks the mutex on this context. More...
 
void mark_modified (const std::string &key, const KnowledgeUpdateSettings &settings=KnowledgeUpdateSettings())
 Changes global variables to modified at current clock for the purposes of sending or checkpointing knowledge (globals and locals respectively) More...
 
void mark_modified (const VariableReference &variable, const KnowledgeUpdateSettings &settings=KnowledgeUpdateSettings())
 Marks the variable reference as updated for the purposes of sending or checkpointing knowledge (for globals and locals respectively) More...
 
void mark_to_checkpoint (const std::string &key, const KnowledgeUpdateSettings &settings=KnowledgeUpdateSettings())
 Changes variable to modified at current clock for the purposes of checkpointing (even if it is a global). More...
 
void mark_to_checkpoint (const VariableReference &variable, const KnowledgeUpdateSettings &settings=KnowledgeUpdateSettings())
 Changes variable reference to modified at current clock for the purposes of checkpointing (even if it is a global). More...
 
void mark_to_send (const std::string &key, const KnowledgeUpdateSettings &settings=KnowledgeUpdateSettings())
 Changes variable to modified at current clock, and queues it to send, even if it is a local that would not ordinarily be sent. More...
 
void mark_to_send (const VariableReference &variable, const KnowledgeUpdateSettings &settings=KnowledgeUpdateSettings())
 Changes variable reference to modified at current clock, and queues it to send, even if it is a local that would not ordinarily be sent. More...
 
void print (const std::string &statement, unsigned int level) const
 Atomically Print a statement, similar to printf (variable expansions allowed) e.g., input = "MyVar{.id} = {MyVar{.id}}\n";. More...
 
void print (unsigned int level) const
 Atomically prints all variables and values in the context. More...
 
int read_file (const std::string &key, const std::string &filename, const KnowledgeUpdateSettings &settings=KnowledgeUpdateSettings())
 Atomically reads a file into a variable. More...
 
int read_file (const VariableReference &variable, const std::string &filename, const KnowledgeUpdateSettings &settings=KnowledgeUpdateSettings())
 Atomically reads a file into a variable. More...
 
void reset_checkpoint (void) const
 Reset all checkpoint variables in the modified lists. More...
 
void reset_modified (const std::string &key)
 Resets a variable to unmodified. More...
 
void reset_modified (void)
 Reset all variables to be unmodified. More...
 
Functionretrieve_function (const std::string &name, const KnowledgeReferenceSettings &settings=KnowledgeReferenceSettings())
 Retrieves an external function. More...
 
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. More...
 
KnowledgeRecord retrieve_index (const VariableReference &variable, size_t index, const KnowledgeReferenceSettings &settings=KnowledgeReferenceSettings())
 Retrieves a value at a specified index within a knowledge array. More...
 
int64_t save_as_json (const CheckpointSettings &settings) const
 Saves the context to a file as JSON. More...
 
int64_t save_as_json (const std::string &filename) const
 Saves the context to a file as JSON. More...
 
int64_t save_as_karl (const CheckpointSettings &settings) const
 Saves the context to a file as karl assignments, rather than binary. More...
 
int64_t save_as_karl (const std::string &filename) const
 Saves the context to a file as karl assignments, rather than binary. More...
 
int64_t save_checkpoint (const CheckpointSettings &settings) const
 Saves a checkpoint of a list of changes to a file. More...
 
int64_t save_checkpoint (const std::string &filename, const std::string &id="") const
 Saves a checkpoint of a list of changes to a file. More...
 
int64_t save_context (const CheckpointSettings &settings) const
 Saves the context to a file. More...
 
int64_t save_context (const std::string &filename, const std::string &id="") const
 Saves the context to a file. More...
 
VariableReferences save_modifieds (void) const
 Saves the list of modified records to use later for resending. More...
 
template<typename T >
int set (const std::string &key, const T *value, uint32_t size, const KnowledgeUpdateSettings &settings=KnowledgeUpdateSettings())
 Atomically sets the value of a variable to an array. More...
 
template<typename T >
int set (const std::string &key, T &&value, const KnowledgeUpdateSettings &settings=KnowledgeUpdateSettings())
 Atomically sets the value of a variable to the specific record. More...
 
template<typename T >
int set (const VariableReference &variable, const T *value, uint32_t size, const KnowledgeUpdateSettings &settings=KnowledgeUpdateSettings())
 Atomically sets the value of a variable to an array. More...
 
template<typename T >
int set (const VariableReference &variable, T &&value, const KnowledgeUpdateSettings &settings=KnowledgeUpdateSettings())
 Atomically sets the value of a variable to an array. More...
 
void set_changed (void)
 Force a change to be registered, waking up anyone waiting on entry. More...
 
uint64_t set_clock (const std::string &key, uint64_t clock, const KnowledgeReferenceSettings &settings=KnowledgeReferenceSettings())
 Atomically sets the Lamport clock of a variable and returns the new clock time (intended for sending knowledge updates). More...
 
uint64_t set_clock (uint64_t clock)
 Atomically sets the lamport clock. More...
 
int set_file (const std::string &key, const unsigned char *value, size_t size, const KnowledgeUpdateSettings &settings=KnowledgeUpdateSettings())
 Atomically sets the value of a variable to an arbitrary string. More...
 
int set_file (const VariableReference &variable, const unsigned char *value, size_t size, const KnowledgeUpdateSettings &settings=KnowledgeUpdateSettings())
 Atomically sets the value of a variable to an arbitrary string. More...
 
int set_if_unequal (const std::string &key, const std::string &value, uint32_t quality, uint64_t clock, const KnowledgeUpdateSettings &settings=KnowledgeUpdateSettings())
 Atomically sets if the variable value will be different. More...
 
int set_if_unequal (const std::string &key, double value, uint32_t quality, uint64_t clock, const KnowledgeUpdateSettings &settings=KnowledgeUpdateSettings())
 Atomically sets if the variable value will be different. More...
 
int set_if_unequal (const std::string &key, madara::knowledge::KnowledgeRecord::Integer value, uint32_t quality, uint64_t clock, const KnowledgeUpdateSettings &settings=KnowledgeUpdateSettings())
 Atomically sets if the variable value will be different. More...
 
template<typename T >
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. More...
 
template<typename T >
int set_index (const VariableReference &variable, size_t index, T &&value, const KnowledgeUpdateSettings &settings=KnowledgeUpdateSettings())
 Atomically sets the value of an array index to a value. More...
 
template<typename T >
int set_index_unsafe (const VariableReference &variable, size_t index, T &&value, const KnowledgeUpdateSettings &settings=KnowledgeUpdateSettings())
 NON-Atomically sets the value of an array index to a value. More...
 
int set_jpeg (const std::string &key, const unsigned char *value, size_t size, const KnowledgeUpdateSettings &settings=KnowledgeUpdateSettings())
 Atomically sets the value of a variable to a JPEG image. More...
 
int set_jpeg (const VariableReference &variable, const unsigned char *value, size_t size, const KnowledgeUpdateSettings &settings=KnowledgeUpdateSettings())
 Atomically sets the value of a variable to a JPEG image. More...
 
void set_log_level (int level)
 Sets the log level. More...
 
uint32_t set_quality (const std::string &key, uint32_t quality, bool force_update, const KnowledgeReferenceSettings &settings)
 Atomically sets quality of this process for a variable. More...
 
int set_text (const std::string &key, const char *value, size_t size, const KnowledgeUpdateSettings &settings=KnowledgeUpdateSettings())
 Atomically sets the value of a variable to an XML string. More...
 
int set_text (const VariableReference &variable, const char *value, size_t size, const KnowledgeUpdateSettings &settings=KnowledgeUpdateSettings())
 Atomically sets the value of a variable to a text file's contents. More...
 
template<typename T >
int set_unsafe (const VariableReference &variable, const T *array, size_t size, const KnowledgeUpdateSettings &settings=KnowledgeUpdateSettings())
 NON-Atomically sets the value of a variable to the specific array. More...
 
template<typename T >
int set_unsafe (const VariableReference &variable, T &&value, const KnowledgeUpdateSettings &settings=KnowledgeUpdateSettings())
 NON-Atomically sets the value of a variable to the specific value. More...
 
void set_write_quality (const std::string &key, uint32_t quality, const KnowledgeReferenceSettings &settings)
 Atomically sets write quality of this process for a variable. More...
 
int set_xml (const std::string &key, const char *value, size_t size, const KnowledgeUpdateSettings &settings=KnowledgeUpdateSettings())
 Atomically sets the value of a variable to an XML string. More...
 
int set_xml (const VariableReference &variable, const char *value, size_t size, const KnowledgeUpdateSettings &settings=KnowledgeUpdateSettings())
 Atomically sets the value of a variable to an XML string. More...
 
std::shared_ptr< const std::vector< unsigned char > > share_binary (const std::string &key, const KnowledgeReferenceSettings &settings=KnowledgeReferenceSettings()) const
 
std::shared_ptr< const std::vector< unsigned char > > share_binary (const VariableReference &key, const KnowledgeReferenceSettings &settings=KnowledgeReferenceSettings()) const
 
std::shared_ptr< const std::vector< double > > share_doubles (const std::string &key, const KnowledgeReferenceSettings &settings=KnowledgeReferenceSettings()) const
 
std::shared_ptr< const std::vector< double > > share_doubles (const VariableReference &key, const KnowledgeReferenceSettings &settings=KnowledgeReferenceSettings()) const
 
std::shared_ptr< const std::vector< KnowledgeRecord::Integer > > share_integers (const std::string &key, const KnowledgeReferenceSettings &settings=KnowledgeReferenceSettings()) const
 
std::shared_ptr< const std::vector< KnowledgeRecord::Integer > > share_integers (const VariableReference &key, const KnowledgeReferenceSettings &settings=KnowledgeReferenceSettings()) const
 
std::shared_ptr< const std::string > share_string (const std::string &key, const KnowledgeReferenceSettings &settings=KnowledgeReferenceSettings()) const
 
std::shared_ptr< const std::string > share_string (const VariableReference &key, const KnowledgeReferenceSettings &settings=KnowledgeReferenceSettings()) const
 
void signal (bool lock=true) const
 Signals that this thread is done with the context. More...
 
knowledge::KnowledgeMap to_map (const std::string &prefix) const
 Creates a map with Knowledge Records that begin with the given prefix. More...
 
size_t to_map (const std::string &prefix, const std::string &delimiter, const std::string &suffix, std::vector< std::string > &next_keys, std::map< std::string, knowledge::KnowledgeRecord > &result, bool just_keys)
 Fills a variable map with list of keys according to a matching prefix, suffix, and delimiter hierarchy. More...
 
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. More...
 
knowledge::KnowledgeMap to_map_stripped (const std::string &prefix) const
 Creates a map with Knowledge Records that begin with the given prefix. More...
 
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 function. More...
 
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 integer values. More...
 
bool try_lock (void) const
 Locks the mutex on this context. More...
 
void unlock (void) const
 Unlocks the mutex on this context. More...
 
int update_record_from_external (const std::string &key, const knowledge::KnowledgeRecord &rhs, const KnowledgeUpdateSettings &settings=KnowledgeUpdateSettings(true))
 Atomically sets if the variable value meets update conditions. More...
 
int update_record_from_external (const VariableReference &target, const knowledge::KnowledgeRecord &new_value, const KnowledgeUpdateSettings &settings=KnowledgeUpdateSettings(true))
 Atomically sets if the variable value meets update conditions. More...
 
void wait_for_change (bool extra_release=false)
 Wait for a change to happen to the context. More...
 

Private Types

template<typename T >
using ConstMethodType = std::shared_ptr< T >(KnowledgeRecord::*)(void) const
 
template<typename T >
using MethodType = std::shared_ptr< T >(KnowledgeRecord::*)(void)
 

Private Member Functions

std::pair< KnowledgeMap::iterator, KnowledgeMap::iterator > get_prefix_range (const std::string &prefix)
 
std::pair< KnowledgeMap::const_iterator, KnowledgeMap::const_iterator > get_prefix_range (const std::string &prefix) const
 
template<typename T , MethodType< T > Get, typename K >
std::shared_ptr< T > get_shared (K &&key, const KnowledgeReferenceSettings &settings)
 
template<typename T , ConstMethodType< T > Get, typename K >
std::shared_ptr< T > get_shared (K &&key, const KnowledgeReferenceSettings &settings) const
 
void mark_and_signal (VariableReference ref, const KnowledgeUpdateSettings &settings=KnowledgeUpdateSettings())
 method for marking a record modified and signaling changes More...
 
void mark_to_checkpoint_unsafe (VariableReference ref, const KnowledgeUpdateSettings &settings=KnowledgeUpdateSettings())
 Changes variable to modified at current clock for the purposes of checkpointing. More...
 
void mark_to_send_unsafe (VariableReference ref, const KnowledgeUpdateSettings &settings=KnowledgeUpdateSettings())
 Changes variable to modified at current clock, and queues it to send, even if it is a local that would not ordinarily be sent. More...
 
template<typename T >
int set_index_unsafe_impl (const VariableReference &variable, size_t index, T &&value, const KnowledgeUpdateSettings &settings=KnowledgeUpdateSettings())
 
template<typename... Args>
int set_unsafe_impl (const VariableReference &variable, const KnowledgeUpdateSettings &settings, Args &&... args)
 
madara::knowledge::KnowledgeRecordwith (const std::string &key, const KnowledgeReferenceSettings &settings=KnowledgeReferenceSettings())
 Atomically returns a reference to the variable. More...
 
const madara::knowledge::KnowledgeRecordwith (const std::string &key, const KnowledgeReferenceSettings &settings=KnowledgeReferenceSettings()) const
 Atomically returns a reference to the variable. More...
 
madara::knowledge::KnowledgeRecordwith (const VariableReference &variable, const KnowledgeReferenceSettings &settings=KnowledgeReferenceSettings())
 Atomically returns the value of a variable. More...
 
const madara::knowledge::KnowledgeRecordwith (const VariableReference &variable, const KnowledgeReferenceSettings &settings=KnowledgeReferenceSettings()) const
 Atomically returns the value of a variable. More...
 

Private Attributes

MADARA_CONDITION_TYPE changed_
 
VariableReferenceMap changed_map_
 
uint64_t clock_
 
std::vector< std::string > expansion_splitters_
 
FunctionMap functions_
 map of function names to functions More...
 
madara::expression::Interpreterinterpreter_
 KaRL interpreter. More...
 
VariableReferenceMap local_changed_map_
 
logger::Loggerlogger_
 Logger for printing. More...
 
madara::knowledge::KnowledgeMap map_
 Hash table containing variable names and values. More...
 
MADARA_LOCK_TYPE mutex_
 
std::unique_ptr< BaseStreamerstreamer_ = nullptr
 Streaming provider for saving all updates. More...
 

Friends

class expression::CompositeArrayReference
 
class expression::VariableNode
 
class KnowledgeBaseImpl
 

Detailed Description

This class stores variables and their values for use by any entity needing state information in a thread safe way.

Definition at line 75 of file ThreadSafeContext.h.

Member Typedef Documentation

◆ ConstMethodType

template<typename T >
using madara::knowledge::ThreadSafeContext::ConstMethodType = std::shared_ptr<T> (KnowledgeRecord::*)(void) const
private

Definition at line 198 of file ThreadSafeContext.h.

◆ MethodType

template<typename T >
using madara::knowledge::ThreadSafeContext::MethodType = std::shared_ptr<T> (KnowledgeRecord::*)(void)
private

Definition at line 183 of file ThreadSafeContext.h.

Constructor & Destructor Documentation

◆ ThreadSafeContext()

madara::knowledge::ThreadSafeContext::ThreadSafeContext ( )

Constructor.

Definition at line 31 of file ThreadSafeContext.cpp.

◆ ~ThreadSafeContext()

madara::knowledge::ThreadSafeContext::~ThreadSafeContext ( void  )

Destructor.

Definition at line 49 of file ThreadSafeContext.cpp.

Member Function Documentation

◆ add_logger()

void madara::knowledge::ThreadSafeContext::add_logger ( const std::string &  filename)
inline

Adds a file to the logger.

Parameters
filenamethe file to add to logger

Definition at line 1220 of file ThreadSafeContext.inl.

◆ add_modifieds()

void madara::knowledge::ThreadSafeContext::add_modifieds ( const VariableReferences modifieds) const
inline

Adds a list of VariableReferences to the current modified list.

Parameters
modifiedsa list of variables to add to modified list

Definition at line 1132 of file ThreadSafeContext.inl.

◆ apply_modified()

void madara::knowledge::ThreadSafeContext::apply_modified ( void  )
inline

Changes all global variables to modified at current clock.

Changes all global variables to modified at current time.

Definition at line 1161 of file ThreadSafeContext.inl.

◆ attach_logger()

void madara::knowledge::ThreadSafeContext::attach_logger ( logger::Logger logger) const
inline

Attaches a logger to be used for printing.

Parameters
loggerthe logger the context should lose

Definition at line 770 of file ThreadSafeContext.inl.

◆ attach_streamer()

std::unique_ptr<BaseStreamer> madara::knowledge::ThreadSafeContext::attach_streamer ( std::unique_ptr< BaseStreamer streamer)
inline

Attach a streaming provider object, inherited from BaseStreamer, such as CheckpointStreamer.

Once attached, all updates to records in this ThreadSafeContext will be provided to the streamer. May pass nullptr to stop streaming.

Parameters
streamerthe new streamer to attach
Returns
the old streamer, or nullptr if there wasn't any.

Definition at line 1537 of file ThreadSafeContext.h.

◆ cinvoke() [1/2]

template<typename Callable >
auto madara::knowledge::ThreadSafeContext::cinvoke ( const std::string &  key,
Callable &&  callable,
const KnowledgeReferenceSettings settings = KnowledgeReferenceSettings() 
) const -> decltype(utility::invoke_( std::forward<Callable>(callable), std::declval<KnowledgeRecord&>()))
inline

Definition at line 1632 of file ThreadSafeContext.h.

◆ cinvoke() [2/2]

template<typename Callable >
auto madara::knowledge::ThreadSafeContext::cinvoke ( const VariableReference key,
Callable &&  callable,
const KnowledgeReferenceSettings settings = KnowledgeReferenceSettings() 
) const -> decltype(utility::invoke_( std::forward<Callable>(callable), std::declval<KnowledgeRecord&>()))
inline

Definition at line 1641 of file ThreadSafeContext.h.

◆ clear() [1/3]

void madara::knowledge::ThreadSafeContext::clear ( bool  erase = false)
inline

Clears the context.

Parameters
eraseIf true, completely erase keys. If false, reset knowledge

Definition at line 838 of file ThreadSafeContext.inl.

◆ clear() [2/3]

bool madara::knowledge::ThreadSafeContext::clear ( const std::string &  key,
const KnowledgeReferenceSettings settings = KnowledgeReferenceSettings() 
)
inline

Clears a variable.

This is much safer than

See also
delete_variable. It clears the memory used in the variable and marks it as UNCREATED, meaning that it is effectively deleted, will not show up in
print statements or
save_checkpoint.
Parameters
keyunique identifier of the variable
settingssettings for referring to variables
Returns
true if variable exists

Definition at line 506 of file ThreadSafeContext.inl.

◆ clear() [3/3]

bool madara::knowledge::ThreadSafeContext::clear ( const VariableReference variable)
inline

Clears a variable.

This is much safer than

See also
delete_variable. It clears the memory used in the variable and marks it as UNCREATED, meaning that it is effectively deleted, will not show up in
print statements or
save_checkpoint.
Parameters
variablereference to a variable (
See also
get_ref)

Definition at line 535 of file ThreadSafeContext.inl.

◆ compile()

CompiledExpression madara::knowledge::ThreadSafeContext::compile ( const std::string &  expression)

Compiles a KaRL expression into an expression tree.

Parameters
expressionexpression to compile
Returns
compiled, optimized expression tree
Exceptions
exceptions::KarlExceptionfailure during compile/evaluate

Definition at line 1057 of file ThreadSafeContext.cpp.

◆ copy() [1/2]

void madara::knowledge::ThreadSafeContext::copy ( const ThreadSafeContext source,
const CopySet copy_set = CopySet(),
bool  clean_copy = false,
const KnowledgeUpdateSettings settings = KnowledgeUpdateSettings() 
)

Copies variables and values from source to this context.

PERFORMANCE NOTES: worst case depends on size of copy_set. If empty, performance is always O (n), where n is number of variables in the source context. If copy_set is not empty, then performance is O (m log n) where m is the number of variables in copy_set and n is number of variables in the source context.
 
Note that this is a deep copy due to the fact that source and destination are expected to have their own thread management (ref-counted variables can be problematic if shallow copy).

Parameters
sourcethe source context to copy from
copy_seta map of variables that should be copied. If empty, then everything is copied. If not empty, only the supplied variables will be copied.
clean_copyif true, clear the destination context (this) before copying.
settingssettings for appplying updates to context

Definition at line 1556 of file ThreadSafeContext.cpp.

◆ copy() [2/2]

void madara::knowledge::ThreadSafeContext::copy ( const ThreadSafeContext source,
const KnowledgeRequirements reqs,
const KnowledgeUpdateSettings settings 
)

Copies variables and values from source to this context.

PERFORMANCE NOTES: predicates with prefixes can limit copying to O(log n). predices with suffixes and no prefix force O(n) copy cost since all records could fit requirements

Parameters
sourcethe source context to copy from
reqsrequirements that must be met
settingssettings for appplying updates to context

Definition at line 1434 of file ThreadSafeContext.cpp.

◆ debug_modifieds()

std::string madara::knowledge::ThreadSafeContext::debug_modifieds ( void  ) const
inline

Retrieves a stringified list of all modified variables that are ready to send over transport on next send_modifieds call.

Returns
stringified list of the modified knowledge records

Definition at line 991 of file ThreadSafeContext.inl.

◆ dec() [1/2]

KnowledgeRecord madara::knowledge::ThreadSafeContext::dec ( const std::string &  key,
const KnowledgeUpdateSettings settings = KnowledgeUpdateSettings() 
)
inline

Atomically decrements the value of the variable.

Parameters
keyunique identifier of the variable
settingssettings for applying the update
Returns
new value of variable

Definition at line 464 of file ThreadSafeContext.inl.

◆ dec() [2/2]

KnowledgeRecord madara::knowledge::ThreadSafeContext::dec ( const VariableReference variable,
const KnowledgeUpdateSettings settings = KnowledgeUpdateSettings() 
)
inline

Atomically decrements the value of the variable.

Parameters
variablereference to a variable (
See also
get_ref)
Parameters
settingssettings for applying the update
Returns
new value of variable

Definition at line 645 of file ThreadSafeContext.inl.

◆ define_function() [1/6]

void madara::knowledge::ThreadSafeContext::define_function ( const std::string &  name,
boost::python::object  callable,
const KnowledgeReferenceSettings settings = KnowledgeReferenceSettings() 
)

Defines a named python function.

Parameters
namename of the function
callableexternal python function to call with this name
settingssettings for referring to variables

Definition at line 976 of file ThreadSafeContext.cpp.

◆ define_function() [2/6]

void madara::knowledge::ThreadSafeContext::define_function ( const std::string &  name,
const CompiledExpression expression,
const KnowledgeReferenceSettings settings = KnowledgeReferenceSettings() 
)

Defines a MADARA KaRL function.

Parameters
namename of the function
expressionKaRL function body
settingssettings for referring to variables

Definition at line 1008 of file ThreadSafeContext.cpp.

◆ define_function() [3/6]

void madara::knowledge::ThreadSafeContext::define_function ( const std::string &  name,
const std::string &  expression,
const KnowledgeReferenceSettings settings = KnowledgeReferenceSettings() 
)

Defines a MADARA KaRL function.

Parameters
namename of the function
expressionKaRL function body
settingssettings for referring to variables

Definition at line 1001 of file ThreadSafeContext.cpp.

◆ define_function() [4/6]

void madara::knowledge::ThreadSafeContext::define_function ( const std::string &  name,
jobject  callable,
const KnowledgeReferenceSettings settings = KnowledgeReferenceSettings() 
)

Defines a named java function.

Parameters
namename of the function
callableexternal java object to call with this name
settingssettings for referring to variables

Definition at line 951 of file ThreadSafeContext.cpp.

◆ define_function() [5/6]

void madara::knowledge::ThreadSafeContext::define_function ( const std::string &  name,
knowledge::KnowledgeRecord(*)(const char *, FunctionArguments &, Variables &)  func,
const KnowledgeReferenceSettings settings = KnowledgeReferenceSettings() 
)

Defines a named function that can distinguish the name it was called with in MADARA.

Parameters
namename of the function
funcexternal function to call with this name
settingssettings for referring to variables

◆ define_function() [6/6]

void madara::knowledge::ThreadSafeContext::define_function ( const std::string &  name,
knowledge::KnowledgeRecord(*)(FunctionArguments &, Variables &)  func,
const KnowledgeReferenceSettings settings = KnowledgeReferenceSettings() 
)

Defines an external function.

Parameters
namename of the function
funcexternal function to call with this name
settingssettings for referring to variables

Definition at line 901 of file ThreadSafeContext.cpp.

◆ delete_expression()

bool madara::knowledge::ThreadSafeContext::delete_expression ( const std::string &  expression)
inline

Deletes the expression from the interpreter cache.

Parameters
expressionthe KaRL logic in the interpreter context
Returns
true if variable exists

Definition at line 497 of file ThreadSafeContext.inl.

◆ delete_prefix()

void madara::knowledge::ThreadSafeContext::delete_prefix ( const std::string &  prefix,
const KnowledgeReferenceSettings settings = KnowledgeReferenceSettings() 
)

Deletes keys starting with the given prefix.

Parameters
prefixstring which starts all variables to delete
settingssettings for referring to variables

Definition at line 1300 of file ThreadSafeContext.cpp.

◆ delete_variable() [1/2]

bool madara::knowledge::ThreadSafeContext::delete_variable ( const std::string &  key,
const KnowledgeReferenceSettings settings = KnowledgeReferenceSettings() 
)
inline

Deletes the key.

Note that this is extremely unsafe. You can cause illegal operations in the knowledge base by using this method and trying to access this variable again with 1) a VariableReference, 2) a

See also
saved_modifieds listing, 3) a compiled expression in KaRL that uses the variable. There are very, very few reasons to ever use this function. Actually, there is one: you will never, ever, ever use this variable again. That's it. Otherwise, use
clear with the default argument
Parameters
keyunique identifier of the variable
settingssettings for referring to variables
Returns
true if variable exists

Definition at line 556 of file ThreadSafeContext.inl.

◆ delete_variable() [2/2]

bool madara::knowledge::ThreadSafeContext::delete_variable ( const VariableReference var,
const KnowledgeReferenceSettings settings = KnowledgeReferenceSettings() 
)
inline

Deletes the variable.

Note that this is extremely unsafe. You can cause illegal operations in the knowledge base by using this method and trying to access this variable again with 1) a VariableReference, 2) a

See also
saved_modifieds listing, 3) a compiled expression in KaRL that uses the variable. There are very, very few reasons to ever use this function. Actually, there is one: you will never, ever, ever use this variable again. That's it. Otherwise, use
clear with the default argument
Parameters
varVariableReference to variable. Do not use object this after calling this method!
settingssettings for referring to variables
Returns
true if variable exists

Definition at line 585 of file ThreadSafeContext.inl.

◆ delete_variables()

void madara::knowledge::ThreadSafeContext::delete_variables ( KnowledgeMap::iterator  begin,
KnowledgeMap::iterator  end,
const KnowledgeReferenceSettings settings = KnowledgeReferenceSettings() 
)
inline

Deletes variables.

Note that this is extremely unsafe. You can cause illegal operations in the knowledge base by using this method and trying to access this variable again with 1) a VariableReference, 2) a

See also
saved_modifieds listing, 3) a compiled expression in KaRL that uses the variable. There are very, very few reasons to ever use this function. Actually, there is one: you will never, ever, ever use this variable again. That's it. Otherwise, use
clear with the default argument
Parameters
beginiterator to variables inside the map
enditerator to variables inside the map
settingssettings for referring to variables
Returns
true if variable exists

Definition at line 599 of file ThreadSafeContext.inl.

◆ evaluate() [1/2]

KnowledgeRecord madara::knowledge::ThreadSafeContext::evaluate ( CompiledExpression  expression,
const KnowledgeUpdateSettings settings = KnowledgeUpdateSettings() 
)

Evaluate a compiled expression.

Please note that if you update any variables here, they will not be sent through any transports until you call through the KnowledgeBase.

Parameters
expressionA compiled expressio to run.
settingssettings for applying the update
Returns
result of the evaluation
Exceptions
exceptions::KarlExceptionfailure during compile/evaluate

Definition at line 1072 of file ThreadSafeContext.cpp.

◆ evaluate() [2/2]

KnowledgeRecord madara::knowledge::ThreadSafeContext::evaluate ( expression::ComponentNode root,
const KnowledgeUpdateSettings settings = KnowledgeUpdateSettings() 
)

Evaluate a component node-rooted tree.

Please note that if you update any variables here, they will not be sent through any transports until you call through the KnowledgeBase.

Parameters
rootRoot of an expression tree
settingssettings for applying the update
Returns
result of the evaluation
Exceptions
exceptions::KarlExceptionfailure during compile/evaluate

Definition at line 1079 of file ThreadSafeContext.cpp.

◆ evaluate_file()

madara::knowledge::KnowledgeRecord madara::knowledge::ThreadSafeContext::evaluate_file ( CheckpointSettings checkpoint_settings,
const KnowledgeUpdateSettings update_settings = KnowledgeUpdateSettings(          true, true, true, false) 
)

Loads and evaluates a karl script from a file.

Parameters
checkpoint_settingscheckpoint settings to load
update_settingssettings for applying the updates
Returns
result of evaluation
Exceptions
exceptions::MemoryExceptionnot enough buffer to encode

Definition at line 2174 of file ThreadSafeContext.cpp.

◆ exists() [1/2]

bool madara::knowledge::ThreadSafeContext::exists ( const std::string &  key,
const KnowledgeReferenceSettings settings = KnowledgeReferenceSettings() 
) const
inline

Atomically checks to see if a variable already exists.

Parameters
keyunique identifier of the variable
settingssettings for referring to variables
Returns
true if variable exists

Definition at line 611 of file ThreadSafeContext.inl.

◆ exists() [2/2]

bool madara::knowledge::ThreadSafeContext::exists ( const VariableReference variable,
const KnowledgeReferenceSettings settings = KnowledgeReferenceSettings(          false) 
) const
inline

Checks if a knowledge variable exists in the context.

Parameters
variableknowledge variable reference
settingssettings for referring to knowledge variables
Returns
true if location has been set

Definition at line 237 of file ThreadSafeContext.inl.

◆ expand_statement()

std::string madara::knowledge::ThreadSafeContext::expand_statement ( const std::string &  statement) const

Expands a string with variable expansion.

Expand a string with variable expansions.

For instance, if .id == 5, and a statement of "MyVar{.id} = {.id} * 30" then then expanded statement would be "MyVar5 = 5 * 30".

Parameters
statementstatement to expand. Useful for printing.
Returns
variable expanded statement

This is a generic form of the function found in VariableNode, which is optimized to never change keys.

Definition at line 844 of file ThreadSafeContext.cpp.

◆ file_to_string()

std::string madara::knowledge::ThreadSafeContext::file_to_string ( CheckpointSettings checkpoint_settings)

Loads and returns a karl script from a file with encode/decode.

Parameters
checkpoint_settingscheckpoint settings to load
Exceptions
exceptions::MemoryExceptionnot enough buffer to encode

Definition at line 2194 of file ThreadSafeContext.cpp.

◆ for_each()

template<typename Func >
void madara::knowledge::ThreadSafeContext::for_each ( Func &&  func) const
inline

Call given Callable on each element in this context.

Note that the context will be locked for the entire duration of this iteration. The Callable must accept one argument, a const std::pair<const std::string, KnowledgeRecord>&, and it's return value is ignored.

Template Parameters
Funca callable type as described above
Parameters
functhe callable object; either function pointer or functor

Definition at line 1659 of file ThreadSafeContext.h.

◆ get() [1/2]

KnowledgeRecord madara::knowledge::ThreadSafeContext::get ( const std::string &  key,
const KnowledgeReferenceSettings settings = KnowledgeReferenceSettings() 
) const
inline

Atomically returns the current value of a variable.

Parameters
keyunique identifier of the variable
settingsthe settings for referring to variables
Returns
the madara::knowledge::KnowledgeRecord::Integer value for the variable

Definition at line 27 of file ThreadSafeContext.inl.

◆ get() [2/2]

KnowledgeRecord madara::knowledge::ThreadSafeContext::get ( const VariableReference variable,
const KnowledgeReferenceSettings settings = KnowledgeReferenceSettings() 
) const
inline

Atomically returns the current value of a variable.

Parameters
variablereference to a variable (
See also
get_ref)
Parameters
settingsthe settings for referring to variables
Returns
the madara::knowledge::KnowledgeRecord::Integer value for the variable

Definition at line 63 of file ThreadSafeContext.inl.

◆ get_actual() [1/2]

KnowledgeRecord madara::knowledge::ThreadSafeContext::get_actual ( const std::string &  key,
const KnowledgeReferenceSettings settings = KnowledgeReferenceSettings() 
) const
inline

Atomically returns the underlying value of a variable, including history.

If record has no history, equivalent to get.

Parameters
keyunique identifier of the variable
settingsthe settings for referring to variables
Returns
the madara::knowledge::KnowledgeRecord::Integer value for the variable

Definition at line 99 of file ThreadSafeContext.inl.

◆ get_actual() [2/2]

KnowledgeRecord madara::knowledge::ThreadSafeContext::get_actual ( const VariableReference variable,
const KnowledgeReferenceSettings settings = KnowledgeReferenceSettings() 
) const
inline

Atomically returns the underlying value of a variable, including history.

If record has no history, equivalent to get.

Parameters
variablereference to a variable (
See also
get_ref)
Parameters
settingsthe settings for referring to variables
Returns
the madara::knowledge::KnowledgeRecord::Integer value for the variable

Definition at line 118 of file ThreadSafeContext.inl.

◆ get_clock() [1/2]

uint64_t madara::knowledge::ThreadSafeContext::get_clock ( const std::string &  key,
const KnowledgeReferenceSettings settings = KnowledgeReferenceSettings() 
) const
inline

Atomically gets the Lamport clock of a variable.

get the lamport clock for a particular variable

Parameters
keyunique identifier of the variable
settingssettings for reading the variable
Returns
current variable clock

Definition at line 777 of file ThreadSafeContext.inl.

◆ get_clock() [2/2]

uint64_t madara::knowledge::ThreadSafeContext::get_clock ( void  ) const
inline

Atomically gets the Lamport clock.

get the lamport clock (updates with lamport clocks lower than our current clock get discarded)

Returns
current global clock

Definition at line 758 of file ThreadSafeContext.inl.

◆ get_local_modified()

const VariableReferenceMap & madara::knowledge::ThreadSafeContext::get_local_modified ( void  ) const
inline

Retrieves a list of modified local variables.

Return list of variables that have been modified.

Useful for building a comprehensive checkpoint.

Returns
the modified knowledge records

Definition at line 1144 of file ThreadSafeContext.inl.

◆ get_log_level()

int madara::knowledge::ThreadSafeContext::get_log_level ( void  )
inline

Gets the log level.

Returns
the maximum detail level to print

Definition at line 1225 of file ThreadSafeContext.inl.

◆ get_logger()

madara::logger::Logger & madara::knowledge::ThreadSafeContext::get_logger ( void  ) const
inline

Gets the logger used for information printing.

Returns
the context's logger

Definition at line 764 of file ThreadSafeContext.inl.

◆ get_map_unsafe() [1/2]

KnowledgeMap& madara::knowledge::ThreadSafeContext::get_map_unsafe ( void  )
inline

NOT THREAD SAFE!

Retrieves a reference to the underlying KnowledgeMap. This is not thread-safe. Only call this if you already hold this Context's lock. Reading the map is then generally safe, but writting to it will bypass important mechanisms such as modification tracking. Make sure you know what you're doing, and consider whether other methods fit your needs.

Returns
a reference to this context's KnowledgeMap

Definition at line 1559 of file ThreadSafeContext.h.

◆ get_map_unsafe() [2/2]

const KnowledgeMap& madara::knowledge::ThreadSafeContext::get_map_unsafe ( void  ) const
inline

NOT THREAD SAFE!

Retrieves a reference to the underlying KnowledgeMap. This is not thread-safe. Only call this if you already hold this Context's lock. Reading the map is then generally safe.

Ensure you know what you're doing, and consider whether other methods fit your needs.

Returns
a reference to this context's KnowledgeMap

Definition at line 1576 of file ThreadSafeContext.h.

◆ get_matches()

void madara::knowledge::ThreadSafeContext::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.

Parameters
prefixstring that the key must start with
suffixstring that the key must end with
matchesall VariableReferences matching the prefix and suffix

Definition at line 1162 of file ThreadSafeContext.cpp.

◆ get_modifieds()

const VariableReferenceMap & madara::knowledge::ThreadSafeContext::get_modifieds ( void  ) const
inline

Retrieves a list of modified variables.

Return list of variables that have been modified.

Useful for building a disseminatable knowledge update.

Returns
the modified knowledge records

Definition at line 1037 of file ThreadSafeContext.inl.

◆ get_modifieds_current()

KnowledgeMap madara::knowledge::ThreadSafeContext::get_modifieds_current ( const std::map< std::string, bool > &  send_list,
bool  reset = true 
)
inline

Retrieves the current modifieds map.

Parameters
send_listmap of variables that limit what will be sent
resetreset modifieds atomically
Returns
the modified knowledge records

Definition at line 1044 of file ThreadSafeContext.inl.

◆ get_prefix_range() [1/2]

std::pair< KnowledgeMap::iterator, KnowledgeMap::iterator > madara::knowledge::ThreadSafeContext::get_prefix_range ( const std::string &  prefix)
private

Definition at line 1361 of file ThreadSafeContext.cpp.

◆ get_prefix_range() [2/2]

std::pair< KnowledgeMap::const_iterator, KnowledgeMap::const_iterator > madara::knowledge::ThreadSafeContext::get_prefix_range ( const std::string &  prefix) const
private

Definition at line 1383 of file ThreadSafeContext.cpp.

◆ get_quality()

uint32_t madara::knowledge::ThreadSafeContext::get_quality ( const std::string &  key,
const KnowledgeReferenceSettings settings = KnowledgeReferenceSettings() 
)

Atomically gets quality of a variable.

get quality of last update to a variable.

Parameters
keyunique identifier of the
settingssettings for referring to a knowledge variable
Returns
quality associated with the variable
quality of the variable

Definition at line 275 of file ThreadSafeContext.cpp.

◆ get_record()

KnowledgeRecord * madara::knowledge::ThreadSafeContext::get_record ( const std::string &  key,
const KnowledgeReferenceSettings settings = KnowledgeReferenceSettings() 
)

Retrieves a knowledge record from the key.

This function is useful for performance reasons and also for using a knowledge::KnowledgeRecord that can be one of multiple types

Parameters
keyunique identifier of the variable. Allows variable expansion.
settingsthe settings for referring to variables
Returns
the knowledge record for the variable

This function is useful for performance reasons and also for using a knowledge::KnowledgeRecord that can be one of multiple types

Definition at line 61 of file ThreadSafeContext.cpp.

◆ get_ref() [1/2]

VariableReference madara::knowledge::ThreadSafeContext::get_ref ( const std::string &  key,
const KnowledgeReferenceSettings settings = KnowledgeReferenceSettings() 
)

Atomically returns a reference to the variable.

Variable references are efficient mechanisms for reference variables individually–similar to speedups seen from CompiledExpression.

Parameters
keyunique identifier of the variable
settingssettings for referring to knowledge variables
Returns
reference to the variable in the context

Definition at line 84 of file ThreadSafeContext.cpp.

◆ get_ref() [2/2]

VariableReference madara::knowledge::ThreadSafeContext::get_ref ( const std::string &  key,
const KnowledgeReferenceSettings settings = KnowledgeReferenceSettings() 
) const

Atomically returns a reference to the variable.

Parameters
keyunique identifier of the variable
settingssettings for referring to knowledge variables
Returns
reference to the variable in the context. If variable doesn't exist, then a null reference is returned.

Definition at line 115 of file ThreadSafeContext.cpp.

◆ get_shared() [1/2]

template<typename T , MethodType< T > Get, typename K >
std::shared_ptr<T> madara::knowledge::ThreadSafeContext::get_shared ( K &&  key,
const KnowledgeReferenceSettings settings 
)
inlineprivate

Definition at line 186 of file ThreadSafeContext.h.

◆ get_shared() [2/2]

template<typename T , ConstMethodType< T > Get, typename K >
std::shared_ptr<T> madara::knowledge::ThreadSafeContext::get_shared ( K &&  key,
const KnowledgeReferenceSettings settings 
) const
inlineprivate

Definition at line 201 of file ThreadSafeContext.h.

◆ get_write_quality()

uint32_t madara::knowledge::ThreadSafeContext::get_write_quality ( const std::string &  key,
const KnowledgeReferenceSettings settings = KnowledgeReferenceSettings() 
)

Atomically gets write quality of this process for a variable.

get quality of last update to a variable.

Parameters
keyunique identifier of the variable
settingssettings for referring to a knowledge variable
Returns
write quality associated with the variable
quality of the variable

Definition at line 306 of file ThreadSafeContext.cpp.

◆ inc() [1/2]

KnowledgeRecord madara::knowledge::ThreadSafeContext::inc ( const std::string &  key,
const KnowledgeUpdateSettings settings = KnowledgeUpdateSettings() 
)
inline

Atomically increments the value of the variable.

Parameters
keyunique identifier of the variable
settingssettings for applying the update
Returns
new value of variable

Definition at line 457 of file ThreadSafeContext.inl.

◆ inc() [2/2]

KnowledgeRecord madara::knowledge::ThreadSafeContext::inc ( const VariableReference variable,
const KnowledgeUpdateSettings settings = KnowledgeUpdateSettings() 
)
inline

Atomically increments the value of the variable.

Parameters
variablereference to a variable (
See also
get_ref)
Parameters
settingssettings for applying the update
Returns
new value of variable

Definition at line 471 of file ThreadSafeContext.inl.

◆ inc_clock() [1/2]

uint64_t madara::knowledge::ThreadSafeContext::inc_clock ( const KnowledgeUpdateSettings settings = KnowledgeUpdateSettings())
inline

Atomically increments the Lamport clock and returns the new clock time (intended for sending knowledge updates).

increment the process lamport clock

Parameters
settingssettings for applying the update
Returns
new clock time

Definition at line 749 of file ThreadSafeContext.inl.

◆ inc_clock() [2/2]

uint64_t madara::knowledge::ThreadSafeContext::inc_clock ( const std::string &  key,
const KnowledgeUpdateSettings settings = KnowledgeUpdateSettings() 
)
inline

Atomically increments the Lamport clock of a variable and returns the new clock time (intended for sending knowledge updates).

set the lamport clock for a particular variable (updates with lamport clocks lower than our current clock get discarded)

Parameters
keyunique identifier of the variable
settingssettings for applying the update
Returns
new clock time for variable

Definition at line 722 of file ThreadSafeContext.inl.

◆ invoke() [1/4]

template<typename Callable >
auto madara::knowledge::ThreadSafeContext::invoke ( const std::string &  key,
Callable &&  callable,
const KnowledgeReferenceSettings settings = KnowledgeReferenceSettings() 
) const -> decltype(utility::invoke_( std::forward<Callable>(callable), std::declval<KnowledgeRecord&>()))
inline

Definition at line 1604 of file ThreadSafeContext.h.

◆ invoke() [2/4]

template<typename Callable >
auto madara::knowledge::ThreadSafeContext::invoke ( const std::string &  key,
Callable &&  callable,
const KnowledgeUpdateSettings settings = KnowledgeUpdateSettings() 
) -> decltype(utility::invoke_( std::forward<Callable>(callable), std::declval<KnowledgeRecord&>()))
inline

Definition at line 1582 of file ThreadSafeContext.h.

◆ invoke() [3/4]

template<typename Callable >
auto madara::knowledge::ThreadSafeContext::invoke ( const VariableReference key,
Callable &&  callable,
const KnowledgeReferenceSettings settings = KnowledgeReferenceSettings() 
) const -> decltype(utility::invoke_( std::forward<Callable>(callable), std::declval<KnowledgeRecord&>()))
inline

Definition at line 1620 of file ThreadSafeContext.h.

◆ invoke() [4/4]

template<typename Callable >
auto madara::knowledge::ThreadSafeContext::invoke ( const VariableReference key,
Callable &&  callable,
const KnowledgeUpdateSettings settings = KnowledgeUpdateSettings() 
) -> decltype(utility::invoke_( std::forward<Callable>(callable), std::declval<KnowledgeRecord&>()))
inline

Definition at line 1593 of file ThreadSafeContext.h.

◆ load_context() [1/3]

int64_t madara::knowledge::ThreadSafeContext::load_context ( CheckpointSettings checkpoint_settings,
const KnowledgeUpdateSettings update_settings = KnowledgeUpdateSettings(          true, true, true, false) 
)

Loads the context from a file.

Parameters
checkpoint_settingscheckpoint settings to load
update_settingssettings for applying the updates
Returns
-1 if file open failed
-2 if file read failed
>0 if successful (number of bytes written)
Exceptions
exceptions::MemoryExceptionnot enough buffer to encode

Definition at line 2261 of file ThreadSafeContext.cpp.

◆ load_context() [2/3]

int64_t madara::knowledge::ThreadSafeContext::load_context ( const std::string &  filename,
FileHeader meta,
const KnowledgeUpdateSettings settings = KnowledgeUpdateSettings(          true, true, true, false) 
)

Loads the context from a file.

Parameters
filenamename of the file to open
metaa file header that will contain metadata such as originator, timestamp, lamport clock, etc.
settingssettings for applying the update
Returns
-1 if file open failed
-2 if file read failed
>0 if successful (number of bytes written)
Exceptions
exceptions::MemoryExceptionnot enough buffer to encode

Definition at line 2114 of file ThreadSafeContext.cpp.

◆ load_context() [3/3]

int64_t madara::knowledge::ThreadSafeContext::load_context ( const std::string &  filename,
std::string &  id,
const KnowledgeUpdateSettings settings = KnowledgeUpdateSettings(          true, true, true, false) 
)

Loads the context from a file.

Parameters
filenamename of the file to open
idunique identifier of the context holder (will be changed by the function)
settingssettings for applying the update
Returns
-1 if file open failed
-2 if file read failed
>0 if successful (number of bytes written)

Definition at line 2104 of file ThreadSafeContext.cpp.

◆ lock()

void madara::knowledge::ThreadSafeContext::lock ( void  ) const
inline

Locks the mutex on this context.

Lock the mutex on this context.

Warning: this will cause all operations to block until the unlock call is made.

Use ContextGuard instead of calling this directly.

Warning: this will cause all operations to block until the unlock call is made.

Definition at line 812 of file ThreadSafeContext.inl.

◆ mark_and_signal()

void madara::knowledge::ThreadSafeContext::mark_and_signal ( VariableReference  ref,
const KnowledgeUpdateSettings settings = KnowledgeUpdateSettings() 
)
inlineprivate

method for marking a record modified and signaling changes

Parameters
refa reference to a variable in the knowledge base
settingssettings for applying modification and signalling

Definition at line 937 of file ThreadSafeContext.inl.

◆ mark_modified() [1/2]

void madara::knowledge::ThreadSafeContext::mark_modified ( const std::string &  key,
const KnowledgeUpdateSettings settings = KnowledgeUpdateSettings() 
)
inline

Changes global variables to modified at current clock for the purposes of sending or checkpointing knowledge (globals and locals respectively)

Parameters
keythe key of the record you are changing
settingsthe settings for referring to variables

Definition at line 970 of file ThreadSafeContext.inl.

◆ mark_modified() [2/2]

void madara::knowledge::ThreadSafeContext::mark_modified ( const VariableReference variable,
const KnowledgeUpdateSettings settings = KnowledgeUpdateSettings() 
)
inline

Marks the variable reference as updated for the purposes of sending or checkpointing knowledge (for globals and locals respectively)

Parameters
variablereference to a variable (
See also
get_ref)
Parameters
settingsthe settings for referring to variables

Definition at line 978 of file ThreadSafeContext.inl.

◆ mark_to_checkpoint() [1/2]

void madara::knowledge::ThreadSafeContext::mark_to_checkpoint ( const std::string &  key,
const KnowledgeUpdateSettings settings = KnowledgeUpdateSettings() 
)
inline

Changes variable to modified at current clock for the purposes of checkpointing (even if it is a global).

Parameters
keythe key of the record you are marking
settingsthe settings for referring to variables

Definition at line 909 of file ThreadSafeContext.inl.

◆ mark_to_checkpoint() [2/2]

void madara::knowledge::ThreadSafeContext::mark_to_checkpoint ( const VariableReference variable,
const KnowledgeUpdateSettings settings = KnowledgeUpdateSettings() 
)
inline

Changes variable reference to modified at current clock for the purposes of checkpointing (even if it is a global).

Parameters
variablereference to a variable (
See also
get_ref)
Parameters
settingsthe settings for referring to variables

Definition at line 917 of file ThreadSafeContext.inl.

◆ mark_to_checkpoint_unsafe()

void madara::knowledge::ThreadSafeContext::mark_to_checkpoint_unsafe ( VariableReference  ref,
const KnowledgeUpdateSettings settings = KnowledgeUpdateSettings() 
)
inlineprivate

Changes variable to modified at current clock for the purposes of checkpointing.

Skips all safety checks and variable expansions.

Parameters
refa reference to a variable in the knowledge base
settingsthe settings for referring to variables

Definition at line 927 of file ThreadSafeContext.inl.

◆ mark_to_send() [1/2]

void madara::knowledge::ThreadSafeContext::mark_to_send ( const std::string &  key,
const KnowledgeUpdateSettings settings = KnowledgeUpdateSettings() 
)
inline

Changes variable to modified at current clock, and queues it to send, even if it is a local that would not ordinarily be sent.

Parameters
keythe key of the record you are marking
settingsthe settings for referring to variables

Definition at line 881 of file ThreadSafeContext.inl.

◆ mark_to_send() [2/2]

void madara::knowledge::ThreadSafeContext::mark_to_send ( const VariableReference variable,
const KnowledgeUpdateSettings settings = KnowledgeUpdateSettings() 
)
inline

Changes variable reference to modified at current clock, and queues it to send, even if it is a local that would not ordinarily be sent.

Parameters
variablereference to a variable (
See also
get_ref)
Parameters
settingsthe settings for referring to variables

Definition at line 889 of file ThreadSafeContext.inl.

◆ mark_to_send_unsafe()

void madara::knowledge::ThreadSafeContext::mark_to_send_unsafe ( VariableReference  ref,
const KnowledgeUpdateSettings settings = KnowledgeUpdateSettings() 
)
inlineprivate

Changes variable to modified at current clock, and queues it to send, even if it is a local that would not ordinarily be sent.

Skips all safety checks and variable expansions.

Parameters
refa reference to a variable in the knowledge base
settingsthe settings for referring to variables

Definition at line 899 of file ThreadSafeContext.inl.

◆ print() [1/2]

void madara::knowledge::ThreadSafeContext::print ( const std::string &  statement,
unsigned int  level 
) const
inline

Atomically Print a statement, similar to printf (variable expansions allowed) e.g., input = "MyVar{.id} = {MyVar{.id}}\n";.

Print a statement, similar to printf (variable expressions allowed) e.g.

Parameters
statementtemplated statement to print from
levellog level.
See also
LogMacros.h

input = "MyVar{.id} = {MyVar{.id}}\n";

Definition at line 830 of file ThreadSafeContext.inl.

◆ print() [2/2]

void madara::knowledge::ThreadSafeContext::print ( unsigned int  level) const

Atomically prints all variables and values in the context.

Parameters
levellog level.
See also
LogMacros.h

Definition at line 775 of file ThreadSafeContext.cpp.

◆ read_file() [1/2]

int madara::knowledge::ThreadSafeContext::read_file ( const std::string &  key,
const std::string &  filename,
const KnowledgeUpdateSettings settings = KnowledgeUpdateSettings() 
)
inline

Atomically reads a file into a variable.

Parameters
keyunique identifier of the variable
filenamefile to read
settingssettings for applying the update
Returns
0 if the value was set. -1 if unsuccessful

Definition at line 20 of file ThreadSafeContext.inl.

◆ read_file() [2/2]

int madara::knowledge::ThreadSafeContext::read_file ( const VariableReference variable,
const std::string &  filename,
const KnowledgeUpdateSettings settings = KnowledgeUpdateSettings() 
)

Atomically reads a file into a variable.

Parameters
variablereference to a variable (
See also
get_ref)
Parameters
filenamefile to read
settingssettings for applying the update
Returns
0 if the value was set. -1 if unsuccessful

Definition at line 247 of file ThreadSafeContext.cpp.

◆ reset_checkpoint()

void madara::knowledge::ThreadSafeContext::reset_checkpoint ( void  ) const
inline

Reset all checkpoint variables in the modified lists.

This essentially purges the diff and starts fresh

Definition at line 1201 of file ThreadSafeContext.inl.

◆ reset_modified() [1/2]

void madara::knowledge::ThreadSafeContext::reset_modified ( const std::string &  key)
inline

Resets a variable to unmodified.

Reset a variable to unmodified.

Parameters
keyunique identifier of the variable

Definition at line 1194 of file ThreadSafeContext.inl.

◆ reset_modified() [2/2]

void madara::knowledge::ThreadSafeContext::reset_modified ( void  )
inline

Reset all variables to be unmodified.

Reset all variables to unmodified.

This will clear all global knowledge updates. Use with caution.

Definition at line 1153 of file ThreadSafeContext.inl.

◆ retrieve_function()

Function * madara::knowledge::ThreadSafeContext::retrieve_function ( const std::string &  name,
const KnowledgeReferenceSettings settings = KnowledgeReferenceSettings() 
)

Retrieves an external function.

Parameters
namename of the function to retrieve
settingssettings for referring to variables
Returns
the mapped external function

Definition at line 1034 of file ThreadSafeContext.cpp.

◆ retrieve_index() [1/2]

KnowledgeRecord madara::knowledge::ThreadSafeContext::retrieve_index ( const std::string &  key,
size_t  index,
const KnowledgeReferenceSettings settings = KnowledgeReferenceSettings() 
)
inline

Retrieves a value at a specified index within a knowledge array.

Parameters
keyknowledge location
indexindex within the array
settingssettings for referring to knowledge variables
Returns
value at knowledge location

Definition at line 279 of file ThreadSafeContext.inl.

◆ retrieve_index() [2/2]

KnowledgeRecord madara::knowledge::ThreadSafeContext::retrieve_index ( const VariableReference variable,
size_t  index,
const KnowledgeReferenceSettings settings = KnowledgeReferenceSettings() 
)
inline

Retrieves a value at a specified index within a knowledge array.

Parameters
variablereference to a variable (
See also
get_ref)
Parameters
indexindex within the array
settingssettings for referring to knowledge variables
Returns
value at knowledge location

Definition at line 257 of file ThreadSafeContext.inl.

◆ save_as_json() [1/2]

int64_t madara::knowledge::ThreadSafeContext::save_as_json ( const CheckpointSettings settings) const

Saves the context to a file as JSON.

Parameters
settingsthe settings to save
Returns
total bytes written

Definition at line 1952 of file ThreadSafeContext.cpp.

◆ save_as_json() [2/2]

int64_t madara::knowledge::ThreadSafeContext::save_as_json ( const std::string &  filename) const

Saves the context to a file as JSON.

Parameters
filenamename of the file to save to
Returns
total bytes written

Definition at line 1944 of file ThreadSafeContext.cpp.

◆ save_as_karl() [1/2]

int64_t madara::knowledge::ThreadSafeContext::save_as_karl ( const CheckpointSettings settings) const

Saves the context to a file as karl assignments, rather than binary.

Parameters
settingsthe settings to save
Returns
total bytes written

Definition at line 1780 of file ThreadSafeContext.cpp.

◆ save_as_karl() [2/2]

int64_t madara::knowledge::ThreadSafeContext::save_as_karl ( const std::string &  filename) const

Saves the context to a file as karl assignments, rather than binary.

Parameters
filenamename of the file to save to
Returns
total bytes written

Definition at line 1772 of file ThreadSafeContext.cpp.

◆ save_checkpoint() [1/2]

int64_t madara::knowledge::ThreadSafeContext::save_checkpoint ( const CheckpointSettings settings) const

Saves a checkpoint of a list of changes to a file.

Parameters
settingscheckpoint settings to load
Returns
-1 if file open failed
-2 if file write failed
>0 if successful (number of bytes written)
Exceptions
exceptions::MemoryExceptionnot enough buffer to encode

Definition at line 2755 of file ThreadSafeContext.cpp.

◆ save_checkpoint() [2/2]

int64_t madara::knowledge::ThreadSafeContext::save_checkpoint ( const std::string &  filename,
const std::string &  id = "" 
) const

Saves a checkpoint of a list of changes to a file.

Parameters
filenamename of the file to open
idunique identifier of the context holder
Returns
-1 if file open failed
-2 if file write failed
>0 if successful (number of bytes written)
Exceptions
exceptions::MemoryExceptionnot enough buffer to encode

Definition at line 2808 of file ThreadSafeContext.cpp.

◆ save_context() [1/2]

int64_t madara::knowledge::ThreadSafeContext::save_context ( const CheckpointSettings settings) const

Saves the context to a file.

Parameters
settingsthe settings to save
Returns
-1 if file open failed
-2 if file write failed
>0 if successful (number of bytes written)
Exceptions
exceptions::MemoryExceptionnot enough buffer to encode

Definition at line 1603 of file ThreadSafeContext.cpp.

◆ save_context() [2/2]

int64_t madara::knowledge::ThreadSafeContext::save_context ( const std::string &  filename,
const std::string &  id = "" 
) const

Saves the context to a file.

Parameters
filenamename of the file to open
idunique identifier of the context holder
Returns
-1 if file open failed
-2 if file write failed
>0 if successful (number of bytes written)
Exceptions
exceptions::MemoryExceptionnot enough buffer to encode

Definition at line 1593 of file ThreadSafeContext.cpp.

◆ save_modifieds()

VariableReferences madara::knowledge::ThreadSafeContext::save_modifieds ( void  ) const
inline

Saves the list of modified records to use later for resending.

This does not clear the modified list. This feature is useful if you want to remember what has been modified and then resend later, e.g., if you believe packets may be dropped and want to resend information. Use this function in conjunction with

See also
add_modifieds to remodify
Returns
a vector of VariableReferences to the current modified list

Definition at line 1106 of file ThreadSafeContext.inl.

◆ set() [1/4]

template<typename T >
int madara::knowledge::ThreadSafeContext::set ( const std::string &  key,
const T *  value,
uint32_t  size,
const KnowledgeUpdateSettings settings = KnowledgeUpdateSettings() 
)
inline

Atomically sets the value of a variable to an array.

Parameters
keyunique identifier of the variable
valuean array
sizenumber of elements in the array
settingssettings for applying the update
Returns
0 if the value was set. -1 if null key

Definition at line 308 of file ThreadSafeContext.inl.

◆ set() [2/4]

template<typename T >
int madara::knowledge::ThreadSafeContext::set ( const std::string &  key,
T &&  value,
const KnowledgeUpdateSettings settings = KnowledgeUpdateSettings() 
)
inline

Atomically sets the value of a variable to the specific record.

Note, this does not copy meta information (e.g. quality, clock).

Parameters
keyunique identifier of the variable
valuenew value of the variable
settingssettings for applying the update
Returns
0 if the value was set. -1 if null key

Definition at line 288 of file ThreadSafeContext.inl.

◆ set() [3/4]

template<typename T >
int madara::knowledge::ThreadSafeContext::set ( const VariableReference variable,
const T *  value,
uint32_t  size,
const KnowledgeUpdateSettings settings = KnowledgeUpdateSettings() 
)
inline

Atomically sets the value of a variable to an array.

Parameters
variablereference to a variable (
See also
get_ref)
Parameters
valuean array of type T
sizenumber of elements in the array
settingssettings for applying the update
Returns
0 if the value was set. -1 if null key

Definition at line 317 of file ThreadSafeContext.inl.

◆ set() [4/4]

template<typename T >
int madara::knowledge::ThreadSafeContext::set ( const VariableReference variable,
T &&  value,
const KnowledgeUpdateSettings settings = KnowledgeUpdateSettings() 
)
inline

Atomically sets the value of a variable to an array.

Parameters
variablereference to a variable (
See also
get_ref)
Parameters
valuenew value of the variable
settingssettings for applying the update
Returns
0 if the value was set. -1 if null key

Definition at line 296 of file ThreadSafeContext.inl.

◆ set_changed()

void madara::knowledge::ThreadSafeContext::set_changed ( void  )

Force a change to be registered, waking up anyone waiting on entry.

Indicate that a status change has occurred.

This could be a message from the transport to let the knowledge engine know that new agents are available to send knowledge to.

Definition at line 769 of file ThreadSafeContext.cpp.

◆ set_clock() [1/2]

uint64_t madara::knowledge::ThreadSafeContext::set_clock ( const std::string &  key,
uint64_t  clock,
const KnowledgeReferenceSettings settings = KnowledgeReferenceSettings() 
)
inline

Atomically sets the Lamport clock of a variable and returns the new clock time (intended for sending knowledge updates).

set the lamport clock (updates with lamport clocks lower than our current clock get discarded)

Parameters
keyunique identifier of the variable
clocknew variable clock
settingssettings for applying the update
Returns
new clock time for variable

Definition at line 685 of file ThreadSafeContext.inl.

◆ set_clock() [2/2]

uint64_t madara::knowledge::ThreadSafeContext::set_clock ( uint64_t  clock)
inline

Atomically sets the lamport clock.

set the lamport clock (updates with lamport clocks lower than our current clock get discarded)

Parameters
clocknew global clock
Returns
new clock time

Definition at line 671 of file ThreadSafeContext.inl.

◆ set_file() [1/2]

int madara::knowledge::ThreadSafeContext::set_file ( const std::string &  key,
const unsigned char *  value,
size_t  size,
const KnowledgeUpdateSettings settings = KnowledgeUpdateSettings() 
)
inline

Atomically sets the value of a variable to an arbitrary string.

Parameters
keyunique identifier of the variable
valuenew value of the variable
sizeindicates the size of the value buffer
settingssettings for applying the update
Returns
0 if the value was set. -1 if null key

Definition at line 396 of file ThreadSafeContext.inl.

◆ set_file() [2/2]

int madara::knowledge::ThreadSafeContext::set_file ( const VariableReference variable,
const unsigned char *  value,
size_t  size,
const KnowledgeUpdateSettings settings = KnowledgeUpdateSettings() 
)

Atomically sets the value of a variable to an arbitrary string.

Parameters
variablereference to a variable (
See also
get_ref)
Parameters
valuenew value of the variable
sizeindicates the size of the value buffer
settingssettings for applying the update
Returns
0 if the value was set. -1 if null key

Definition at line 220 of file ThreadSafeContext.cpp.

◆ set_if_unequal() [1/3]

int madara::knowledge::ThreadSafeContext::set_if_unequal ( const std::string &  key,
const std::string &  value,
uint32_t  quality,
uint64_t  clock,
const KnowledgeUpdateSettings settings = KnowledgeUpdateSettings() 
)

Atomically sets if the variable value will be different.

Set if the variable value will be different.

Parameters
keyunique identifier of the variable
valuenew value of the variable
qualityquality to set the variable at (type of priority)
clockclock value of the update
settingssettings for applying the update
Returns
1 if the value was changed. 0 if not changed. -1 if null key

Always updates clock to highest value

Returns
1 if the value was changed. 0 if not changed. -1 if null key, -2 if quality not high enough

Definition at line 569 of file ThreadSafeContext.cpp.

◆ set_if_unequal() [2/3]

int madara::knowledge::ThreadSafeContext::set_if_unequal ( const std::string &  key,
double  value,
uint32_t  quality,
uint64_t  clock,
const KnowledgeUpdateSettings settings = KnowledgeUpdateSettings() 
)

Atomically sets if the variable value will be different.

Set if the variable value will be different.

Parameters
keyunique identifier of the variable
valuenew value of the variable
qualityquality to set the variable at (type of priority)
clockclock value of the update
settingssettings for applying the update
Returns
1 if the value was changed. 0 if not changed. -1 if null key

Always updates clock to highest value

Returns
1 if the value was changed. 0 if not changed. -1 if null key, -2 if quality not high enough

Definition at line 484 of file ThreadSafeContext.cpp.

◆ set_if_unequal() [3/3]

int madara::knowledge::ThreadSafeContext::set_if_unequal ( const std::string &  key,
madara::knowledge::KnowledgeRecord::Integer  value,
uint32_t  quality,
uint64_t  clock,
const KnowledgeUpdateSettings settings = KnowledgeUpdateSettings() 
)

Atomically sets if the variable value will be different.

Set if the variable value will be different.

Parameters
keyunique identifier of the variable
valuenew value of the variable
qualityquality to set the variable at (type of priority)
clockclock value of the update
settingssettings for applying the update
Returns
1 if the value was changed. 0 if not changed. -1 if null key

Always updates clock to highest value

Returns
1 if the value was changed. 0 if not changed. -1 if null key, -2 if quality not high enough

Definition at line 397 of file ThreadSafeContext.cpp.

◆ set_index() [1/2]

template<typename T >
int madara::knowledge::ThreadSafeContext::set_index ( const std::string &  key,
size_t  index,
T &&  value,
const KnowledgeUpdateSettings settings = KnowledgeUpdateSettings() 
)
inline

Atomically sets the value of an array index to a value.

Parameters
keyunique identifier of the variable
indexindex within array
valuenew value of the array index
settingssettings for applying the update
Returns
0 if the value was set. -1 if null key

Definition at line 405 of file ThreadSafeContext.inl.

◆ set_index() [2/2]

template<typename T >
int madara::knowledge::ThreadSafeContext::set_index ( const VariableReference variable,
size_t  index,
T &&  value,
const KnowledgeUpdateSettings settings = KnowledgeUpdateSettings() 
)
inline

Atomically sets the value of an array index to a value.

Parameters
variablereference to a variable (
See also
get_ref)
Parameters
indexindex within array
valuenew value of the array index
settingssettings for applying the update
Returns
0 if the value was set. -1 if null key

Definition at line 413 of file ThreadSafeContext.inl.

◆ set_index_unsafe()

template<typename T >
int madara::knowledge::ThreadSafeContext::set_index_unsafe ( const VariableReference variable,
size_t  index,
T &&  value,
const KnowledgeUpdateSettings settings = KnowledgeUpdateSettings() 
)
inline

NON-Atomically sets the value of an array index to a value.

THIS IS NOT A THREAD-SAFE FUNCTION.

Parameters
variablereference to a variable (
See also
get_ref)
Parameters
indexindex within array
valuenew value of the array index
settingssettings for applying the update
Returns
0 if the value was set. -1 if null key

Definition at line 444 of file ThreadSafeContext.inl.

◆ set_index_unsafe_impl()

template<typename T >
int madara::knowledge::ThreadSafeContext::set_index_unsafe_impl ( const VariableReference variable,
size_t  index,
T &&  value,
const KnowledgeUpdateSettings settings = KnowledgeUpdateSettings() 
)
inlineprivate

Definition at line 424 of file ThreadSafeContext.inl.

◆ set_jpeg() [1/2]

int madara::knowledge::ThreadSafeContext::set_jpeg ( const std::string &  key,
const unsigned char *  value,
size_t  size,
const KnowledgeUpdateSettings settings = KnowledgeUpdateSettings() 
)
inline

Atomically sets the value of a variable to a JPEG image.

Parameters
keyunique identifier of the variable
valuenew value of the variable
sizeindicates the size of the value buffer
settingssettings for applying the update
Returns
0 if the value was set. -1 if null key

Definition at line 388 of file ThreadSafeContext.inl.

◆ set_jpeg() [2/2]

int madara::knowledge::ThreadSafeContext::set_jpeg ( const VariableReference variable,
const unsigned char *  value,
size_t  size,
const KnowledgeUpdateSettings settings = KnowledgeUpdateSettings() 
)

Atomically sets the value of a variable to a JPEG image.

Parameters
variablereference to a variable (
See also
get_ref)
Parameters
valuenew value of the variable
sizeindicates the size of the value buffer
settingssettings for applying the update
Returns
0 if the value was set. -1 if null key

Definition at line 193 of file ThreadSafeContext.cpp.

◆ set_log_level()

void madara::knowledge::ThreadSafeContext::set_log_level ( int  level)
inline

Sets the log level.

Parameters
levelthe maximum detail level to print

Definition at line 1230 of file ThreadSafeContext.inl.

◆ set_quality()

uint32_t madara::knowledge::ThreadSafeContext::set_quality ( const std::string &  key,
uint32_t  quality,
bool  force_update,
const KnowledgeReferenceSettings settings 
)

Atomically sets quality of this process for a variable.

Set quality of last update to a variable.

Parameters
keyunique identifier of the variable
qualityquality of this process
force_updateforce an update to variable, even if lower
settingssettings for referring to a knowledge variable
Returns
write quality associated with the variable
quality of the variable after this call

Definition at line 337 of file ThreadSafeContext.cpp.

◆ set_text() [1/2]

int madara::knowledge::ThreadSafeContext::set_text ( const std::string &  key,
const char *  value,
size_t  size,
const KnowledgeUpdateSettings settings = KnowledgeUpdateSettings() 
)
inline

Atomically sets the value of a variable to an XML string.

Parameters
keyunique identifier of the variable
valuenew value of the variable
sizeindicates the size of the value buffer
settingssettings for applying the update
Returns
0 if the value was set. -1 if null key

Definition at line 381 of file ThreadSafeContext.inl.

◆ set_text() [2/2]

int madara::knowledge::ThreadSafeContext::set_text ( const VariableReference variable,
const char *  value,
size_t  size,
const KnowledgeUpdateSettings settings = KnowledgeUpdateSettings() 
)

Atomically sets the value of a variable to a text file's contents.

Parameters
variablereference to a variable (
See also
get_ref)
Parameters
valuenew value of the variable
sizeindicates the size of the value buffer
settingssettings for applying the update
Returns
0 if the value was set. -1 if null key

Definition at line 167 of file ThreadSafeContext.cpp.

◆ set_unsafe() [1/2]

template<typename T >
int madara::knowledge::ThreadSafeContext::set_unsafe ( const VariableReference variable,
const T *  array,
size_t  size,
const KnowledgeUpdateSettings settings = KnowledgeUpdateSettings() 
)
inline

NON-Atomically sets the value of a variable to the specific array.

THIS IS NOT A THREAD-SAFE FUNCTION. Note, this does not copy meta information (e.g. quality, clock).

Parameters
variablereference to a variable (
See also
get_ref)
Parameters
arraynew array value of the variable
sizesize of array pointed to by array
settingssettings for applying the update
Returns
0 if the value was set. -1 if null key

Definition at line 363 of file ThreadSafeContext.inl.

◆ set_unsafe() [2/2]

template<typename T >
int madara::knowledge::ThreadSafeContext::set_unsafe ( const VariableReference variable,
T &&  value,
const KnowledgeUpdateSettings settings = KnowledgeUpdateSettings() 
)
inline

NON-Atomically sets the value of a variable to the specific value.

THIS IS NOT A THREAD-SAFE FUNCTION. Note, this does not copy meta information (e.g. quality, clock).

Parameters
variablereference to a variable (
See also
get_ref)
Parameters
valuenew value of the variable
settingssettings for applying the update
Returns
0 if the value was set. -1 if null key

Definition at line 350 of file ThreadSafeContext.inl.

◆ set_unsafe_impl()

template<typename... Args>
int madara::knowledge::ThreadSafeContext::set_unsafe_impl ( const VariableReference variable,
const KnowledgeUpdateSettings settings,
Args &&...  args 
)
inlineprivate

Definition at line 330 of file ThreadSafeContext.inl.

◆ set_write_quality()

void madara::knowledge::ThreadSafeContext::set_write_quality ( const std::string &  key,
uint32_t  quality,
const KnowledgeReferenceSettings settings 
)

Atomically sets write quality of this process for a variable.

Set quality of this process writing to a variable.

Parameters
keyunique identifier of the variable
qualitywrite quality of this process
settingssettings for referring to a knowledge variable

Definition at line 372 of file ThreadSafeContext.cpp.

◆ set_xml() [1/2]

int madara::knowledge::ThreadSafeContext::set_xml ( const std::string &  key,
const char *  value,
size_t  size,
const KnowledgeUpdateSettings settings = KnowledgeUpdateSettings() 
)
inline

Atomically sets the value of a variable to an XML string.

Parameters
keyunique identifier of the variable
valuenew value of the variable
sizeindicates the size of the value buffer
settingssettings for applying the update
Returns
0 if the value was set. -1 if null key

Definition at line 374 of file ThreadSafeContext.inl.

◆ set_xml() [2/2]

int madara::knowledge::ThreadSafeContext::set_xml ( const VariableReference variable,
const char *  value,
size_t  size,
const KnowledgeUpdateSettings settings = KnowledgeUpdateSettings() 
)

Atomically sets the value of a variable to an XML string.

Parameters
variablereference to a variable (
See also
get_ref)
Parameters
valuenew value of the variable
sizeindicates the size of the value buffer
settingssettings for applying the update
Returns
0 if the value was set. -1 if null key

Definition at line 141 of file ThreadSafeContext.cpp.

◆ share_binary() [1/2]

std::shared_ptr<const std::vector<unsigned char> > madara::knowledge::ThreadSafeContext::share_binary ( const std::string &  key,
const KnowledgeReferenceSettings settings = KnowledgeReferenceSettings() 
) const
inline
Returns
a shared_ptr, sharing with the internal one. If this record is not a binary file, returns NULL shared_ptr

Definition at line 289 of file ThreadSafeContext.h.

◆ share_binary() [2/2]

std::shared_ptr<const std::vector<unsigned char> > madara::knowledge::ThreadSafeContext::share_binary ( const VariableReference key,
const KnowledgeReferenceSettings settings = KnowledgeReferenceSettings() 
) const
inline
Returns
a shared_ptr, sharing with the internal one. If this record is not a binary file, returns NULL shared_ptr

Definition at line 301 of file ThreadSafeContext.h.

◆ share_doubles() [1/2]

std::shared_ptr<const std::vector<double> > madara::knowledge::ThreadSafeContext::share_doubles ( const std::string &  key,
const KnowledgeReferenceSettings settings = KnowledgeReferenceSettings() 
) const
inline
Returns
a shared_ptr, sharing with the internal one. If this record is not a doubles array, returns NULL shared_ptr

Definition at line 265 of file ThreadSafeContext.h.

◆ share_doubles() [2/2]

std::shared_ptr<const std::vector<double> > madara::knowledge::ThreadSafeContext::share_doubles ( const VariableReference key,
const KnowledgeReferenceSettings settings = KnowledgeReferenceSettings() 
) const
inline
Returns
a shared_ptr, sharing with the internal one. If this record is not a doubles array, returns NULL shared_ptr

Definition at line 277 of file ThreadSafeContext.h.

◆ share_integers() [1/2]

std::shared_ptr<const std::vector<KnowledgeRecord::Integer> > madara::knowledge::ThreadSafeContext::share_integers ( const std::string &  key,
const KnowledgeReferenceSettings settings = KnowledgeReferenceSettings() 
) const
inline
Returns
a shared_ptr, sharing with the internal one. If this record is not an integer array, returns NULL shared_ptr

Definition at line 241 of file ThreadSafeContext.h.

◆ share_integers() [2/2]

std::shared_ptr<const std::vector<KnowledgeRecord::Integer> > madara::knowledge::ThreadSafeContext::share_integers ( const VariableReference key,
const KnowledgeReferenceSettings settings = KnowledgeReferenceSettings() 
) const
inline
Returns
a shared_ptr, sharing with the internal one. If this record is not an integer array, returns NULL shared_ptr

Definition at line 253 of file ThreadSafeContext.h.

◆ share_string() [1/2]

std::shared_ptr<const std::string> madara::knowledge::ThreadSafeContext::share_string ( const std::string &  key,
const KnowledgeReferenceSettings settings = KnowledgeReferenceSettings() 
) const
inline
Returns
a shared_ptr, sharing with the internal one. If this record is not a string, returns NULL shared_ptr

Definition at line 217 of file ThreadSafeContext.h.

◆ share_string() [2/2]

std::shared_ptr<const std::string> madara::knowledge::ThreadSafeContext::share_string ( const VariableReference key,
const KnowledgeReferenceSettings settings = KnowledgeReferenceSettings() 
) const
inline
Returns
a shared_ptr, sharing with the internal one. If this record is not a string, returns NULL shared_ptr

Definition at line 229 of file ThreadSafeContext.h.

◆ signal()

void madara::knowledge::ThreadSafeContext::signal ( bool  lock = true) const
inline

Signals that this thread is done with the context.

Signal the condition that it can wake up someone else on changed data.

Anyone waiting on the underlying condition is awoken.

Definition at line 1209 of file ThreadSafeContext.inl.

◆ to_map() [1/3]

KnowledgeMap madara::knowledge::ThreadSafeContext::to_map ( const std::string &  prefix) const

Creates a map with Knowledge Records that begin with the given prefix.

Runs in O(log n + m) time, where n is the size of the KnowledgeBase, and m is the number of matching records

Parameters
prefixPrefix string to match with
Returns
A new map with just entries starting with prefix

Definition at line 1404 of file ThreadSafeContext.cpp.

◆ to_map() [2/3]

size_t madara::knowledge::ThreadSafeContext::to_map ( const std::string &  prefix,
const std::string &  delimiter,
const std::string &  suffix,
std::vector< std::string > &  next_keys,
std::map< std::string, knowledge::KnowledgeRecord > &  result,
bool  just_keys 
)

Fills a variable map with list of keys according to a matching prefix, suffix, and delimiter hierarchy.

This is useful for understanding the logical hierarchy of your variables (and also a key utility of containers like

See also
containers::FlexMap).
Parameters
prefixText that must be present at the front of the key
delimiterText that signifies a logical boundary in hierarchy If empty, no check is performed.
suffixText that must be present at the end of the key. If empty, no check is performed.
next_keysThe immediate keys in the hierarchy after prefix
resultThe map that will be filled with full variable names and the Knowledge Records that correspond to
just_keysif true, do not fill result, only next_keys
Returns
entries in the resulting map

Definition at line 1219 of file ThreadSafeContext.cpp.

◆ to_map() [3/3]

size_t madara::knowledge::ThreadSafeContext::to_map ( const std::string &  subject,
std::map< std::string, knowledge::KnowledgeRecord > &  target 
)

Fills a variable map with Knowledge Records that match an expression.

At the moment, this expression must be of the form "subject*"

Parameters
subjectAn expression that matches the variable names that are of interest. Wildcards may only be at the end.
targetThe map that will be filled with variable names and the Knowledge Records that correspond to
Returns
entries in the resulting map

Definition at line 1115 of file ThreadSafeContext.cpp.

◆ to_map_stripped()

KnowledgeMap madara::knowledge::ThreadSafeContext::to_map_stripped ( const std::string &  prefix) const

Creates a map with Knowledge Records that begin with the given prefix.

Runs in O(log n + m) time, where n is the size of the KnowledgeBase, and m is the number of matching records

All key names have the "prefix" portion stripped off their front in the returned map.

Parameters
prefixPrefix string to match with
Returns
A new map with just entries starting with prefix

Definition at line 1416 of file ThreadSafeContext.cpp.

◆ to_string()

void madara::knowledge::ThreadSafeContext::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 function.

This is an optimized version that allows the specification of a target string to avoid string copying (which can be expensive with longer strings across multiple function boundaries). This function differs from knowledge::KnowledgeRecord to_string in that it is intended to save the database in a format that can be easily parseable. Consequently, strings are delineated in this function by being included in single quotes. Arrays are delineated with array indices [].

This is not appropriate for saving the context if it has binary data inside of it, as only the size of the data entry would be saved.

Parameters
targetwhere to store the resulting string operation.
array_delimiterfor any arrays, the characters in between data elements.
record_delimiterthe characters to place between individual key/value pairs
key_val_delimiterthe characters to place between keys and values.

Definition at line 789 of file ThreadSafeContext.cpp.

◆ to_vector()

size_t madara::knowledge::ThreadSafeContext::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 integer values.

Parameters
subjectThe common subject of the variable names. For instance, if we are looking for a range of vars like "var0", "var1", "var2", then the common subject would be "var".
startAn inclusive start index
endAn inclusive end index
targetThe vector that will be filled with Knowledge Record instances within the subject range.
Returns
entries in the resulting vector

Definition at line 1091 of file ThreadSafeContext.cpp.

◆ try_lock()

bool madara::knowledge::ThreadSafeContext::try_lock ( void  ) const
inline

Locks the mutex on this context.

Warning: this will cause all operations to block until the unlock call is made.

Returns immediately without blocking. Returns true if lock was successful, false otherwise.

Definition at line 817 of file ThreadSafeContext.inl.

◆ unlock()

void madara::knowledge::ThreadSafeContext::unlock ( void  ) const
inline

Unlocks the mutex on this context.

Unlock the mutex on this context.

Definition at line 823 of file ThreadSafeContext.inl.

◆ update_record_from_external() [1/2]

int madara::knowledge::ThreadSafeContext::update_record_from_external ( const std::string &  key,
const knowledge::KnowledgeRecord rhs,
const KnowledgeUpdateSettings settings = KnowledgeUpdateSettings(true) 
)

Atomically sets if the variable value meets update conditions.

Set if the variable value will be different.

Appropriate conditions include clock being >= old clock, quality >= old quality, etc.

Parameters
keyunique identifier of the variable
rhsnew value of the variable
settingssettings for applying the update
Returns
1 if the value was changed. 0 if not changed. -1 if null key

Always updates clock to highest value

Returns
1 if the value was changed. 0 if not changed. -1 if null key, -2 if quality not high enough

Definition at line 655 of file ThreadSafeContext.cpp.

◆ update_record_from_external() [2/2]

int madara::knowledge::ThreadSafeContext::update_record_from_external ( const VariableReference target,
const knowledge::KnowledgeRecord rhs,
const KnowledgeUpdateSettings settings = KnowledgeUpdateSettings(true) 
)

Atomically sets if the variable value meets update conditions.

Set if the variable value will be different.

Appropriate conditions include clock being >= old clock, quality >= old quality, etc.

Parameters
targetthe target reference in the knowledge base
rhsnew value of the variable
settingssettings for applying the update
Returns
1 if the value was changed. 0 if not changed. -1 if null key

Always updates clock to highest value

Returns
1 if the value was changed. 0 if not changed. -1 if null key, -2 if quality not high enough

Definition at line 730 of file ThreadSafeContext.cpp.

◆ wait_for_change()

void madara::knowledge::ThreadSafeContext::wait_for_change ( bool  extra_release = false)
inline

Wait for a change to happen to the context.

Make the current thread of execution wait for a change on the context.

Parameters
extra_releaseperform extra release of lock for nested locks

Definition at line 863 of file ThreadSafeContext.inl.

◆ with() [1/4]

KnowledgeRecord * madara::knowledge::ThreadSafeContext::with ( const std::string &  key,
const KnowledgeReferenceSettings settings = KnowledgeReferenceSettings() 
)
inlineprivate

Atomically returns a reference to the variable.

Parameters
keyunique identifier of the variable
settingsthe settings for referring to variables
Returns
pointer to record, nullptr if none exists

Definition at line 138 of file ThreadSafeContext.inl.

◆ with() [2/4]

const KnowledgeRecord * madara::knowledge::ThreadSafeContext::with ( const std::string &  key,
const KnowledgeReferenceSettings settings = KnowledgeReferenceSettings() 
) const
inlineprivate

Atomically returns a reference to the variable.

Parameters
keyunique identifier of the variable
settingsthe settings for referring to variables
Returns
the madara::knowledge::KnowledgeRecord::Integer value for the variable

Definition at line 183 of file ThreadSafeContext.inl.

◆ with() [3/4]

KnowledgeRecord * madara::knowledge::ThreadSafeContext::with ( const VariableReference variable,
const KnowledgeReferenceSettings settings = KnowledgeReferenceSettings() 
)
inlineprivate

Atomically returns the value of a variable.

Parameters
variablereference to a variable (
See also
get_ref)
Parameters
settingsthe settings for referring to variables
Returns
pointer to record, nullptr if none exists

Definition at line 164 of file ThreadSafeContext.inl.

◆ with() [4/4]

const KnowledgeRecord * madara::knowledge::ThreadSafeContext::with ( const VariableReference variable,
const KnowledgeReferenceSettings settings = KnowledgeReferenceSettings() 
) const
inlineprivate

Atomically returns the value of a variable.

Parameters
variablereference to a variable (
See also
get_ref)
Parameters
settingsthe settings for referring to variables
Returns
the madara::knowledge::KnowledgeRecord::Integer value for the variable

Definition at line 217 of file ThreadSafeContext.inl.

Friends And Related Function Documentation

◆ expression::CompositeArrayReference

Definition at line 79 of file ThreadSafeContext.h.

◆ expression::VariableNode

friend class expression::VariableNode
friend

Definition at line 80 of file ThreadSafeContext.h.

◆ KnowledgeBaseImpl

friend class KnowledgeBaseImpl
friend

Definition at line 78 of file ThreadSafeContext.h.

Member Data Documentation

◆ changed_

MADARA_CONDITION_TYPE madara::knowledge::ThreadSafeContext::changed_
mutableprivate

Definition at line 1713 of file ThreadSafeContext.h.

◆ changed_map_

VariableReferenceMap madara::knowledge::ThreadSafeContext::changed_map_
mutableprivate

Definition at line 1716 of file ThreadSafeContext.h.

◆ clock_

uint64_t madara::knowledge::ThreadSafeContext::clock_
mutableprivate

Definition at line 1715 of file ThreadSafeContext.h.

◆ expansion_splitters_

std::vector<std::string> madara::knowledge::ThreadSafeContext::expansion_splitters_
private

Definition at line 1714 of file ThreadSafeContext.h.

◆ functions_

FunctionMap madara::knowledge::ThreadSafeContext::functions_
private

map of function names to functions

Definition at line 1720 of file ThreadSafeContext.h.

◆ interpreter_

madara::expression::Interpreter* madara::knowledge::ThreadSafeContext::interpreter_
private

KaRL interpreter.

Definition at line 1723 of file ThreadSafeContext.h.

◆ local_changed_map_

VariableReferenceMap madara::knowledge::ThreadSafeContext::local_changed_map_
mutableprivate

Definition at line 1717 of file ThreadSafeContext.h.

◆ logger_

logger::Logger* madara::knowledge::ThreadSafeContext::logger_
mutableprivate

Logger for printing.

Definition at line 1726 of file ThreadSafeContext.h.

◆ map_

madara::knowledge::KnowledgeMap madara::knowledge::ThreadSafeContext::map_
private

Hash table containing variable names and values.

Definition at line 1711 of file ThreadSafeContext.h.

◆ mutex_

MADARA_LOCK_TYPE madara::knowledge::ThreadSafeContext::mutex_
mutableprivate

Definition at line 1712 of file ThreadSafeContext.h.

◆ streamer_

std::unique_ptr<BaseStreamer> madara::knowledge::ThreadSafeContext::streamer_ = nullptr
private

Streaming provider for saving all updates.

Definition at line 1729 of file ThreadSafeContext.h.


The documentation for this class was generated from the following files: