MADARA  3.4.1
madara::knowledge::containers::NativeIntegerVectorStaged Class Reference

This class stores a vector of doubles inside of KaRL. More...

#include <NativeIntegerVectorStaged.h>

Inheritance diagram for madara::knowledge::containers::NativeIntegerVectorStaged:
madara::knowledge::containers::BaseContainer

Public Types

typedef knowledge::KnowledgeRecord::Integer type
 trait that describes the value type More...
 

Public Member Functions

 NativeIntegerVectorStaged (const KnowledgeUpdateSettings &settings=KnowledgeUpdateSettings())
 Default constructor. More...
 
 NativeIntegerVectorStaged (const NativeIntegerVectorStaged &rhs)
 Copy constructor. More...
 
 NativeIntegerVectorStaged (const std::string &name, KnowledgeBase &knowledge, int size=-1, const KnowledgeUpdateSettings &settings=KnowledgeUpdateSettings())
 Constructor. More...
 
 NativeIntegerVectorStaged (const std::string &name, Variables &knowledge, int size=-1, const KnowledgeUpdateSettings &settings=KnowledgeUpdateSettings())
 Constructor. More...
 
virtual ~NativeIntegerVectorStaged ()
 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 (NativeIntegerVectorStaged &other)
 Exchanges the vector at this location with the vector at another location. 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_name (void) const
 Returns the name of the container. More...
 
KnowledgeUpdateSettings get_settings (void)
 Gets the update settings for the container. 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 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 NativeIntegerVectorStaged &rhs)
 Assignment operator. More...
 
void operator= (const std::vector< type > &rhs)
 Assignment operator. More...
 
type operator[] (size_t index) const
 Retrieves a copy of the record from the map. More...
 
void push_back (type value)
 Pushes the value to the end of the array after incrementing the array size. More...
 
void read (void)
 Reads the value from the knowledge base. More...
 
void resize (size_t size)
 Resizes the vector. More...
 
void set (const std::vector< type > &value)
 Reads values from a STL vector of doubles. More...
 
void set (size_t index, type value)
 Sets a knowledge variable to a specified value. More...
 
void set_name (const std::string &var_name, KnowledgeBase &knowledge, int size=-1, bool sync=true)
 Sets the variable name that this refers to. More...
 
void set_name (const std::string &var_name, ThreadSafeContext &knowledge, int size=-1, bool sync=true)
 Sets the variable name that this refers to. More...
 
void set_name (const std::string &var_name, Variables &knowledge, int size=-1, bool sync=true)
 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 vector. More...
 
knowledge::KnowledgeRecord to_record (size_t index) const
 Retrieves a copy of the record from the vector. More...
 
knowledge::KnowledgeRecord to_record (void) const
 Retrieves the entire vector as a native double array in a record. More...
 
void transfer_to (NativeIntegerVectorStaged &other)
 Transfers elements from this vector to another. More...
 
void write (void)
 Writes the value to the knowledge base. 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...
 
bool has_changed_
 Tracks if value_ has changed since last read. More...
 
KnowledgeRecord value_
 The staged value of the vector. More...
 
VariableReference vector_
 Reference to the size field of the vector space. More...
 

Detailed Description

This class stores a vector of doubles inside of KaRL.

Definition at line 31 of file NativeIntegerVectorStaged.h.

Member Typedef Documentation

◆ type

Constructor & Destructor Documentation

◆ NativeIntegerVectorStaged() [1/4]

madara::knowledge::containers::NativeIntegerVectorStaged::NativeIntegerVectorStaged ( const KnowledgeUpdateSettings settings = KnowledgeUpdateSettings())

Default constructor.

Parameters
settingssettings for evaluating the vector

Definition at line 4 of file NativeIntegerVectorStaged.cpp.

◆ NativeIntegerVectorStaged() [2/4]

madara::knowledge::containers::NativeIntegerVectorStaged::NativeIntegerVectorStaged ( const std::string &  name,
KnowledgeBase knowledge,
int  size = -1,
const KnowledgeUpdateSettings settings = KnowledgeUpdateSettings() 
)

Constructor.

Parameters
namename of the vector in the knowledge base
sizesize of the vector
knowledgethe knowledge base that will contain the vector
settingssettings for evaluating the vector

Definition at line 12 of file NativeIntegerVectorStaged.cpp.

◆ NativeIntegerVectorStaged() [3/4]

