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

This class stores a vector of KaRL variables. More...

#include <Vector.h>

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

Public Member Functions

 Vector (const KnowledgeUpdateSettings &settings=KnowledgeUpdateSettings(), const std::string &delimiter=".")
 Default constructor. More...
 
 Vector (const std::string &name, KnowledgeBase &knowledge, int size=-1, bool delete_vars=true, const KnowledgeUpdateSettings &settings=KnowledgeUpdateSettings(), const std::string &delimiter=".")
 Constructor. More...
 
 Vector (const std::string &name, Variables &knowledge, int size=-1, bool delete_vars=true, const KnowledgeUpdateSettings &settings=KnowledgeUpdateSettings(), const std::string &delimiter=".")
 Constructor. More...
 
 Vector (const Vector &rhs)
 Copy constructor. More...
 
virtual ~Vector ()
 Destructor. More...
 
virtual BaseContainerclone (void) const
 Clones this container. More...
 
void copy_to (KnowledgeVector &target) const
 Copies the vector elements to an STL vector of Knowledge Records. More...
 
void exchange (Vector &other, bool refresh_keys=true, bool delete_keys=true)
 Exchanges the vector at this location with the vector at another location. More...
 
bool exists (size_t index) const
 Checks to see if the index has ever been assigned a value. 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...
 
VariableReference get_size_ref (void)
 Returns a reference to the size field of the current name. More...
 
bool is_false (void) const
 Determines if the value of the vector is false. More...
 
bool is_true (void) const
 Determines if all values in the vector are true. More...
 
void modify (void)
 Mark the vector as modified. More...
 
void modify (size_t 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 Vector &rhs)
 Assignment operator. More...
 
knowledge::KnowledgeRecord operator[] (size_t index) const
 Retrieves a copy of the record from the map. More...
 
void push_back (KnowledgeRecord value)
 Pushes the value to the end of the array after incrementing the array size. More...
 
int read_file (size_t index, const std::string &filename)
 Read a file into the index. More...
 
int read_file (size_t index, const std::string &filename, const KnowledgeUpdateSettings &settings)
 Read a file into the index. More...
 
void resize (int size=-1, bool delete_vars=true)
 Resizes the vector. More...
 
int set (size_t index, madara::knowledge::KnowledgeRecord::Integer value=madara::knowledge::KnowledgeRecord::MODIFIED)
 Sets a knowledge variable to a specified value. More...
 
int set (size_t index, madara::knowledge::KnowledgeRecord::Integer value, const KnowledgeUpdateSettings &settings)
 Sets a knowledge variable to a specified value. More...
 
int set (size_t index, const madara::knowledge::KnowledgeRecord::Integer *value, uint32_t size)
 Sets a knowledge variable to a specified value. More...
 
int set (size_t index, const madara::knowledge::KnowledgeRecord::Integer *value, uint32_t size, const KnowledgeUpdateSettings &settings)
 Sets a knowledge variable to a specified value. More...
 
int set (size_t index, const std::vector< KnowledgeRecord::Integer > &value)
 Sets a knowledge variable to a specified value. More...
 
int set (size_t index, const std::vector< KnowledgeRecord::Integer > &value, const KnowledgeUpdateSettings &settings)
 Sets a knowledge variable to a specified value. More...
 
int set (size_t index, double value)
 Sets a knowledge variable to a specified value. More...
 
int set (size_t index, double value, const KnowledgeUpdateSettings &settings)
 Sets a knowledge variable to a specified value. More...
 
int set (size_t index, const double *value, uint32_t size)
 Sets a knowledge variable to a specified value. More...
 
int set (size_t index, const double *value, uint32_t size, const KnowledgeUpdateSettings &settings)
 Sets a knowledge variable to a specified value. More...
 
int set (size_t index, const std::vector< double > &value)
 Sets a knowledge variable to a specified value. More...
 
int set (size_t index, const std::vector< double > &value, const KnowledgeUpdateSettings &settings)
 Sets a knowledge variable to a specified value. More...
 
int set (size_t index, const std::string &value)
 Sets a knowledge variable to a specified value. More...
 
int set (size_t index, const std::string &value, const KnowledgeUpdateSettings &settings)
 Sets a knowledge variable to a specified value. More...
 
void set_delimiter (const std::string &delimiter)
 Sets the delimiter for adding and detecting subvariables. More...
 
int set_file (size_t index, const unsigned char *value, size_t size)
 Atomically sets the value of an index to an arbitrary string. More...
 
