MADARA  3.1.8
madara::knowledge::containers::Map Class Reference

This class stores a map of strings to KaRL variables. More...

#include <Map.h>

Inheritance diagram for madara::knowledge::containers::Map:
Collaboration diagram for madara::knowledge::containers::Map:

Public Member Functions

 Map (const KnowledgeUpdateSettings &settings=KnowledgeUpdateSettings(), const std::string &delimiter=".")
 Default constructor. More...
 
 Map (const std::string &name, KnowledgeBase &knowledge, const KnowledgeUpdateSettings &settings=KnowledgeUpdateSettings(), const std::string &delimiter=".")
 Constructor. More...
 
 Map (const std::string &name, Variables &knowledge, const KnowledgeUpdateSettings &settings=KnowledgeUpdateSettings(), const std::string &delimiter=".")
 Constructor. More...
 
 Map (const Map &rhs)
 Copy constructor. More...
 
virtual ~Map ()
 Destructor. More...
 
void clear (bool clear_knowledge=true)
 Clears the map. More...
 
virtual BaseContainerclone (void) const
 Clones this container. More...
 
void erase (const std::string &key)
 Erases a variable from the map. More...
 
void exchange (Map &other, bool refresh_keys=true, bool delete_keys=true)
 Exchanges the map at this location with the map at another location. More...
 
bool exists (const std::string &key) const
 Checks for the existence of a key. More...
 
std::string get_debug_info (void)
 Returns the type of the container along with name and any other useful information. More...
 
std::string get_delimiter (void)
 Gets the delimiter for adding and detecting subvariables. More...
 
std::string get_name (void) const
 Returns the name of the container. More...
 
KnowledgeUpdateSettings get_settings (void)
 Gets the update settings for the container. More...
 
bool has_prefix (const std::string &prefix) const
 Checks for the existence of a prefix in the keys. More...
 
bool is_false (void) const
 Determines if the value of the map is false. More...
 
bool is_true (void) const
 Determines if all values in the map are true. More...
 
void keys (std::vector< std::string > &curkeys) const
 Returns the keys within the map. More...
 
void modify (void)
 Mark the vector as modified. More...
 
void modify (const std::string &index)
 Mark the value as modified. More...
 
virtual bool modify_if_false (BaseContainer &conditional)
 Modifies the container if the argument is false. More...
 
virtual bool modify_if_true (BaseContainer &conditional)
 Modifies the container if the argument is true. More...
 
void operator= (const Map &rhs)
 Assignment operator. More...
 
knowledge::KnowledgeRecord operator[] (const std::string &key)
 Retrieves a copy of the record from the map. More...
 
int read_file (const std::string &key, const std::string &filename)
 Read a file into a location in the map. More...
 
int read_file (const std::string &key, const std::string &filename, const KnowledgeUpdateSettings &settings)
 Read a file into a location in the map. More...
 
int set (const std::string &key, madara::knowledge::KnowledgeRecord::Integer value=madara::knowledge::KnowledgeRecord::MODIFIED)
 Sets a location within the map to the specified value. More...
 
int set (const std::string &key, madara::knowledge::KnowledgeRecord::Integer value, const KnowledgeUpdateSettings &settings)
 Sets a location within the map to the specified value. More...
 
int set (const std::string &key, const madara::knowledge::KnowledgeRecord::Integer *value, uint32_t size)
 Sets a location within the map to the specified value. More...
 
int set (const std::string &key, const madara::knowledge::KnowledgeRecord::Integer *value, uint32_t size, const KnowledgeUpdateSettings &settings)
 Sets a location within the map to the specified value. More...
 
int set (const std::string &key, const std::vector< KnowledgeRecord::Integer > &value)
 Sets a location within the map to the specified value. More...
 
int set (const std::string &key, const std::vector< KnowledgeRecord::Integer > &value, const KnowledgeUpdateSettings &settings)
 Sets a location within the map to the specified value. More...
 
int set (const std::string &key, double value)
 Sets a location within the map to the specified value. More...
 
