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

Manages a 3D array of doubles as a virtual overlay in the KnowledgeBase. More...

#include <IntegerVector3D.h>

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

Classes

struct  Indices
 three dimensional indexing More...
 

Public Types

typedef Indices Dimensions
 convenience typedef for size More...
 
typedef KnowledgeRecord::Integer type
 convenience typedef for element type More...
 

Public Member Functions

 IntegerVector3D (const KnowledgeUpdateSettings &settings=KnowledgeUpdateSettings(), const std::string &delimiter=".")
 Default constructor. More...
 
 IntegerVector3D (const std::string &name, KnowledgeBase &knowledge, const Dimensions &dimensions={0, 0, 0}, bool delete_vars=true, const KnowledgeUpdateSettings &settings=KnowledgeUpdateSettings(), const std::string &delimiter=".")
 Constructor. More...
 
 IntegerVector3D (const std::string &name, Variables &knowledge, const Dimensions &dimensions={0, 0, 0}, bool delete_vars=true, const KnowledgeUpdateSettings &settings=KnowledgeUpdateSettings(), const std::string &delimiter=".")
 Constructor. More...
 
 IntegerVector3D (const IntegerVector3D &rhs)
 Copy constructor. More...
 
virtual ~IntegerVector3D ()
 Destructor. More...
 
virtual BaseContainerclone (void) const
 Clones this container. More...
 
void copy_to (std::vector< std::vector< std::vector< type > > > &target) const
 Copies the vector elements to an STL vector. More...
 
