MADARA  3.2.3
madara::knowledge::containers::StringStaged Class Reference

Stages a string value to and from the knowledge base. More...

#include <StringStaged.h>

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

Public Types

typedef std::string type
 trait that describes the value type More...
 

Public Member Functions

 StringStaged (const KnowledgeUpdateSettings &settings=KnowledgeUpdateSettings())
 Default constructor. More...
 
 StringStaged (const std::string &name, KnowledgeBase &knowledge, const KnowledgeUpdateSettings &settings=KnowledgeUpdateSettings())
 Constructor. More...
 
 StringStaged (const std::string &name, Variables &knowledge, const KnowledgeUpdateSettings &settings=KnowledgeUpdateSettings())
 Constructor. More...
 
 StringStaged (const std::string &name, KnowledgeBase &knowledge, const type &value, const KnowledgeUpdateSettings &settings=KnowledgeUpdateSettings())
 Default constructor. More...
 
 StringStaged (const std::string &name, Variables &knowledge, const type &value, const KnowledgeUpdateSettings &settings=KnowledgeUpdateSettings())
 Default constructor. More...
 
 StringStaged (const StringStaged &rhs)
 Copy constructor. More...
 
virtual ~StringStaged ()
 Destructor. More...
 
virtual BaseContainerclone (void) const
 Clones this container. More...
 
void exchange (StringStaged &other)
 Exchanges the integer at this location with the integer at another location. More...
 
bool exists (void) const
 Checks to see if the variable 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_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 is zero. More...
 
bool is_true (void) const
 Determines if the value is 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...
 
bool operator!= (const StringStaged &value) const
 Checks for inequality. More...
 
bool operator!= (const type &value) const
 Checks for inequality. More...
 
type operator* (void) const
 Returns the value of the variable. More...
 
type operator+= (const type &value)
 Increments by a value. More...
 
type operator-= (const type &value)
 Decrements by a value. More...
 
bool operator< (const type &value) const
 Checks for less than relationship. More...
 
bool operator<= (const type &value) const
 Checks for less than or equal to relationship. More...
 
void operator= (const StringStaged &rhs)
 Assignment operator. More...
 
type operator= (const type &value)
 Sets the value of the variable. More...
 
bool operator== (const StringStaged &value) const
 Checks for equality. More...
 
bool operator== (const type &value) const
 Checks for equality. More...
 
bool operator> (const type &value) const
 Checks for greater than relationship. More...
 
bool operator>= (const type &value) const
 Checks for greater than or equal to relationship. More...
 
void read (void)
 Reads the value from the knowledge base. 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_name (const std::string &var_name, ThreadSafeContext &knowledge, bool sync=true)
 Sets the variable name that this refers to. More...
 
void set_quality (uint32_t quality, const KnowledgeReferenceSettings &settings=KnowledgeReferenceSettings(false))
 Sets the quality of writing to the variable. More...
 
void set_settings (const KnowledgeUpdateSettings &settings)
 Sets the update settings for the container. More...
 
double to_double (void) const
 Returns the value as a double. More...
 
knowledge::KnowledgeRecord::Integer to_integer (void) const
 Returns the value as an integer (same as *) More...
 
knowledge::KnowledgeRecord to_record (void) const
 Returns the value as a knowledge::KnowledgeRecord. More...
 
std::string to_string (void) const
 Returns the value as a string. 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...
 
type value_
 The staged value. More...
 
VariableReference variable_
 Variable reference. More...
 

Detailed Description

Stages a string value to and from the knowledge base.

This container is highly optimized for using a staged value (an intermediate value between the user application and the knowledge base) for common operations and then writing that staged value to the knowledge base after operations are complete with the write method. The value is only updated from the knowledge base on construction and when read is called.

Definition at line 38 of file StringStaged.h.

Member Typedef Documentation

trait that describes the value type

Definition at line 42 of file StringStaged.h.

Constructor & Destructor Documentation

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

Default constructor.

Parameters
settingssettings for updating knowledge

Definition at line 4 of file StringStaged.cpp.