int set (const std::string &key, double value, const KnowledgeUpdateSettings &settings)
 Sets a location within the map to the specified value. More...
 
int set (const std::string &key, const double *value, uint32_t size)
 Sets a location within the map to the specified value. More...
 
int set (const std::string &key, const double *value, uint32_t size, const KnowledgeUpdateSettings &settings)
 Sets a location within the map to the specified value. More...
 
int set (const std::string &key, const std::vector< double > &value)
 Sets a location within the map to the specified value. More...
 
int set (const std::string &key, const std::vector< double > &value, const KnowledgeUpdateSettings &settings)
 Sets a location within the map to the specified value. More...
 
int set (const std::string &key, const std::string &value)
 Sets a location within the map to the specified value. More...
 
int set (const std::string &key, const std::string &value, const KnowledgeUpdateSettings &settings)
 Sets a location within the map to the specified value. More...
 
void set_delimiter (const std::string &delimiter, bool sync=true)
 Sets the delimiter for adding and detecting subvariables. More...
 
int set_file (const std::string &key, const unsigned char *value, size_t size)
 Atomically sets the value of an index to an arbitrary string. More...
 
int set_file (const std::string &key, const unsigned char *value, size_t size, const KnowledgeUpdateSettings &settings)
 Atomically sets the value of an index to an arbitrary string. More...
 
int set_index (const std::string &key, size_t index, madara::knowledge::KnowledgeRecord::Integer value)
 Sets an index within an array to a specified value. More...
 
int set_index (const std::string &key, size_t index, madara::knowledge::KnowledgeRecord::Integer value, const KnowledgeUpdateSettings &settings)
 Sets an index within an array to a specified value. More...
 
int set_index (const std::string &key, size_t index, double value)
 Sets an index within a map to a specified value. More...
 
int set_index (const std::string &key, size_t index, double value, const KnowledgeUpdateSettings &settings)
 Sets an index within a map to a specified value. More...
 
int set_jpeg (const std::string &key, const unsigned char *value, size_t size)
 Atomically sets the value of an index to a JPEG image. More...
 
int set_jpeg (const std::string &key, const unsigned char *value, size_t size, const KnowledgeUpdateSettings &settings)
 Atomically sets the value of an index to a JPEG image. More...
 
void set_name (const std::string &var_name, KnowledgeBase &knowledge, bool sync=true)
 Sets the variable name that this refers to. More...
 
void set_name (const std::string &var_name, Variables &knowledge, bool sync=true)
 Sets the variable name that this refers to. More...
 
void set_quality (const std::string &key, uint32_t quality, const KnowledgeReferenceSettings &settings=KnowledgeReferenceSettings(false))
 Sets the quality of writing to a certain variable from this entity. More...
 
void set_settings (const KnowledgeUpdateSettings &settings)
 Sets the update settings for the container. More...
 
size_t size (void) const
 Returns the size of the map. More...
 
std::vector< std::string > sync_keys (void)
 Syncs the keys from the knowledge base. More...
 
knowledge::KnowledgeRecord to_record (const std::string &key)
 Retrieves a copy of the record from the map. More...
 

Protected Attributes

MADARA_LOCK_TYPE mutex_
 guard for access and changes More...
 
std::string name_
 Prefix of variable. More...
 
KnowledgeUpdateSettings settings_
 Settings for modifications. More...
 

Private Types

typedef std::map< std::string, VariableReferenceInternalMap
 internal map of variable references More...
 

Private Member Functions

virtual std::string get_debug_info_ (void)
 Returns the type of the container along with name and any other useful information. More...
 
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 false. More...
 
virtual bool is_true_ (void) const
 Polymorphic is true method which can be used to determine if all values in the container are true. More...
 
virtual void modify_ (void)
 Polymorphic modify method used by collection containers. More...
 

Private Attributes

ThreadSafeContextcontext_
 Variable context that we are modifying. More...
 
std::string delimiter_
 Delimiter for the prefix to subvars. More...
 
InternalMap map_
 Map of variables to values. More...
 

Detailed Description

This class stores a map of strings to KaRL variables.

Definition at line 32 of file Map.h.