bool exists (const Indices &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 of vector. 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 (const Indices &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 IntegerVector3D &rhs)
 Assignment operator. More...
 
type operator[] (const Indices &index) const
 Retrieves an index from the multi-dimensional array. More...
 
void resize (const Dimensions &dimensions, bool delete_vars=true)
 Resizes the vector. More...
 
int set (const Indices &index, type value)
 Sets a knowledge variable to a specified value. More...
 
int set (const std::vector< std::vector< std::vector< type > > > &value)
 Reads values from a STL vector of doubles. More...
 
int set (const Indices &index, type value, const KnowledgeUpdateSettings &settings)
 Sets a knowledge variable to a specified value. More...
 
int set (const std::vector< std::vector< std::vector< type > > > &value, const KnowledgeUpdateSettings &settings)
 Reads values from a STL vector of doubles. More...
 
void set_delimiter (const std::string &delimiter)
 Sets the delimiter for adding and detecting subvariables. More...
 
void set_name (const std::string &var_name, KnowledgeBase &knowledge, const Dimensions &dimensions={0, 0, 0})
 Sets the variable name that this refers to. More...
 
void set_name (const std::string &var_name, Variables &knowledge, const Dimensions &dimensions={0, 0, 0})
 Sets the variable name that this refers to. More...
 
void set_name (const std::string &var_name, ThreadSafeContext &knowledge, const Dimensions &dimensions={0, 0, 0})
 Sets the variable name that this refers to. More...
 
void set_quality (const Indices &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...
 
Dimensions size (void) const
 Returns the size of the local vector. 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 of 2D array. More...
 
std::vector< std::vector< std::vector< VariableReference > > > vector_
 Values of the array. More...
 

Detailed Description

Manages a 3D array of doubles as a virtual overlay in the KnowledgeBase.

Definition at line 32 of file IntegerVector3D.h.

Member Typedef Documentation

convenience typedef for size

Definition at line 42 of file IntegerVector3D.h.

convenience typedef for element type

Definition at line 45 of file IntegerVector3D.h.

Constructor & Destructor Documentation

madara::knowledge::containers::IntegerVector3D::IntegerVector3D ( 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 IntegerVector3D.cpp.

madara::knowledge::containers::IntegerVector3D::IntegerVector3D ( const std::string &  name,
KnowledgeBase knowledge,
const Dimensions dimensions = {0,0,0},
bool  delete_vars = true,
const KnowledgeUpdateSettings settings = KnowledgeUpdateSettings (),
const std::string &  delimiter = "." 
)

Constructor.

Parameters
namename of the vector in the knowledge base
dimensionssize of the vector. {0,0,0} to check for size.
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 IntegerVector3D.cpp.

madara::knowledge::containers::IntegerVector3D::IntegerVector3D ( const std::string &  name,
Variables knowledge,
const Dimensions dimensions = {0,0,0},
bool  delete_vars = true,
const KnowledgeUpdateSettings settings = KnowledgeUpdateSettings (),
const std::string &  delimiter = "." 
)

Constructor.

Parameters
namename of the vector in the knowledge base
dimensionssize of the vector. {0,0,0} to check for size.
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 IntegerVector3D.cpp.

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

Copy constructor.

Definition at line 40 of file IntegerVector3D.cpp.

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

Destructor.

Definition at line 50 of file IntegerVector3D.cpp.

Member Function Documentation

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

void madara::knowledge::containers::IntegerVector3D::copy_to ( std::vector< std::vector< std::vector< type > > > &  target) const

Copies the vector elements to an STL vector.

Parameters
targetthe target of the copy operation

Definition at line 467 of file IntegerVector3D.cpp.

bool madara::knowledge::containers::IntegerVector3D::exists ( const Indices 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 546 of file IntegerVector3D.cpp.

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

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

std::string madara::knowledge::containers::IntegerVector3D::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 461 of file IntegerVector3D.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::IntegerVector3D::get_size_ref ( void  )

Returns a reference to the size of vector.

Returns
reference to the size field

Definition at line 172 of file IntegerVector3D.cpp.

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

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

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

Determines if all values in the vector are true.

Returns
true if all values are true

Definition at line 686 of file IntegerVector3D.cpp.

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

void madara::knowledge::containers::IntegerVector3D::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 56 of file IntegerVector3D.cpp.

void madara::knowledge::containers::IntegerVector3D::modify ( const Indices 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 142 of file IntegerVector3D.cpp.

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

Assignment operator.

Parameters
rhsvalue to copy

Definition at line 155 of file IntegerVector3D.cpp.

madara::knowledge::containers::IntegerVector3D::type madara::knowledge::containers::IntegerVector3D::operator[] ( const Indices index) const

Retrieves an index from the multi-dimensional array.

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 497 of file IntegerVector3D.cpp.

void madara::knowledge::containers::IntegerVector3D::resize ( const Dimensions dimensions,
bool  delete_vars = true 
)

Resizes the vector.

Parameters
dimensionsmaximum size of the vector. Can be -1 to check the knowledge base for size information)
delete_varsdelete indices outside of the specified range

Definition at line 194 of file IntegerVector3D.cpp.

int madara::knowledge::containers::IntegerVector3D::set ( const Indices index,
type  value 
)

Sets a knowledge variable to a specified value.

Parameters
indexlocation index 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 567 of file IntegerVector3D.cpp.

int madara::knowledge::containers::IntegerVector3D::set ( const std::vector< std::vector< std::vector< type > > > &  value)

Reads values from a STL vector of doubles.

Parameters
valuearray of doubles to set at the location
Returns
always returns 0

Definition at line 591 of file IntegerVector3D.cpp.

int madara::knowledge::containers::IntegerVector3D::set ( const Indices index,
type  value,
const KnowledgeUpdateSettings settings 
)

Sets a knowledge variable to a specified value.

Parameters
indexlocation index 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 617 of file IntegerVector3D.cpp.

int madara::knowledge::containers::IntegerVector3D::set ( const std::vector< std::vector< std::vector< type > > > &  value,
const KnowledgeUpdateSettings settings 
)

Reads values from a STL vector of doubles.

Parameters
valuearray of doubles to set at the location
settingssettings for applying the update
Returns
always returns 0

Definition at line 641 of file IntegerVector3D.cpp.

void madara::knowledge::containers::IntegerVector3D::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 446 of file IntegerVector3D.cpp.

void madara::knowledge::containers::IntegerVector3D::set_name ( const std::string &  var_name,
KnowledgeBase knowledge,
const Dimensions dimensions = {0,0,0} 
)

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
dimensionssize of the new vector ({0,0,0} to not change size)

Definition at line 389 of file IntegerVector3D.cpp.

void madara::knowledge::containers::IntegerVector3D::set_name ( const std::string &  var_name,
Variables knowledge,
const Dimensions dimensions = {0,0,0} 
)

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
dimensionssize of the new vector ({0,0,0} to not change size)

Definition at line 410 of file IntegerVector3D.cpp.

void madara::knowledge::containers::IntegerVector3D::set_name ( const std::string &  var_name,
ThreadSafeContext knowledge,
const Dimensions dimensions = {0,0,0} 
)

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
dimensionssize of the new vector ({0,0,0} to not change size)

Definition at line 428 of file IntegerVector3D.cpp.

void madara::knowledge::containers::IntegerVector3D::set_quality ( const Indices 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 668 of file IntegerVector3D.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.

madara::knowledge::containers::IntegerVector3D::Indices madara::knowledge::containers::IntegerVector3D::size ( void  ) const

Returns the size of the local vector.

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

Returns
MxN size of the vector

Definition at line 365 of file IntegerVector3D.cpp.

Member Data Documentation

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

Variable context that we are modifying.

Definition at line 331 of file IntegerVector3D.h.

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

Delimiter for the prefix to subvars.

Definition at line 346 of file IntegerVector3D.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::IntegerVector3D::size_
private

Reference to the size of 2D array.

Definition at line 341 of file IntegerVector3D.h.

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

Values of the array.

Definition at line 336 of file IntegerVector3D.h.


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