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)
223 MADARA_GUARD_TYPE guard (
mutex_);
236 return default_value;
246 MADARA_GUARD_TYPE guard (
mutex_);
259 return default_value;
268 MADARA_GUARD_TYPE guard (
mutex_);
281 return default_value;
291 MADARA_GUARD_TYPE guard (
mutex_);
304 return default_value;
315 MADARA_GUARD_TYPE guard (
mutex_);
334 MADARA_GUARD_TYPE guard (
mutex_);
353 MADARA_GUARD_TYPE guard (
mutex_);
371 MADARA_GUARD_TYPE guard (
mutex_);
389 MADARA_GUARD_TYPE guard (
mutex_);
408 MADARA_GUARD_TYPE guard (
mutex_);
425 MADARA_GUARD_TYPE guard (
mutex_);
443 MADARA_GUARD_TYPE guard (
mutex_);
461 MADARA_GUARD_TYPE guard (
mutex_);
479 MADARA_GUARD_TYPE guard (
mutex_);
500 MADARA_GUARD_TYPE guard (
mutex_);
519 MADARA_GUARD_TYPE guard (
mutex_);
521 std::stringstream buffer;
527 map.
set_name (buffer.str (), knowledge);
535 bool first_level_keys_only)
const 538 MADARA_GUARD_TYPE guard (
mutex_);
542 if (!first_level_keys_only)
549 result = map.
size ();
554 std::vector<std::string> next_keys;
555 std::map<std::string, madara::knowledge::KnowledgeRecord> all_record_vars;
557 next_keys, all_record_vars,
true);
559 result = next_keys.size ();
567 FlexMap & other,
bool refresh_keys,
bool delete_keys)
575 MADARA_GUARD_TYPE guard (
mutex_, std::adopt_lock),
576 guard2 (other.
mutex_, std::adopt_lock);
585 this_map.
exchange (other_map, refresh_keys, delete_keys);
595 MADARA_GUARD_TYPE guard (
mutex_);
615 MADARA_GUARD_TYPE guard (
mutex_);
641 MADARA_GUARD_TYPE guard (
mutex_);
669 MADARA_GUARD_TYPE guard (
mutex_);
691 MADARA_GUARD_TYPE guard (
mutex_);
735 const std::string & key,
bool first_level_key)
const 742 MADARA_GUARD_TYPE guard (
mutex_);
748 if (!result && first_level_key)
750 std::vector <std::string> curkeys;
753 std::vector <std::string>::iterator found;
756 found = std::find (curkeys.begin (), curkeys.end (), key);
758 result = found != curkeys.end ();
767 std::vector <std::string> & curkeys,
768 bool first_level_keys_only)
const 771 MADARA_GUARD_TYPE guard (
mutex_);
773 if (!first_level_keys_only)
785 std::vector<std::string> next_keys;
786 std::map<std::string, madara::knowledge::KnowledgeRecord> all_record_vars;
788 curkeys, all_record_vars,
true);
801 MADARA_GUARD_TYPE guard (
mutex_);
824 MADARA_GUARD_TYPE guard (
mutex_);
844 MADARA_GUARD_TYPE guard (
mutex_);
866 MADARA_GUARD_TYPE guard (
mutex_);
889 MADARA_GUARD_TYPE guard (
mutex_);
913 MADARA_GUARD_TYPE guard (
mutex_);
936 MADARA_GUARD_TYPE guard (
mutex_);
959 MADARA_GUARD_TYPE guard (
mutex_);
973 const std::vector <KnowledgeRecord::Integer> & value)
980 MADARA_GUARD_TYPE guard (
mutex_);
994 const std::vector <KnowledgeRecord::Integer> & value,
1002 MADARA_GUARD_TYPE guard (
mutex_);
1023 MADARA_GUARD_TYPE guard (
mutex_);
1045 MADARA_GUARD_TYPE guard (
mutex_);
1067 MADARA_GUARD_TYPE guard (
mutex_);
1090 MADARA_GUARD_TYPE guard (
mutex_);
1104 const double * value,
1112 MADARA_GUARD_TYPE guard (
mutex_);
1126 const double * value,
1135 MADARA_GUARD_TYPE guard (
mutex_);
1149 const std::vector <double> & value)
1156 MADARA_GUARD_TYPE guard (
mutex_);
1170 const std::vector <double> & value,
1178 MADARA_GUARD_TYPE guard (
mutex_);
1199 MADARA_GUARD_TYPE guard (
mutex_);
1221 MADARA_GUARD_TYPE guard (
mutex_);
1235 const unsigned char * value,
size_t size)
1242 MADARA_GUARD_TYPE guard (
mutex_);
1256 const unsigned char * value,
size_t size,
1264 MADARA_GUARD_TYPE guard (
mutex_);
1278 const unsigned char * value,
size_t size)
1285 MADARA_GUARD_TYPE guard (
mutex_);
1299 const unsigned char * value,
size_t size,
1307 MADARA_GUARD_TYPE guard (
mutex_);
1328 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.
double to_double(double default_value=0.0) const
Returns the value at the location as a double.
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.
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.
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.
std::string to_string(const std::string &default_value="") const
Returns the value at the location as a string.
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.
VariableReference get_ref(const std::string &key, const KnowledgeReferenceSettings &settings=KnowledgeReferenceSettings())
Atomically returns a reference to the variable.
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.
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.
knowledge::KnowledgeRecord::Integer to_integer(KnowledgeRecord::Integer default_value=0) const
Returns the value at the location as an integer.
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.
Settings for applying knowledge updates.
knowledge::KnowledgeRecord to_record(const KnowledgeRecord &default_value=KnowledgeRecord(0)) const
Retrieves a copy of the record from the current location.
madara::knowledge::KnowledgeRecord get(const std::string &key, const KnowledgeReferenceSettings &settings=KnowledgeReferenceSettings()) const
Atomically returns the value of a variable.
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.
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.
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.