Member Typedef Documentation

internal map of variable references

Definition at line 582 of file Map.h.

Constructor & Destructor Documentation

madara::knowledge::containers::Map::Map ( const KnowledgeUpdateSettings settings = KnowledgeUpdateSettings (),
const std::string &  delimiter = "." 
)

Default constructor.

Parameters
settingssettings to apply by default
delimiterthe delimiter for variables in the map

Definition at line 6 of file Map.cpp.

madara::knowledge::containers::Map::Map ( const std::string &  name,
KnowledgeBase knowledge,
const KnowledgeUpdateSettings settings = KnowledgeUpdateSettings (),
const std::string &  delimiter = "." 
)

Constructor.

Parameters
namethe name of the map within the variable context
knowledgethe variable context
settingssettings to apply by default
delimiterthe delimiter for variables in the map

Definition at line 13 of file Map.cpp.

madara::knowledge::containers::Map::Map ( const std::string &  name,
Variables knowledge,
const KnowledgeUpdateSettings settings = KnowledgeUpdateSettings (),
const std::string &  delimiter = "." 
)

Constructor.

Parameters
namethe name of the map within the variable context
knowledgethe variable context
settingssettings to apply by default
delimiterthe delimiter for variables in the map

Definition at line 37 of file Map.cpp.

madara::knowledge::containers::Map::Map ( const Map rhs)

Copy constructor.

Definition at line 62 of file Map.cpp.

madara::knowledge::containers::Map::~Map ( )
virtual

Destructor.

Definition at line 70 of file Map.cpp.

Member Function Documentation

void madara::knowledge::containers::Map::clear ( bool  clear_knowledge = true)

Clears the map.

Parameters
clear_knowledgeif true, clear the underlying knowledge base as well as the keys in the local map

Definition at line 372 of file Map.cpp.

madara::knowledge::containers::BaseContainer * madara::knowledge::containers::Map::clone ( void  ) const
virtual

Clones this container.

Returns
a deep copy of the container that must be managed by the user (i.e., you have to delete the return value)

Implements madara::knowledge::containers::BaseContainer.

Definition at line 145 of file Map.cpp.

void madara::knowledge::containers::Map::erase ( const std::string &  key)

Erases a variable from the map.

Parameters
keythe variable to delete from the map

Definition at line 393 of file Map.cpp.

void madara::knowledge::containers::Map::exchange ( Map other,
bool  refresh_keys = true,
bool  delete_keys = true 
)

Exchanges the map at this location with the map at another location.

Parameters
otherthe other integer to exchange with
refresh_keysforce a refresh of the keys in both maps to ensure all keys are swapped
delete_keysdelete any unused keys

Definition at line 259 of file Map.cpp.

bool madara::knowledge::containers::Map::exists ( const std::string &  key) const

Checks for the existence of a key.

Parameters
keymap key
Returns
true if key exists in map. False otherwise.

Definition at line 476 of file Map.cpp.

std::string madara::knowledge::containers::Map::get_debug_info ( void  )

Returns the type of the container along with name and any other useful information.

The provided information should be useful for developers wishing to debug container operations, especially as it pertains to pending network operations (i.e., when used in conjunction with modify)

Returns
info in format {container}: {name}{ = value, if appropriate}

Definition at line 92 of file Map.cpp.

std::string madara::knowledge::containers::Map::get_debug_info_ ( void  )
privatevirtual

Returns the type of the container along with name and any other useful information.

The provided information should be useful for developers wishing to debug container operations, especially as it pertains to pending network operations (i.e., when used in conjunction with modify)

Returns
info in format {container}: {name}{ = value, if appropriate}

Implements madara::knowledge::containers::BaseContainer.

Definition at line 139 of file Map.cpp.

std::string madara::knowledge::containers::Map::get_delimiter ( void  )

Gets the delimiter for adding and detecting subvariables.

By default, MADARA uses a '.' delimiter for names like "com.madara.Var1". Other conventions can include '/' for ROS-like topic directory structures, e.g., com/madara/Var1.

Returns
the delimiter to use for variable demarcation

