59 std::stringstream result;
66 MADARA_GUARD_TYPE guard(mutex_);
68 result << this->name_;
69 result <<
" = " <<
context_->get(variable_).to_string();
82 return get_debug_info();
95 MADARA_GUARD_TYPE guard(mutex_), guard2(rhs.
mutex_);
98 this->name_ = rhs.
name_;
112 MADARA_GUARD_TYPE guard(mutex_, std::adopt_lock),
113 guard2(other.
mutex_, std::adopt_lock);
128 MADARA_GUARD_TYPE guard(mutex_);
131 variable_ =
context_->get_ref(name_, keep_local);
141 MADARA_GUARD_TYPE guard(mutex_);
144 variable_ =
context_->get_ref(name_, keep_local);
154 MADARA_GUARD_TYPE guard(mutex_);
157 variable_ =
context_->get_ref(name_, keep_local);
166 MADARA_GUARD_TYPE guard(mutex_);
167 context_->set(variable_, value, settings_);
181 MADARA_GUARD_TYPE guard(mutex_);
183 result =
context_->get(variable_, settings_).to_double();
185 context_->set(variable_, result, settings_);
199 MADARA_GUARD_TYPE guard(mutex_);
201 result =
context_->get(variable_, settings_).to_double();
203 context_->set(variable_, result, settings_);
214 MADARA_GUARD_TYPE guard(mutex_);
215 return context_->inc(variable_, settings_).to_double();
227 MADARA_GUARD_TYPE guard(mutex_);
228 return context_->dec(variable_, settings_).to_double();
239 MADARA_GUARD_TYPE guard(mutex_);
240 return context_->get(variable_, settings_).to_double() == value;
251 MADARA_GUARD_TYPE guard(mutex_);
252 return context_->get(variable_, settings_).to_double() != value;
259 const Double& value)
const
264 MADARA_GUARD_TYPE guard(mutex_);
265 return context_->get(variable_, settings_) ==
273 const Double& value)
const
278 MADARA_GUARD_TYPE guard(mutex_);
279 return context_->get(variable_, settings_) !=
291 MADARA_GUARD_TYPE guard(mutex_);
292 return context_->get(variable_, settings_).to_double() < value;
303 MADARA_GUARD_TYPE guard(mutex_);
304 return context_->get(variable_, settings_).to_double() <= value;
315 MADARA_GUARD_TYPE guard(mutex_);
316 return context_->get(variable_, settings_).to_double() > value;
327 MADARA_GUARD_TYPE guard(mutex_);
328 return context_->get(variable_, settings_).to_double() >= value;
347 MADARA_GUARD_TYPE guard(mutex_);
348 result =
context_->exists(variable_);
362 MADARA_GUARD_TYPE guard(mutex_);
363 result =
context_->get(variable_, settings_);
374 MADARA_GUARD_TYPE guard(mutex_);
375 return context_->get(variable_, settings_).to_double();
387 MADARA_GUARD_TYPE guard(mutex_);
388 return context_->get(variable_, settings_).to_integer();
399 MADARA_GUARD_TYPE guard(mutex_);
400 return context_->get(variable_, settings_).to_string();
412 MADARA_GUARD_TYPE guard(mutex_);
413 context_->set_quality(name_, quality,
true, settings);
422 "Double::is_true: checking for non-zero value\n", (
int)result);
427 MADARA_GUARD_TYPE guard(mutex_);
428 result =
context_->get(variable_, settings_).is_true();
432 "Double::is_true: final result is %d\n", (
int)result);
#define madara_logger_log(loggering, level,...)
Fast version of the madara::logger::log method.
const ThreadSafeContext * context_
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.
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...
madara::knowledge::KnowledgeRecord get(const std::string &key, const KnowledgeReferenceSettings &settings=KnowledgeReferenceSettings()) const
Atomically returns the current value of a variable.
int set(const std::string &key, T &&value, const KnowledgeUpdateSettings &settings=KnowledgeUpdateSettings())
Atomically sets the value of a variable to the specific record.
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
This class stores a double within a variable context.
virtual void modify_(void)
Polymorphic modify method used by collection containers.
void set_quality(uint32_t quality, const KnowledgeReferenceSettings &settings=KnowledgeReferenceSettings(false))
Sets the quality of writing to the variable.
double to_double(void) const
Returns the value as a double (alias of *)
void modify(void)
Mark the value as modified.
type operator-=(type value)
Decrements by a value.
void set_name(const std::string &var_name, KnowledgeBase &knowledge)
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.
knowledge::KnowledgeRecord to_record(void) const
Returns the value as a knowledge::KnowledgeRecord.
type operator*(void) const
Returns the value of the variable.
type operator+=(type value)
Increments by a value.
type operator++(void)
Increments the value of the variable and returns the result.
bool operator>=(type value) const
Checks for greater than or equal to relationship.
virtual bool is_true_(void) const
Polymorphic is true method which can be used to determine if all values in the container are true.
bool is_true(void) const
Determines if the value is true.
double type
trait that describes the value type
virtual std::string get_debug_info_(void)
Returns the type of the container along with name and any other useful information.
knowledge::KnowledgeRecord::Integer to_integer(void) const
Returns the value as an integer.
bool operator>(type value) const
Checks for greater than relationship.
bool operator!=(type value) const
Checks for inequality.
bool is_false(void) const
Determines if the value is zero.
void operator=(const Double &rhs)
Assignment operator.
VariableReference variable_
Variable reference.
bool operator==(type value) const
Checks for equality.
void exchange(containers::Double &other)
Exchanges the integer at this location with the integer at another location.
ThreadSafeContext * context_
Variable context that we are modifying.
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 ...
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.
virtual ~Double()
Destructor.
Double(const KnowledgeUpdateSettings &settings=KnowledgeUpdateSettings())
Default constructor.
bool exists(void) const
Checks to see if the variable has ever been assigned a value.
virtual BaseContainer * clone(void) const
Clones this container.
bool operator<=(type value) const
Checks for less than or equal to relationship.
bool operator<(type value) const
Checks for less than relationship.
Provides functions and classes for the distributed knowledge base.