madara::knowledge::containers::StringStaged::StringStaged ( const std::string &  name,
KnowledgeBase knowledge,
const KnowledgeUpdateSettings settings = KnowledgeUpdateSettings () 
)

Constructor.

Parameters
namename of the integer in the knowledge base
knowledgethe knowledge base that will contain the vector
settingssettings for updating knowledge

Definition at line 10 of file StringStaged.cpp.

madara::knowledge::containers::StringStaged::StringStaged ( const std::string &  name,
Variables knowledge,
const KnowledgeUpdateSettings settings = KnowledgeUpdateSettings () 
)

Constructor.

Parameters
namethe name of the map within the variable context
knowledgethe variable context
settingssettings for updating knowledge

Definition at line 21 of file StringStaged.cpp.

madara::knowledge::containers::StringStaged::StringStaged ( const std::string &  name,
KnowledgeBase knowledge,
const type value,
const KnowledgeUpdateSettings settings = KnowledgeUpdateSettings () 
)

Default constructor.

Parameters
namename of the integer in the knowledge base
knowledgethe knowledge base that will contain the vector
valuenew value of the variable in the knowledge base
settingssettings for updating knowledge

Definition at line 32 of file StringStaged.cpp.

madara::knowledge::containers::StringStaged::StringStaged ( const std::string &  name,
Variables knowledge,
const type value,
const KnowledgeUpdateSettings settings = KnowledgeUpdateSettings () 
)

Default constructor.

Parameters
namename of the integer in the knowledge base
knowledgethe knowledge base that will contain the vector
valuenew value of the variable in the knowledge base
settingssettings for updating knowledge

Definition at line 45 of file StringStaged.cpp.

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

Copy constructor.

Definition at line 59 of file StringStaged.cpp.

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

Destructor.

Definition at line 67 of file StringStaged.cpp.

Member Function Documentation

madara::knowledge::containers::BaseContainer * madara::knowledge::containers::StringStaged::clone ( void  ) const
inlinevirtual

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 38 of file StringStaged.inl.

void madara::knowledge::containers::StringStaged::exchange ( containers::StringStaged other)

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

Parameters
otherthe other integer to exchange with

Definition at line 85 of file StringStaged.cpp.

bool madara::knowledge::containers::StringStaged::exists ( void  ) const
inline

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

Returns
true if the record has been set to a value. False if uninitialized

Definition at line 189 of file StringStaged.inl.

std::string madara::knowledge::containers::StringStaged::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 StringStaged.inl.

std::string madara::knowledge::containers::StringStaged::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 79 of file StringStaged.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::StringStaged::is_false ( void  ) const
inline

Determines if the value is zero.

Returns
true if the value is zero

Definition at line 210 of file StringStaged.inl.

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

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

Determines if the value is true.

Returns
true if the values is not zero

Definition at line 204 of file StringStaged.inl.

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

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

Mark the value as modified.

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

Definition at line 9 of file StringStaged.inl.

void madara::knowledge::containers::StringStaged::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 73 of file StringStaged.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.

bool madara::knowledge::containers::StringStaged::operator!= ( const StringStaged value) const
inline

Checks for inequality.

Parameters
valuethe value to compare to
Returns
true if inequal, false otherwise

Definition at line 152 of file StringStaged.inl.

bool madara::knowledge::containers::StringStaged::operator!= ( const type value) const
inline

Checks for inequality.

Parameters
valuethe value to compare to
Returns
true if inequal, false otherwise

Definition at line 139 of file StringStaged.inl.

madara::knowledge::containers::StringStaged::type madara::knowledge::containers::StringStaged::operator* ( void  ) const
inline

Returns the value of the variable.

Returns
the value of the variable

Definition at line 183 of file StringStaged.inl.

madara::knowledge::containers::StringStaged::type madara::knowledge::containers::StringStaged::operator+= ( const type value)
inline

Increments by a value.

Parameters
valuethe value to add
Returns
the new value

Definition at line 229 of file StringStaged.inl.

madara::knowledge::containers::StringStaged::type madara::knowledge::containers::StringStaged::operator-= ( const type value)
inline

Decrements by a value.

Parameters
valuethe value to remove
Returns
the new value

Definition at line 238 of file StringStaged.inl.