Definition at line 470 of file Map.cpp.

std::string madara::knowledge::containers::BaseContainer::get_name ( void  ) const
inlineinherited

Returns the name of the container.

Returns
name of the container

Definition at line 5 of file BaseContainer.inl.

madara::knowledge::KnowledgeUpdateSettings madara::knowledge::containers::BaseContainer::get_settings ( void  )
inherited

Gets the update settings for the container.

Returns
the current settings

Definition at line 37 of file BaseContainer.cpp.

bool madara::knowledge::containers::Map::has_prefix ( const std::string &  prefix) const

Checks for the existence of a prefix in the keys.

Parameters
prefixthe first letters in a key
Returns
true if prefix exists in map. False otherwise.

Definition at line 495 of file Map.cpp.

bool madara::knowledge::containers::Map::is_false ( void  ) const

Determines if the value of the map is false.

Returns
true if at least one value is false

Definition at line 1453 of file Map.cpp.

bool madara::knowledge::containers::Map::is_false_ ( void  ) const
privatevirtual

Polymorphic is false method which can be used to determine if at least one value in the container is false.

Implements madara::knowledge::containers::BaseContainer.

Definition at line 1466 of file Map.cpp.

bool madara::knowledge::containers::Map::is_true ( void  ) const

Determines if all values in the map are true.

Returns
true if all values are true

Definition at line 1411 of file Map.cpp.

bool madara::knowledge::containers::Map::is_true_ ( void  ) const
privatevirtual

Polymorphic is true method which can be used to determine if all values in the container are true.

Implements madara::knowledge::containers::BaseContainer.

Definition at line 1460 of file Map.cpp.

void madara::knowledge::containers::Map::keys ( std::vector< std::string > &  curkeys) const

Returns the keys within the map.

Returns
keys used in the map

Definition at line 512 of file Map.cpp.

void madara::knowledge::containers::Map::modify ( void  )

Mark the vector as modified.

The map retains the same values but will resend values as if they had been modified.

Definition at line 76 of file Map.cpp.

void madara::knowledge::containers::Map::modify ( const std::string &  index)

Mark the value as modified.

The map element retains its value but will resend its value as if it had been modified.

Parameters
indexthe index to modify

Definition at line 151 of file Map.cpp.

void madara::knowledge::containers::Map::modify_ ( void  )
privatevirtual

Polymorphic modify method used by collection containers.

This method calls the modify method for this class. We separate the faster version (modify) from this version (modify_) to allow users the opportunity to have a fastery version that does not use polymorphic functions (generally virtual functions are half as efficient as normal function calls)

Implements madara::knowledge::containers::BaseContainer.

Definition at line 133 of file Map.cpp.

bool madara::knowledge::containers::BaseContainer::modify_if_false ( BaseContainer conditional)
virtualinherited

Modifies the container if the argument is false.

Parameters
conditionalthe container that must be false to modify
Returns
true if the container was modified

Definition at line 64 of file BaseContainer.cpp.

bool madara::knowledge::containers::BaseContainer::modify_if_true ( BaseContainer conditional)
virtualinherited

Modifies the container if the argument is true.

Parameters
conditionalthe container that must be true to modify
Returns
true if the container was modified

Definition at line 44 of file BaseContainer.cpp.

void madara::knowledge::containers::Map::operator= ( const Map rhs)

Assignment operator.

Parameters
rhsvalue to copy

Definition at line 162 of file Map.cpp.

madara::knowledge::KnowledgeRecord madara::knowledge::containers::Map::operator[] ( const std::string &  key)

Retrieves a copy of the record from the map.

Parameters
keythe name of the variable entry
Returns
the value of the entry. Modifications to this will not be reflected in the context. This is a local copy.

Definition at line 210 of file Map.cpp.

int madara::knowledge::containers::Map::read_file ( const std::string &  key,
const std::string &  filename 
)

Read a file into a location in the map.

Parameters
filenamefile to read
keykey to store the file into

Definition at line 530 of file Map.cpp.