int set_file (size_t index, 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 (size_t index, size_t sub_index, madara::knowledge::KnowledgeRecord::Integer value)
 Sets an index within an array to a specified value. More...
 
int set_index (size_t index, size_t sub_index, madara::knowledge::KnowledgeRecord::Integer value, const KnowledgeUpdateSettings &settings)
 Sets an index within an array to a specified value. More...
 
int set_index (size_t index, size_t sub_index, double value)
 Sets an index within an array to a specified value. More...
 
int set_index (size_t index, size_t sub_index, double value, const KnowledgeUpdateSettings &settings)
 Sets an index within an array to a specified value. More...
 
int set_jpeg (size_t index, const unsigned char *value, size_t size)
 Atomically sets the value of an index to a JPEG image. More...
 
int set_jpeg (size_t index, 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, int size=-1)
 Sets the variable name that this refers to. More...
 
void set_name (const std::string &var_name, Variables &knowledge, int size=-1)
 Sets the variable name that this refers to. More...
 
void set_name (const std::string &var_name, ThreadSafeContext &knowledge, int size=-1)
 Sets the variable name that this refers to. More...
 
void set_quality (size_t index, 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 local vector. More...
 
knowledge::KnowledgeRecord to_record (size_t index) const
 Retrieves a copy of the record from the map. More...
 
void transfer_to (Vector &other)
 Transfers elements from this vector to another. 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 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...
 
VariableReference size_
 Reference to the size field of the vector space. More...
 
std::vector< VariableReferencevector_
 Values of the array. More...
 

Friends

class Queue
 Allow the Queue class to manipulate variables. More...
 

Detailed Description

This class stores a vector of KaRL variables.

Definition at line 35 of file Vector.h.

Constructor & Destructor Documentation

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

Default constructor.

Parameters
settingssettings for evaluating the vector
delimiterthe delimiter for variables in the vector

Definition at line 5 of file Vector.cpp.

madara::knowledge::containers::Vector::Vector ( const std::string &  name,
KnowledgeBase knowledge,
int  size = -1,
bool  delete_vars = true,
const KnowledgeUpdateSettings settings = KnowledgeUpdateSettings (),
const std::string &  delimiter = "." 
)

Constructor.

Parameters
namename of the vector in the knowledge base
sizesize of the vector. -1 will check knowledge base for size information
knowledgethe knowledge base that will contain the vector
delete_varsdelete indices outside of the specified range
settingssettings for evaluating the vector
delimiterthe delimiter for variables in the vector

Definition at line 12 of file Vector.cpp.

madara::knowledge::containers::Vector::Vector ( const std::string &  name,
Variables knowledge,
int  size = -1,
bool  delete_vars = true,
const KnowledgeUpdateSettings settings = KnowledgeUpdateSettings (),
const std::string &  delimiter = "." 
)

Constructor.

Parameters
namename of the vector in the knowledge base
sizesize of the vector. -1 will check knowledge base for size information
knowledgethe knowledge base that will contain the vector
delete_varsdelete indices outside of the specified range
settingssettings for evaluating the vector
delimiterthe delimiter for variables in the vector

Definition at line 26 of file Vector.cpp.

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

Copy constructor.

Definition at line 40 of file Vector.cpp.

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

Destructor.

Definition at line 50 of file Vector.cpp.

Member Function Documentation

madara::knowledge::containers::BaseContainer * madara::knowledge::containers::Vector::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 116 of file Vector.cpp.

void madara::knowledge::containers::Vector::copy_to ( KnowledgeVector target) const

Copies the vector elements to an STL vector of Knowledge Records.

Parameters
targetrecord values at this instance

Definition at line 512 of file Vector.cpp.

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

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

Parameters
otherthe other vector 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 399 of file Vector.cpp.

bool madara::knowledge::containers::Vector::exists ( size_t  index) const

Checks to see if the index has ever been assigned a value.

Parameters
indexthe index of the variable entry
Returns
true if the record has been set to a value. False is uninitialized

Definition at line 563 of file Vector.cpp.

std::string madara::knowledge::containers::Vector::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 70 of file Vector.cpp.

std::string madara::knowledge::containers::Vector::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 110 of file Vector.cpp.

std::string madara::knowledge::containers::Vector::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 393 of file Vector.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.

madara::knowledge::VariableReference madara::knowledge::containers::Vector::get_size_ref ( void  )

Returns a reference to the size field of the current name.

Returns
reference to the size field

Definition at line 151 of file Vector.cpp.

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

Determines if the value of the vector is false.

Returns
true if at least one value is false

Definition at line 1068 of file Vector.cpp.

bool madara::knowledge::containers::Vector::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 1081 of file Vector.cpp.

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

Determines if all values in the vector are true.

Returns
true if all values are true

Definition at line 1022 of file Vector.cpp.

bool madara::knowledge::containers::Vector::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 1075 of file Vector.cpp.

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

Mark the vector as modified.

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

Definition at line 55 of file Vector.cpp.

void madara::knowledge::containers::Vector::modify ( size_t  index)

Mark the value as modified.

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

Parameters
indexthe index to modify

Definition at line 122 of file Vector.cpp.

void madara::knowledge::containers::Vector::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 104 of file Vector.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::Vector::operator= ( const Vector rhs)

Assignment operator.

Parameters
rhsvalue to copy

Definition at line 134 of file Vector.cpp.

madara::knowledge::KnowledgeRecord madara::knowledge::containers::Vector::operator[] ( size_t  index) const

Retrieves a copy of the record from the map.

Parameters
indexthe index 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 530 of file Vector.cpp.

void madara::knowledge::containers::Vector::push_back ( knowledge::KnowledgeRecord  value)

Pushes the value to the end of the array after incrementing the array size.

Parameters
valuethe value to place at the end of the array

Definition at line 173 of file Vector.cpp.

int madara::knowledge::containers::Vector::read_file ( size_t  index,
const std::string &  filename 
)

Read a file into the index.

Parameters
filenamefile to read
indexindex within vector

Definition at line 579 of file Vector.cpp.

int madara::knowledge::containers::Vector::read_file ( size_t  index,
const std::string &  filename,
const KnowledgeUpdateSettings settings 
)

Read a file into the index.

Parameters
filenamefile to read
indexindex within vector
settingssettings to use when evaluating/updating

Definition at line 596 of file Vector.cpp.

void madara::knowledge::containers::Vector::resize ( int  size = -1,
bool  delete_vars = true 
)

Resizes the vector.

Parameters
sizesize of the vector. -1 will check knowledge base for size information
delete_varsdelete indices outside of the specified range

Definition at line 221 of file Vector.cpp.

int madara::knowledge::containers::Vector::set ( size_t  index,
madara::knowledge::KnowledgeRecord::Integer  value = madara::knowledge::KnowledgeRecord::MODIFIED 
)

Sets a knowledge variable to a specified value.

Parameters
indexindex to set
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 683 of file Vector.cpp.

int madara::knowledge::containers::Vector::set ( size_t  index,
madara::knowledge::KnowledgeRecord::Integer  value,
const KnowledgeUpdateSettings settings 
)

Sets a knowledge variable to a specified value.

Parameters
indexindex to set
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 700 of file Vector.cpp.

int madara::knowledge::containers::Vector::set ( size_t  index,
const madara::knowledge::KnowledgeRecord::Integer value,
uint32_t  size 
)

Sets a knowledge variable to a specified value.

Parameters
indexindex to set
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 755 of file Vector.cpp.

int madara::knowledge::containers::Vector::set ( size_t  index,
const madara::knowledge::KnowledgeRecord::Integer value,
uint32_t  size,
const KnowledgeUpdateSettings settings 
)

Sets a knowledge variable to a specified value.

Parameters
indexindex to set
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 773 of file Vector.cpp.

int madara::knowledge::containers::Vector::set ( size_t  index,
const std::vector< KnowledgeRecord::Integer > &  value 
)

Sets a knowledge variable to a specified value.

Parameters
indexindex to set
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 792 of file Vector.cpp.

int madara::knowledge::containers::Vector::set ( size_t  index,
const std::vector< KnowledgeRecord::Integer > &  value,
const KnowledgeUpdateSettings settings 
)

Sets a knowledge variable to a specified value.

Parameters
indexindex to set
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 809 of file Vector.cpp.

int madara::knowledge::containers::Vector::set ( size_t  index,
double  value 
)

Sets a knowledge variable to a specified value.

Parameters
indexindex to set
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 827 of file Vector.cpp.

int madara::knowledge::containers::Vector::set ( size_t  index,
double  value,
const KnowledgeUpdateSettings settings 
)

Sets a knowledge variable to a specified value.

Parameters
indexindex to set
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 844 of file Vector.cpp.

int madara::knowledge::containers::Vector::set ( size_t  index,
const double *  value,
uint32_t  size 
)

Sets a knowledge variable to a specified value.

Parameters
indexindex to set
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 899 of file Vector.cpp.

int madara::knowledge::containers::Vector::set ( size_t  index,
const double *  value,
uint32_t  size,
const KnowledgeUpdateSettings settings 
)

Sets a knowledge variable to a specified value.

Parameters
indexindex to set
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 917 of file Vector.cpp.

int madara::knowledge::containers::Vector::set ( size_t  index,
const std::vector< double > &  value 
)

Sets a knowledge variable to a specified value.

Parameters
indexindex to set
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 936 of file Vector.cpp.

int madara::knowledge::containers::Vector::set ( size_t  index,
const std::vector< double > &  value,
const KnowledgeUpdateSettings settings 
)

Sets a knowledge variable to a specified value.

Parameters
indexindex to set
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 953 of file Vector.cpp.

int madara::knowledge::containers::Vector::set ( size_t  index,
const std::string &  value 
)

Sets a knowledge variable to a specified value.

Parameters
indexindex to set
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 971 of file Vector.cpp.

int madara::knowledge::containers::Vector::set ( size_t  index,
const std::string &  value,
const KnowledgeUpdateSettings settings 
)

Sets a knowledge variable to a specified value.

Parameters
indexindex to set
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 988 of file Vector.cpp.

void madara::knowledge::containers::Vector::set_delimiter ( const std::string &  delimiter)

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

Definition at line 377 of file Vector.cpp.

int madara::knowledge::containers::Vector::set_file ( size_t  index,
const unsigned char *  value,
size_t  size 
)

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

Parameters
indexindex within vector
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 614 of file Vector.cpp.

int madara::knowledge::containers::Vector::set_file ( size_t  index,
const unsigned char *  value,
size_t  size,
const KnowledgeUpdateSettings settings 
)

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

Parameters
indexindex within vector
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 631 of file Vector.cpp.

int madara::knowledge::containers::Vector::set_index ( size_t  index,
size_t  sub_index,
madara::knowledge::KnowledgeRecord::Integer  value 
)

Sets an index within an array to a specified value.

Parameters
indexindex to set in the variable
sub_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 718 of file Vector.cpp.

int madara::knowledge::containers::Vector::set_index ( size_t  index,
size_t  sub_index,
madara::knowledge::KnowledgeRecord::Integer  value,
const KnowledgeUpdateSettings settings 
)

Sets an index within an array to a specified value.

Parameters
indexindex to set in the variable
sub_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 736 of file Vector.cpp.

int madara::knowledge::containers::Vector::set_index ( size_t  index,
size_t  sub_index,
double  value 
)

Sets an index within an array to a specified value.

Parameters
indexindex to set within the variable
sub_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 862 of file Vector.cpp.

int madara::knowledge::containers::Vector::set_index ( size_t  index,
size_t  sub_index,
double  value,
const KnowledgeUpdateSettings settings 
)

Sets an index within an array to a specified value.

Parameters
indexindex to set within the variable
sub_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 880 of file Vector.cpp.

int madara::knowledge::containers::Vector::set_jpeg ( size_t  index,
const unsigned char *  value,
size_t  size 
)

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

Parameters
indexindex of the variable to set
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 649 of file Vector.cpp.

int madara::knowledge::containers::Vector::set_jpeg ( size_t  index,
const unsigned char *  value,
size_t  size,
const KnowledgeUpdateSettings settings 
)

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

Parameters
indexindex of the variable to set
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 666 of file Vector.cpp.

void madara::knowledge::containers::Vector::set_name ( const std::string &  var_name,
KnowledgeBase knowledge,
int  size = -1 
)

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
sizesize of the new vector (-1 to not change size)

Definition at line 317 of file Vector.cpp.

void madara::knowledge::containers::Vector::set_name ( const std::string &  var_name,
Variables knowledge,
int  size = -1 
)

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
sizesize of the new vector (-1 to not change size)

Definition at line 339 of file Vector.cpp.

void madara::knowledge::containers::Vector::set_name ( const std::string &  var_name,
ThreadSafeContext knowledge,
int  size = -1 
)

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
sizesize of the new vector (-1 to not change size)

Definition at line 358 of file Vector.cpp.

void madara::knowledge::containers::Vector::set_quality ( size_t  index,
uint32_t  quality,
const KnowledgeReferenceSettings settings = KnowledgeReferenceSettings (false) 
)

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

Parameters
indexindex to set
qualityquality of writing to this location
settingssettings for referring to knowledge variables

Definition at line 1006 of file Vector.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::Vector::size ( void  ) const

Returns the size of the local vector.

Call resize() first without arguments to ensure local vector matches data in KnowledgeBase.

Returns
size of the vector

Definition at line 310 of file Vector.cpp.

madara::knowledge::KnowledgeRecord madara::knowledge::containers::Vector::to_record ( size_t  index) const

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
indexthe index 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 547 of file Vector.cpp.

void madara::knowledge::containers::Vector::transfer_to ( Vector other)

Transfers elements from this vector to another.

Parameters
otherthe other vector to transfer to

Definition at line 487 of file Vector.cpp.

Friends And Related Function Documentation

friend class Queue
friend

Allow the Queue class to manipulate variables.

Definition at line 39 of file Vector.h.

Member Data Documentation

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

Variable context that we are modifying.

Definition at line 607 of file Vector.h.

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

Delimiter for the prefix to subvars.

Definition at line 622 of file Vector.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.

VariableReference madara::knowledge::containers::Vector::size_
private

Reference to the size field of the vector space.

Definition at line 617 of file Vector.h.

std::vector<VariableReference> madara::knowledge::containers::Vector::vector_
private

Values of the array.

Definition at line 612 of file Vector.h.


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