1 #ifndef _MADARA_KNOWLEDGE_CONTAINERS_STRINGSTAGED_INL_
2 #define _MADARA_KNOWLEDGE_CONTAINERS_STRINGSTAGED_INL_
19 std::stringstream result;
21 result <<
"StringStaged: ";
26 MADARA_GUARD_TYPE guard(mutex_);
28 result << this->name_;
29 result <<
" = " <<
context_->get(variable_).to_string();
46 MADARA_GUARD_TYPE guard(mutex_), guard2(rhs.
mutex_);
51 this->name_ = rhs.
name_;
64 MADARA_GUARD_TYPE guard(mutex_);
67 variable_ =
context_->get_ref(name_, keep_local);
71 value_ =
context_->get(variable_).to_string();
83 MADARA_GUARD_TYPE guard(mutex_);
86 variable_ =
context_->get_ref(name_, keep_local);
90 value_ =
context_->get(variable_).to_string();
102 MADARA_GUARD_TYPE guard(mutex_);
105 variable_ =
context_->get_ref(name_, keep_local);
109 value_ =
context_->get(variable_).to_string();
110 has_changed_ =
false;
118 return value_ = value;
122 const type& value)
const
124 return value_ == value;
128 const type& value)
const
130 return value_ != value;
136 return value_ == value.
value_;
142 return value_ != value.
value_;
146 const type& value)
const
148 return value_ < value;
152 const type& value)
const
154 return value_ <= value;
158 const type& value)
const
160 return value_ > value;
164 const type& value)
const
166 return value_ >= value;
182 MADARA_GUARD_TYPE guard(mutex_);
183 result =
context_->exists(variable_);
248 MADARA_GUARD_TYPE guard(mutex_);
249 context_->set_quality(name_, quality,
true, settings);
255 has_changed_ =
false;
256 value_ =
context_->get(variable_).to_string();
const ThreadSafeContext * context_
madara::knowledge::KnowledgeRecord KnowledgeRecord
A thread-safe guard for a context or knowledge base.
This class provides a distributed knowledge base to users.
This class encapsulates an entry in a KnowledgeBase.
double to_double(void) const
converts the value to a float/double.
Integer to_integer(void) const
converts the value to an integer.
Settings for applying knowledge updates.
Settings for applying knowledge updates.
This class stores variables and their values for use by any entity needing state information in a thr...
void mark_modified(const VariableReference &variable, const KnowledgeUpdateSettings &settings=KnowledgeUpdateSettings())
Marks the variable reference as updated for the purposes of sending or checkpointing knowledge (for g...
Provides an interface for external functions into the MADARA KaRL variable settings.
This class is an abstract base class for all containers.
KnowledgeUpdateSettings settings_
Settings for modifications.
std::string name_
Prefix of variable.
MADARA_LOCK_TYPE mutex_
guard for access and changes
Stages a string value to and from the knowledge base.
bool exists(void) const
Checks to see if the variable has ever been assigned a value.
bool operator<=(const type &value) const
Checks for less than or equal to relationship.
bool has_changed_
Tracks if value_ has changed since last read.
type operator*(void) const
Returns the value of the variable.
void set_quality(uint32_t quality, const KnowledgeReferenceSettings &settings=KnowledgeReferenceSettings(false))
Sets the quality of writing to the variable.
knowledge::KnowledgeRecord::Integer to_integer(void) const
Returns the value as an integer (same as *)
knowledge::KnowledgeRecord to_record(void) const
Returns the value as a knowledge::KnowledgeRecord.
void set_name(const std::string &var_name, KnowledgeBase &knowledge, bool sync=true)
Sets the variable name that this refers to.
bool is_true(void) const
Determines if the value is true.
bool operator>(const type &value) const
Checks for greater than relationship.
virtual BaseContainer * clone(void) const
Clones this container.
bool operator<(const type &value) const
Checks for less than relationship.
type value_
The staged value.
bool operator>=(const type &value) const
Checks for greater than or equal to relationship.
bool operator!=(const StringStaged &value) const
Checks for inequality.
void operator=(const StringStaged &rhs)
Assignment operator.
double to_double(void) const
Returns the value as a double.
VariableReference variable_
Variable reference.
void write(void)
Writes the value to the knowledge base.
std::string get_debug_info(void)
Returns the type of the container along with name and any other useful information.
std::string to_string(void) const
Returns the value as a string.
void read(void)
Reads the value from the knowledge base.
bool operator==(const StringStaged &value) const
Checks for equality.
ThreadSafeContext * context_
Variable context that we are modifying.
bool is_false(void) const
Determines if the value is zero.
type operator-=(const type &value)
Decrements by a value.
std::string type
trait that describes the value type
void modify(void)
Mark the value as modified.
type operator+=(const type &value)
Increments by a value.
Provides functions and classes for the distributed knowledge base.