madara::knowledge::containers::NativeIntegerVectorStaged::NativeIntegerVectorStaged ( const std::string &  name,
Variables knowledge,
int  size = -1,
const KnowledgeUpdateSettings settings = KnowledgeUpdateSettings() 
)

Constructor.

Parameters
namename of the vector in the knowledge base
sizesize of the vector
knowledgethe knowledge base that will contain the vector
settingssettings for evaluating the vector

Definition at line 30 of file NativeIntegerVectorStaged.cpp.

◆ NativeIntegerVectorStaged() [4/4]

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

Copy constructor.

Definition at line 48 of file NativeIntegerVectorStaged.cpp.

◆ ~NativeIntegerVectorStaged()

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

Destructor.

Definition at line 60 of file NativeIntegerVectorStaged.cpp.

Member Function Documentation

◆ clone()

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

◆ copy_to()

void madara::knowledge::containers::NativeIntegerVectorStaged::copy_to ( KnowledgeVector target) const
inline

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

Parameters
targetrecord values at this instance

Definition at line 215 of file NativeIntegerVectorStaged.inl.

◆ exchange()

void madara::knowledge::containers::NativeIntegerVectorStaged::exchange ( NativeIntegerVectorStaged other)
inline

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

Parameters
otherthe other vector to exchange with

Definition at line 171 of file NativeIntegerVectorStaged.inl.

◆ get_debug_info()

std::string madara::knowledge::containers::NativeIntegerVectorStaged::get_debug_info ( void  )
inline

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 19 of file NativeIntegerVectorStaged.inl.

◆ get_debug_info_()

std::string madara::knowledge::containers::NativeIntegerVectorStaged::get_debug_info_ ( void  )
inlineprivatevirtual

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 36 of file NativeIntegerVectorStaged.inl.

◆ get_name()

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 4 of file BaseContainer.inl.

◆ get_settings()

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 29 of file BaseContainer.cpp.

◆ is_false()

bool madara::knowledge::containers::NativeIntegerVectorStaged::is_false ( void  ) const
inline

Determines if the value of the vector is false.

Returns
true if at least one value is false

Definition at line 299 of file NativeIntegerVectorStaged.inl.

◆ is_false_()

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

◆ is_true()

bool madara::knowledge::containers::NativeIntegerVectorStaged::is_true ( void  ) const
inline

Determines if all values in the vector are true.

Returns
true if all values are true

Definition at line 283 of file NativeIntegerVectorStaged.inl.

◆ is_true_()

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

◆ modify()

void madara::knowledge::containers::NativeIntegerVectorStaged::modify ( void  )
inline

Mark the value as modified.

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

Definition at line 8 of file NativeIntegerVectorStaged.inl.

◆ modify_()

void madara::knowledge::containers::NativeIntegerVectorStaged::modify_ ( void  )
inlineprivatevirtual

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 88 of file NativeIntegerVectorStaged.cpp.

◆ modify_if_false()

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 56 of file BaseContainer.cpp.

◆ modify_if_true()

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 36 of file BaseContainer.cpp.

◆ operator=() [1/2]

void madara::knowledge::containers::NativeIntegerVectorStaged::operator= ( const NativeIntegerVectorStaged rhs)
inline

Assignment operator.

Parameters
rhsvalue to copy

Definition at line 41 of file NativeIntegerVectorStaged.inl.

◆ operator=() [2/2]

void madara::knowledge::containers::NativeIntegerVectorStaged::operator= ( const std::vector< type > &  rhs)
inline

Assignment operator.

Parameters
rhsvalue to copy

Definition at line 57 of file NativeIntegerVectorStaged.inl.

◆ operator[]()

madara::knowledge::containers::NativeIntegerVectorStaged::type madara::knowledge::containers::NativeIntegerVectorStaged::operator[] ( size_t  index) const
inline

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 227 of file NativeIntegerVectorStaged.inl.

◆ push_back()

void madara::knowledge::containers::NativeIntegerVectorStaged::push_back ( type  value)
inline

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 66 of file NativeIntegerVectorStaged.inl.

◆ read()

void madara::knowledge::containers::NativeIntegerVectorStaged::read ( void  )
inline

Reads the value from the knowledge base.

Definition at line 305 of file NativeIntegerVectorStaged.inl.

◆ resize()

void madara::knowledge::containers::NativeIntegerVectorStaged::resize ( size_t  size)
inline

Resizes the vector.

