1 #ifndef _MADARA_KNOWLEDGE_CONTAINERS_INTEGERSTAGED_INL_
2 #define _MADARA_KNOWLEDGE_CONTAINERS_INTEGERSTAGED_INL_
19 std::stringstream result;
21 result <<
"IntegerStaged: ";
26 MADARA_GUARD_TYPE guard(mutex_);
28 result << this->name_;
29 result <<
" = " <<
context_->get(variable_).to_string();
30 result <<
", staged_value = " << value_;
47 MADARA_GUARD_TYPE guard(mutex_), guard2(rhs.
mutex_);
52 this->name_ = rhs.
name_;
65 MADARA_GUARD_TYPE guard(mutex_);
68 variable_ =
context_->get_ref(name_, keep_local);
72 value_ =
context_->get(variable_).to_integer();
84 MADARA_GUARD_TYPE guard(mutex_);
87 variable_ =
context_->get_ref(name_, keep_local);
91 value_ =
context_->get(variable_).to_integer();
103 MADARA_GUARD_TYPE guard(mutex_);
106 variable_ =
context_->get_ref(name_, keep_local);
110 value_ =
context_->get(variable_).to_integer();
111 has_changed_ =
false;
119 return value_ = value;
125 return value_ == value;
131 return value_ != value;
137 return value_ == value.
value_;
143 return value_ != value.
value_;
149 return value_ < value;
155 return value_ <= value;
161 return value_ > value;
167 return value_ >= value;
183 MADARA_GUARD_TYPE guard(mutex_);
184 result =
context_->exists(variable_);
251 return (
double)value_;
267 MADARA_GUARD_TYPE guard(mutex_);
268 context_->set_quality(name_, quality,
true, settings);
274 has_changed_ =
false;
275 value_ =
context_->get(variable_).to_integer();
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.
std::string to_string(const std::string &delimiter=", ") const
converts the value to a string.
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 an integer value to and from the knowledge base.
bool is_false(void) const
Determines if the value is zero.
ThreadSafeContext * context_
Variable context that we are modifying.
type operator*(void) const
Returns the value of the variable.
type value_
The staged value.
bool exists(void) const
Checks to see if the variable has ever been assigned a value.
bool has_changed_
Tracks if value_ has changed since last read.
knowledge::KnowledgeRecord::Integer type
trait that describes the value type
void modify(void)
Mark the value as modified.
void set_name(const std::string &var_name, KnowledgeBase &knowledge, bool sync=true)
Sets the variable name that this refers to.
bool operator!=(const IntegerStaged &value) const
Checks for inequality.
bool operator<(type value) const
Checks for less than relationship.
std::string to_string(void) const
Returns the value as a string.
virtual BaseContainer * clone(void) const
Clones this container.
knowledge::KnowledgeRecord::Integer to_integer(void) const
Returns the value as an integer (same as *)
bool operator>=(type value) const
Checks for greater than or equal to relationship.
double to_double(void) const
Returns the value as a double.
knowledge::KnowledgeRecord to_record(void) const
Returns the value as a knowledge::KnowledgeRecord.
type operator-=(type value)
Decrements by a value.
VariableReference variable_
Variable reference.
type operator--(void)
Decrements the value of the variable and returns the result.
void write(void)
Writes the value to the knowledge base.
type operator++(void)
Increments the value of the variable and returns the result.
void set_quality(uint32_t quality, const KnowledgeReferenceSettings &settings=KnowledgeReferenceSettings(false))
Sets the quality of writing to the variable.
bool operator==(const IntegerStaged &value) const
Checks for equality.
bool operator>(type value) const
Checks for greater than relationship.
type operator+=(type value)
Increments by a value.
void operator=(const IntegerStaged &rhs)
Assignment operator.
void read(void)
Reads the value from the knowledge base.
std::string get_debug_info(void)
Returns the type of the container along with name and any other useful information.
bool operator<=(type value) const
Checks for less than or equal to relationship.
bool is_true(void) const
Determines if the value is true.
Provides functions and classes for the distributed knowledge base.