9 :
BaseContainer (
"", settings), context_ (0), delimiter_ (delimiter)
60 "Vector::is_true: checking for non-zero value\n");
68 "FlexMap::is_true: final result is %d\n", (int)result);
118 std::stringstream result;
120 result <<
"Flex Map: ";
125 MADARA_GUARD_TYPE guard (
mutex_);
135 return result.str ();
203 const std::vector <KnowledgeRecord::Integer> & value)
210 const std::vector <double> & value)
224 MADARA_GUARD_TYPE guard (
mutex_);
265 MADARA_GUARD_TYPE guard (
mutex_);
284 MADARA_GUARD_TYPE guard (
mutex_);
303 MADARA_GUARD_TYPE guard (
mutex_);
321 MADARA_GUARD_TYPE guard (
mutex_);
339 MADARA_GUARD_TYPE guard (
mutex_);
358 MADARA_GUARD_TYPE guard (
mutex_);
375 MADARA_GUARD_TYPE guard (
mutex_);
393 MADARA_GUARD_TYPE guard (
mutex_);
411 MADARA_GUARD_TYPE guard (
mutex_);
429 MADARA_GUARD_TYPE guard (
mutex_);
450 MADARA_GUARD_TYPE guard (
mutex_);
469 MADARA_GUARD_TYPE guard (
mutex_);
471 std::stringstream buffer;
477 map.
set_name (buffer.str (), knowledge);
485 bool first_level_keys_only)
const 488 MADARA_GUARD_TYPE guard (
mutex_);
492 if (!first_level_keys_only)
499 result = map.
size ();
504 std::vector<std::string> next_keys;
505 std::map<std::string, madara::knowledge::KnowledgeRecord> all_record_vars;
507 next_keys, all_record_vars,
true);
509 result = next_keys.size ();
517 FlexMap & other,
bool refresh_keys,
bool delete_keys)
523 MADARA_GUARD_TYPE guard (
mutex_), guard2 (other.
mutex_);
531 this_map.
exchange (other_map, refresh_keys, delete_keys);
541 MADARA_GUARD_TYPE guard (
mutex_);
561 MADARA_GUARD_TYPE guard (
mutex_);
587 MADARA_GUARD_TYPE guard (
mutex_);
615 MADARA_GUARD_TYPE guard (
mutex_);
637 MADARA_GUARD_TYPE guard (
mutex_);
681 const std::string & key,
bool first_level_key)
const 688 MADARA_GUARD_TYPE guard (
mutex_);
694 if (!result && first_level_key)
696 std::vector <std::string> curkeys;
699 std::vector <std::string>::iterator found;
702 found = std::find (curkeys.begin (), curkeys.end (), key);
704 result = found != curkeys.end ();
713 std::vector <std::string> & curkeys,
714 bool first_level_keys_only)
const 717 MADARA_GUARD_TYPE guard (
mutex_);
719 if (!first_level_keys_only)
731 std::vector<std::string> next_keys;
732 std::map<std::string, madara::knowledge::KnowledgeRecord> all_record_vars;
734 curkeys, all_record_vars,
true);
747 MADARA_GUARD_TYPE guard (
mutex_);
770 MADARA_GUARD_TYPE guard (
mutex_);
790 MADARA_GUARD_TYPE guard (
mutex_);
812 MADARA_GUARD_TYPE guard (
mutex_);
835 MADARA_GUARD_TYPE guard (
mutex_);
859 MADARA_GUARD_TYPE guard (
mutex_);
882 MADARA_GUARD_TYPE guard (
mutex_);
905 MADARA_GUARD_TYPE guard (
mutex_);
919 const std::vector <KnowledgeRecord::Integer> & value)
926 MADARA_GUARD_TYPE guard (
mutex_);
940 const std::vector <KnowledgeRecord::Integer> & value,
948 MADARA_GUARD_TYPE guard (
mutex_);
969 MADARA_GUARD_TYPE guard (
mutex_);
991 MADARA_GUARD_TYPE guard (
mutex_);
1013 MADARA_GUARD_TYPE guard (
mutex_);
1036 MADARA_GUARD_TYPE guard (
mutex_);
1050 const double * value,
1058 MADARA_GUARD_TYPE guard (
mutex_);
1072 const double * value,
1081 MADARA_GUARD_TYPE guard (
mutex_);
1095 const std::vector <double> & value)
1102 MADARA_GUARD_TYPE guard (
mutex_);
1116 const std::vector <double> & value,
1124 MADARA_GUARD_TYPE guard (
mutex_);
1145 MADARA_GUARD_TYPE guard (
mutex_);
1167 MADARA_GUARD_TYPE guard (
mutex_);
1181 const unsigned char * value,
size_t size)
1188 MADARA_GUARD_TYPE guard (
mutex_);
1202 const unsigned char * value,
size_t size,
1210 MADARA_GUARD_TYPE guard (
mutex_);
1224 const unsigned char * value,
size_t size)
1231 MADARA_GUARD_TYPE guard (
mutex_);
1245 const unsigned char * value,
size_t size,
1253 MADARA_GUARD_TYPE guard (
mutex_);
1274 MADARA_GUARD_TYPE guard (
mutex_);
This class encapsulates an entry in a KnowledgeBase.
This class stores a double within a variable context.
int set(const std::string &key, T &&value, const KnowledgeUpdateSettings &settings=KnowledgeUpdateSettings())
Atomically sets the value of a variable to the specific record.
This class stores a vector of character buffers.
bool is_true(void) const
Checks to see if the record is true.
This class stores a vector of doubles inside of KaRL.
void set_delimiter(const std::string &delimiter)
Sets the delimiter for adding and detecting subvariables.
madara::knowledge::KnowledgeRecord get(const std::string &key, const KnowledgeReferenceSettings &settings=KnowledgeReferenceSettings()) const
Atomically returns the value of a variable.
void set_name(const std::string &var_name, KnowledgeBase &knowledge)
Sets the variable name that this refers to.
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.
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.
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.
bool is_true(void) const
Checks if the value in the record is not false (0)
double to_double(void) const
converts the value to a float/double
std::string name_
Prefix of variable.
void keys(std::vector< std::string > &curkeys) const
Returns the keys within the map.
std::string to_string(void) const
Returns the value at the location as a string.
void operator=(const FlexMap &rhs)
Assignment operator.
void set_name(const std::string &var_name, KnowledgeBase &knowledge, int size=-1)
Sets the variable name that this refers to.
void set_name(const std::string &var_name, KnowledgeBase &knowledge, int size=-1)
Sets the variable name that this refers to.
FlexMap operator[](const std::string &key)
Retrieves a flex map at the keyed location.
This class stores a string within a variable context.
int set_index(size_t index, knowledge::KnowledgeRecord::Integer value)
Sets an index within an array to a specified value.
int set(knowledge::KnowledgeRecord::Integer value=knowledge::KnowledgeRecord::MODIFIED)
Sets the location within the map to the specified value.
This class stores a vector of integers inside of KaRL.
ThreadSafeContext * context_
Variable context that we are modifying.
MADARA_LOCK_TYPE mutex_
guard for access and changes
void update_variable(void) const
Updates the variable reference if necessary.
Optimized reference to a variable within the knowledge base.
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.
#define madara_logger_log(logger, level,...)
Fast version of the madara::logger::log method.
bool is_valid(void) const
Checks to see if the variable reference has been initialized.
virtual void modify_(void)
Polymorphic modify method used by collection containers.
void set_name(const std::string &var_name, KnowledgeBase &knowledge, int size=-1)
Sets the variable name that this refers to.
bool exists(const std::string &key, const KnowledgeReferenceSettings &settings=KnowledgeReferenceSettings()) const
Atomically checks to see if a variable already exists.
This class stores a vector of strings inside of KaRL.
void set_delimiter(const std::string &delimiter, bool sync=true)
Sets the delimiter for adding and detecting subvariables.
void erase(const std::string &key, bool delete_subkeys=true)
Erases a variable from the map.
A thread-safe guard for a context or knowledge base.
void to_container(BufferVector &target) const
Fills a BufferVector container with all subkeys.
virtual BaseContainer * clone(void) const
Clones this container.
int set_file(const unsigned char *value, size_t size)
Atomically sets the value of an index to an arbitrary string.
void modify(void)
Mark the vector as modified.
bool is_false(void) const
Checks if the value in the record is false (0)
bool exists(void) const
Checks for the existence of the current location in the context.
void facade_for(ThreadSafeContext &target)
Change the knowledge base to become a facade for another context.
This class stores a map of strings to KaRL variables.
This class provides a distributed knowledge base to users.
void set_name(const std::string &var_name, KnowledgeBase &knowledge, bool sync=true)
Sets the variable name that this refers to.
This class stores an integer within a variable context.
void clear(void)
Clears the map.
This class stores a vector of doubles inside of KaRL.
void exchange(Map &other, bool refresh_keys=true, bool delete_keys=true)
Exchanges the map at this location with the map at another location.
void set_delimiter(const std::string &delimiter)
Sets the delimiter for adding and detecting subvariables.
std::string get_debug_info(void)
Returns the type of the container along with name and any other useful information.
void exchange(FlexMap &other, bool refresh_keys=true, bool delete_keys=true)
Exchanges the map at this location with the map at another location.
void set_delimiter(const std::string &delimiter)
Sets the delimiter for adding and detecting subvariables.
Integer to_integer(void) const
converts the value to an integer
std::string delimiter_
Delimiter for the prefix to subvars.
virtual ~FlexMap()
Destructor.
void clear(bool clear_knowledge=true)
Clears the map.
void set_name(const std::string &var_name, KnowledgeBase &knowledge)
Sets the variable name that this refers to.
knowledge::KnowledgeRecord::Integer to_integer(void) const
Returns the value at the location as an integer.
void set_delimiter(const std::string &delimiter)
Sets the delimiter for adding and detecting subvariables.
ThreadSafeContext & get_context(void)
Returns the ThreadSafeContext associated with this Knowledge Base.
int set_jpeg(const unsigned char *value, size_t size)
Atomically sets the value of an index to a JPEG image.
bool delete_variable(const std::string &key, const KnowledgeReferenceSettings &settings=KnowledgeReferenceSettings())
Deletes the key.
void set_name(const std::string &var_name, KnowledgeBase &knowledge, int size=-1)
Sets the variable name that this refers to.
int read_file(const std::string &filename)
Read a file into a location in the map.
Provides functions and classes for the distributed knowledge base.
KnowledgeUpdateSettings settings_
Settings for modifications.
virtual std::string get_debug_info_(void)
Returns the type of the container along with name and any other useful information.
FlexMap(const KnowledgeUpdateSettings &settings=KnowledgeUpdateSettings(), const std::string &delimiter=".")
Default constructor.
VariableReference get_ref(const std::string &key, const KnowledgeReferenceSettings &settings=KnowledgeReferenceSettings())
Atomically returns a reference to the variable.
Settings for applying knowledge updates.
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.
void mark_modified(const VariableReference &variable, const KnowledgeUpdateSettings &settings=KnowledgeUpdateSettings())
Marks the variable reference as updated.
logger::Logger & get_logger(void) const
Gets the logger used for information printing.
void set_name(const std::string &var_name, KnowledgeBase &knowledge, int size=-1)
Sets the variable name that this refers to.
knowledge::KnowledgeRecord to_record(void) const
Retrieves a copy of the record from the current location.
VariableReference variable_
The current location variable.
Settings for applying knowledge updates.
This class stores a vector of doubles inside of KaRL.
std::string to_string(const std::string &delimiter=", ") const
converts the value to a string.
Provides an interface for external functions into the MADARA KaRL variable settings.
size_t size(bool first_level_keys_only=true) const
Returns the size of the map.
This class stores a flexible map of strings and ints to KaRL variables FlexMap differs from Map in th...
This class is an abstract base class for all containers.
virtual bool is_false_(void) const
Polymorphic is false method which can be used to determine if at least one value in the container is ...
virtual bool is_true_(void) const
Polymorphic is true method which can be used to determine if all values in the container are true...
std::string get_delimiter(void)
Gets the delimiter for adding and detecting subvariables.
int read_file(const std::string &key, const std::string &filename, const KnowledgeUpdateSettings &settings=KnowledgeUpdateSettings())
Atomically reads a file into a variable.
void set_name(const std::string &var_name, KnowledgeBase &knowledge)
Sets the variable name that this refers to.
void set_name(const std::string &var_name, KnowledgeBase &knowledge, int size=-1)
Sets the variable name that this refers to.
double to_double(void) const
Returns the value at the location as a double.
void set_delimiter(const std::string &delimiter)
Sets the delimiter for adding and detecting subvariables.
void modify(void)
Mark the flex map as modified.
std::string get_debug_info(void)
Returns the type of the container along with name and any other useful information.
void set_name(const std::string &var_name, KnowledgeBase &knowledge)
Sets the variable name that this refers to.
void keys(std::vector< std::string > &curkeys, bool first_level_keys_only=true) const
Returns the keys within the map.
size_t size(void) const
Returns the size of the map.
ThreadSafeContext * get_context(void)
Returns the ThreadSafeContext associated with this Variables facade.
void set_quality(uint32_t quality, const KnowledgeReferenceSettings &settings=KnowledgeReferenceSettings(false))
Sets the quality of writing to a certain variable from this entity.