Parameters
sizemaximum size of the vector

Definition at line 77 of file NativeIntegerVectorStaged.inl.

◆ set() [1/2]

void madara::knowledge::containers::NativeIntegerVectorStaged::set ( const std::vector< type > &  value)
inline

Reads values from a STL vector of doubles.

Parameters
valuearray of doubles to set at the location

Definition at line 246 of file NativeIntegerVectorStaged.inl.

◆ set() [2/2]

void madara::knowledge::containers::NativeIntegerVectorStaged::set ( size_t  index,
type  value 
)
inline

Sets a knowledge variable to a specified value.

Parameters
indexindex to set
valuevalue to set at location

Definition at line 237 of file NativeIntegerVectorStaged.inl.

◆ set_name() [1/3]

void madara::knowledge::containers::NativeIntegerVectorStaged::set_name ( const std::string &  var_name,
KnowledgeBase knowledge,
int  size = -1,
bool  sync = true 
)
inline

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)
syncsynchronize the value from the underlying knowledge

Definition at line 92 of file NativeIntegerVectorStaged.inl.

◆ set_name() [2/3]

void madara::knowledge::containers::NativeIntegerVectorStaged::set_name ( const std::string &  var_name,
ThreadSafeContext knowledge,
int  size = -1,
bool  sync = true 
)
inline

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)
syncsynchronize the value from the underlying knowledge

Definition at line 144 of file NativeIntegerVectorStaged.inl.

◆ set_name() [3/3]

void madara::knowledge::containers::NativeIntegerVectorStaged::set_name ( const std::string &  var_name,
Variables knowledge,
int  size = -1,
bool  sync = true 
)
inline

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)
syncsynchronize the value from the underlying knowledge

Definition at line 118 of file NativeIntegerVectorStaged.inl.

◆ set_quality()

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

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 256 of file NativeIntegerVectorStaged.inl.

◆ set_settings()

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 20 of file BaseContainer.cpp.

◆ size()

size_t madara::knowledge::containers::NativeIntegerVectorStaged::size ( void  ) const
inline

Returns the size of the vector.

Returns
size of the vector

Definition at line 86 of file NativeIntegerVectorStaged.inl.

◆ to_record() [1/2]

madara::knowledge::KnowledgeRecord madara::knowledge::containers::NativeIntegerVectorStaged::to_record ( size_t  index) const
inline

Retrieves a copy of the record from the vector.

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 269 of file NativeIntegerVectorStaged.inl.

◆ to_record() [2/2]

madara::knowledge::KnowledgeRecord madara::knowledge::containers::NativeIntegerVectorStaged::to_record ( void  ) const
inline

Retrieves the entire vector as a native double array in a record.

Returns
the vector in native double array format

Definition at line 278 of file NativeIntegerVectorStaged.inl.

◆ transfer_to()

void madara::knowledge::containers::NativeIntegerVectorStaged::transfer_to ( NativeIntegerVectorStaged other)
inline

Transfers elements from this vector to another.

Parameters
otherthe other vector to transfer to

Definition at line 187 of file NativeIntegerVectorStaged.inl.

◆ write()

void madara::knowledge::containers::NativeIntegerVectorStaged::write ( void  )
inline

Writes the value to the knowledge base.

Definition at line 311 of file NativeIntegerVectorStaged.inl.

Member Data Documentation

◆ context_

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

Variable context that we are modifying.

Definition at line 287 of file NativeIntegerVectorStaged.h.

◆ has_changed_

bool madara::knowledge::containers::NativeIntegerVectorStaged::has_changed_
private

Tracks if value_ has changed since last read.

Definition at line 302 of file NativeIntegerVectorStaged.h.

◆ mutex_

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

guard for access and changes

Mutex for local changes

Definition at line 136 of file BaseContainer.h.

◆ name_

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

Prefix of variable.

Definition at line 146 of file BaseContainer.h.

◆ settings_

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

Settings for modifications.

Definition at line 151 of file BaseContainer.h.

◆ value_

KnowledgeRecord madara::knowledge::containers::NativeIntegerVectorStaged::value_
private

The staged value of the vector.

Definition at line 297 of file NativeIntegerVectorStaged.h.

◆ vector_

VariableReference madara::knowledge::containers::NativeIntegerVectorStaged::vector_
private

Reference to the size field of the vector space.

Definition at line 292 of file NativeIntegerVectorStaged.h.


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