int madara::knowledge::containers::Map::read_file ( const std::string &  key,
const std::string &  filename,
const KnowledgeUpdateSettings settings 
)

Read a file into a location in the map.

Parameters
filenamefile to read
keykey to store the file into
settingssettings to use when evaluating/updating

Definition at line 565 of file Map.cpp.

int madara::knowledge::containers::Map::set ( const std::string &  key,
madara::knowledge::KnowledgeRecord::Integer  value = madara::knowledge::KnowledgeRecord::MODIFIED 
)

Sets a location within the map to the specified value.

Parameters
keylocation within the map
valuevalue to set at location
Returns
0 if successful, -1 if key is null, and -2 if quality isn't high enough

Definition at line 601 of file Map.cpp.

int madara::knowledge::containers::Map::set ( const std::string &  key,
madara::knowledge::KnowledgeRecord::Integer  value,
const KnowledgeUpdateSettings settings 
)

Sets a location within the map to the specified value.

Parameters
keylocation within the map
valuevalue to set at location
settingssettings for applying the update
Returns
0 if successful, -1 if key is null, and -2 if quality isn't high enough

Definition at line 635 of file Map.cpp.

int madara::knowledge::containers::Map::set ( const std::string &  key,
const madara::knowledge::KnowledgeRecord::Integer value,
uint32_t  size 
)

Sets a location within the map to the specified value.

Parameters
keylocation within the map
valuearray of integers to set at the location
sizenumber of elements in the array
Returns
0 if successful, -1 if key is null, and -2 if quality isn't high enough

Definition at line 747 of file Map.cpp.

int madara::knowledge::containers::Map::set ( const std::string &  key,
const madara::knowledge::KnowledgeRecord::Integer value,
uint32_t  size,
const KnowledgeUpdateSettings settings 
)

Sets a location within the map to the specified value.

Parameters
keylocation within the map
valuearray of integers to set at the location
sizenumber of elements in the array
settingssettings for applying the update
Returns
0 if successful, -1 if key is null, and -2 if quality isn't high enough

Definition at line 783 of file Map.cpp.

int madara::knowledge::containers::Map::set ( const std::string &  key,
const std::vector< KnowledgeRecord::Integer > &  value 
)

Sets a location within the map to the specified value.

Parameters
keylocation within the map
valuearray of integers to set at the location
Returns
0 if successful, -1 if key is null, and -2 if quality isn't high enough

Definition at line 820 of file Map.cpp.

int madara::knowledge::containers::Map::set ( const std::string &  key,
const std::vector< KnowledgeRecord::Integer > &  value,
const KnowledgeUpdateSettings settings 
)

Sets a location within the map to the specified value.

Parameters
keylocation within the map
valuearray of integers to set at the location
settingssettings for applying the update
Returns
0 if successful, -1 if key is null, and -2 if quality isn't high enough

Definition at line 856 of file Map.cpp.

int madara::knowledge::containers::Map::set ( const std::string &  key,
double  value 
)

Sets a location within the map to the specified value.

Parameters
keylocation within the map
valuevalue to set at location
Returns
0 if successful, -1 if key is null, and -2 if quality isn't high enough

Definition at line 893 of file Map.cpp.

int madara::knowledge::containers::Map::set ( const std::string &  key,
double  value,
const KnowledgeUpdateSettings settings 
)

Sets a location within the map to the specified value.

Parameters
keylocation within the map
valuevalue to set at location
settingssettings for applying the update
Returns
0 if successful, -1 if key is null, and -2 if quality isn't high enough

Definition at line 929 of file Map.cpp.

int madara::knowledge::containers::Map::set ( const std::string &  key,
const double *  value,
uint32_t  size 
)

Sets a location within the map to the specified value.

Parameters
keylocation within the map
valuearray of doubles to set at the location
sizenumber of elements in the array
Returns
0 if successful, -1 if key is null, and -2 if quality isn't high enough

Definition at line 1039 of file Map.cpp.

int madara::knowledge::containers::Map::set ( const std::string &  key,
const double *  value,
uint32_t  size,
const KnowledgeUpdateSettings settings 
)