bool madara::knowledge::containers::StringStaged::operator< ( const type value) const
inline

Checks for less than relationship.

Parameters
valuethe value to compare to
Returns
true if less than

Definition at line 159 of file StringStaged.inl.

bool madara::knowledge::containers::StringStaged::operator<= ( const type value) const
inline

Checks for less than or equal to relationship.

Parameters
valuethe value to compare to
Returns
true if less than or equal to

Definition at line 165 of file StringStaged.inl.

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

Assignment operator.

Parameters
rhsvalue to copy

Definition at line 44 of file StringStaged.inl.

madara::knowledge::containers::StringStaged::type madara::knowledge::containers::StringStaged::operator= ( const type value)
inline

Sets the value of the variable.

Parameters
valuethe new value of the variable
Returns
the updated value (should be same as value param)

Definition at line 126 of file StringStaged.inl.

bool madara::knowledge::containers::StringStaged::operator== ( const StringStaged value) const
inline

Checks for equality.

Parameters
valuethe value to compare to
Returns
true if equal, false otherwise

Definition at line 145 of file StringStaged.inl.

bool madara::knowledge::containers::StringStaged::operator== ( const type value) const
inline

Checks for equality.

Parameters
valuethe value to compare to
Returns
true if equal, false otherwise

Definition at line 133 of file StringStaged.inl.

bool madara::knowledge::containers::StringStaged::operator> ( const type value) const
inline

Checks for greater than relationship.

Parameters
valuethe value to compare to
Returns
true if greater than

Definition at line 171 of file StringStaged.inl.

bool madara::knowledge::containers::StringStaged::operator>= ( const type value) const
inline

Checks for greater than or equal to relationship.

Parameters
valuethe value to compare to
Returns
true if greater than or equal to

Definition at line 177 of file StringStaged.inl.

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

Reads the value from the knowledge base.

Definition at line 273 of file StringStaged.inl.

void madara::knowledge::containers::StringStaged::set_name ( const std::string &  var_name,
KnowledgeBase knowledge,
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
syncsynchronize the value from the underlying knowledge

Definition at line 60 of file StringStaged.inl.

void madara::knowledge::containers::StringStaged::set_name ( const std::string &  var_name,
Variables knowledge,
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
syncsynchronize the value from the underlying knowledge

Definition at line 104 of file StringStaged.inl.

void madara::knowledge::containers::StringStaged::set_name ( const std::string &  var_name,
ThreadSafeContext knowledge,
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
syncsynchronize the value from the underlying knowledge

Definition at line 82 of file StringStaged.inl.

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

Sets the quality of writing to the variable.

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

Definition at line 260 of file StringStaged.inl.

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.

double madara::knowledge::containers::StringStaged::to_double ( void  ) const
inline

Returns the value as a double.

Returns
the value as a double

Definition at line 247 of file StringStaged.inl.

madara::knowledge::KnowledgeRecord::Integer madara::knowledge::containers::StringStaged::to_integer ( void  ) const
inline

Returns the value as an integer (same as *)

Returns
the value as an integer

Definition at line 222 of file StringStaged.inl.

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

Returns the value as a knowledge::KnowledgeRecord.

This is useful for referencing clock and other record info.

Returns
the value as a knowledge::KnowledgeRecord

Definition at line 216 of file StringStaged.inl.

std::string madara::knowledge::containers::StringStaged::to_string ( void  ) const
inline

Returns the value as a string.

Returns
the value as a string

Definition at line 254 of file StringStaged.inl.

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

Writes the value to the knowledge base.

Definition at line 280 of file StringStaged.inl.

Member Data Documentation

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

Variable context that we are modifying.

Definition at line 362 of file StringStaged.h.

bool madara::knowledge::containers::StringStaged::has_changed_
private

Tracks if value_ has changed since last read.

Definition at line 377 of file StringStaged.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.

type madara::knowledge::containers::StringStaged::value_
private

The staged value.

Definition at line 372 of file StringStaged.h.

VariableReference madara::knowledge::containers::StringStaged::variable_
private

Variable reference.

Definition at line 367 of file StringStaged.h.


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