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