Sets a location within the map to the specified value.

Parameters
keylocation within the map
valuearray of doubles to set at the location
sizenumber of elements in the array
settingssettings for applying the update
Returns
0 if successful, -1 if key is null, and -2 if quality isn't high enough

Definition at line 1075 of file Map.cpp.

int madara::knowledge::containers::Map::set ( const std::string &  key,
const std::vector< double > &  value 
)

Sets a location within the map to the specified value.

Parameters
keylocation within the map
valuearray of doubles to set at the location
Returns
0 if successful, -1 if key is null, and -2 if quality isn't high enough

Definition at line 1110 of file Map.cpp.

int madara::knowledge::containers::Map::set ( const std::string &  key,
const std::vector< double > &  value,
const KnowledgeUpdateSettings settings 
)

Sets a location within the map to the specified value.

Parameters
keylocation within the map
valuearray of doubles to set at the location
settingssettings for applying the update
Returns
0 if successful, -1 if key is null, and -2 if quality isn't high enough

Definition at line 1145 of file Map.cpp.

int madara::knowledge::containers::Map::set ( const std::string &  key,
const std::string &  value 
)

Sets a location within the map to the specified value.

Parameters
keylocation within the map
valuevalue to set at location
Returns
0 if successful, -1 if key is null, and -2 if quality isn't high enough

Definition at line 1181 of file Map.cpp.

int madara::knowledge::containers::Map::set ( const std::string &  key,
const std::string &  value,
const KnowledgeUpdateSettings settings 
)

Sets a location within the map to the specified value.

Parameters
keylocation within the map
valuevalue to set at location
settingssettings for applying the update
Returns
0 if successful, -1 if key is null, and -2 if quality isn't high enough

Definition at line 1216 of file Map.cpp.

void madara::knowledge::containers::Map::set_delimiter ( const std::string &  delimiter,
bool  sync = true 
)

Sets the delimiter for adding and detecting subvariables.

By default, MADARA uses a '.' delimiter for names like "com.madara.Var1". Other conventions can include '/' for ROS-like topic directory structures, e.g., com/madara/Var1.

Parameters
delimiterthe delimiter to use for variable demarcation
syncsync the keys to existing vars in the new delimiter

Definition at line 453 of file Map.cpp.

int madara::knowledge::containers::Map::set_file ( const std::string &  key,
const unsigned char *  value,
size_t  size 
)

Atomically sets the value of an index to an arbitrary string.

Parameters
keykey to store the file into
valuenew value of the variable
sizeindicates the size of the value buffer
Returns
0 if the value was set. -1 if null key

Definition at line 1252 of file Map.cpp.

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

Atomically sets the value of an index to an arbitrary string.

Parameters
keykey to store the file into
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 1287 of file Map.cpp.

int madara::knowledge::containers::Map::set_index ( const std::string &  key,
size_t  index,
madara::knowledge::KnowledgeRecord::Integer  value 
)

Sets an index within an array to a specified value.

Parameters
keylocation within the map
indexindex of the location in the array
valuevalue to set at location
Returns
0 if successful, -1 if key is null, and -2 if quality isn't high enough

Definition at line 671 of file Map.cpp.

int madara::knowledge::containers::Map::set_index ( const std::string &  key,
size_t  index,
madara::knowledge::KnowledgeRecord::Integer  value,
const KnowledgeUpdateSettings settings 
)

Sets an index within an array to a specified value.

Parameters
keylocation within the map
indexindex of the location in the array
valuevalue to set at location
settingssettings for applying the update
Returns
0 if successful, -1 if key is null, and -2 if quality isn't high enough

Definition at line 708 of file Map.cpp.

int madara::knowledge::containers::Map::set_index ( const std::string &  key,
size_t  index,
double  value 
)

Sets an index within a map to a specified value.

Parameters
keylocation within the map
indexindex of the location in the array
valuevalue to set at location
Returns
0 if successful, -1 if key is null, and -2 if quality isn't high enough

Definition at line 965 of file Map.cpp.

int madara::knowledge::containers::Map::set_index ( const std::string &  key,
size_t  index,
double  value,
const KnowledgeUpdateSettings settings 
)

Sets an index within a map to a specified value.

Parameters
keylocation within the map
indexindex of the location in the array
valuevalue to set at location
settingssettings for applying the update
Returns
0 if successful, -1 if key is null, and -2 if quality isn't high enough

Definition at line 1002 of file Map.cpp.

int madara::knowledge::containers::Map::set_jpeg ( const std::string &  key,
const unsigned char *  value,
size_t  size 
)

Atomically sets the value of an index to a JPEG image.

Parameters
keyname of a variable
valuenew value of the variable
sizeindicates the size of the value buffer
Returns
0 if the value was set. -1 if null key

Definition at line 1321 of file Map.cpp.

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

Atomically sets the value of an index to a JPEG image.

Parameters
keyname of a 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 1356 of file Map.cpp.

void madara::knowledge::containers::Map::set_name ( const std::string &  var_name,
KnowledgeBase knowledge,
bool  sync = true 
)

Sets the variable name that this refers to.

Parameters
var_namethe name of the variable in the knowledge base
knowledgethe knowledge base the variable is housed in
syncsync the keys to existing vars in the new name

Definition at line 411 of file Map.cpp.

void madara::knowledge::containers::Map::set_name ( const std::string &  var_name,
Variables knowledge,
bool  sync = true 
)

Sets the variable name that this refers to.

Parameters
var_namethe name of the variable in the knowledge base
knowledgethe knowledge base the variable is housed in
syncsync the keys to existing vars in the new name

Definition at line 432 of file Map.cpp.

void madara::knowledge::containers::Map::set_quality ( const std::string &  key,
uint32_t  quality,
const KnowledgeReferenceSettings settings = KnowledgeReferenceSettings (false) 
)

Sets the quality of writing to a certain variable from this entity.

Parameters
keylocation within the map
qualityquality of writing to this location
settingssettings for referring to knowledge variables

Definition at line 1391 of file Map.cpp.

void madara::knowledge::containers::BaseContainer::set_settings ( const KnowledgeUpdateSettings settings)
inherited

Sets the update settings for the container.

Parameters
settingsthe new settings to use

Definition at line 28 of file BaseContainer.cpp.

size_t madara::knowledge::containers::Map::size ( void  ) const

Returns the size of the map.

Returns
size of the map

Definition at line 217 of file Map.cpp.

std::vector< std::string > madara::knowledge::containers::Map::sync_keys ( void  )

Syncs the keys from the knowledge base.

This can be useful if you expect other knowledge bases to add variables to the map.

Returns
a vector of the keys that were added during the sync

Definition at line 225 of file Map.cpp.

madara::knowledge::KnowledgeRecord madara::knowledge::containers::Map::to_record ( const std::string &  key)

Retrieves a copy of the record from the map.

Same functionality as operator[]. This is provided for convenience to match other containers way of converting to a record.

Parameters
keythe name of the variable entry
Returns
the value of the entry. Modifications to this will not be reflected in the context. This is a local copy.

Definition at line 177 of file Map.cpp.

Member Data Documentation

ThreadSafeContext* madara::knowledge::containers::Map::context_
private

Variable context that we are modifying.

Definition at line 587 of file Map.h.

std::string madara::knowledge::containers::Map::delimiter_
private

Delimiter for the prefix to subvars.

Definition at line 597 of file Map.h.

InternalMap madara::knowledge::containers::Map::map_
private

Map of variables to values.

Definition at line 592 of file Map.h.

MADARA_LOCK_TYPE madara::knowledge::containers::BaseContainer::mutex_
mutableprotectedinherited

guard for access and changes

Mutex for local changes

Definition at line 141 of file BaseContainer.h.

std::string madara::knowledge::containers::BaseContainer::name_
protectedinherited

Prefix of variable.

Definition at line 151 of file BaseContainer.h.

KnowledgeUpdateSettings madara::knowledge::containers::BaseContainer::settings_
protectedinherited

Settings for modifications.

Definition at line 156 of file BaseContainer.h.


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