1 #ifndef _MADARA_KNOWLEDGE_CONTAINERS_INTEGER_INL_
2 #define _MADARA_KNOWLEDGE_CONTAINERS_INTEGER_INL_
18 std::stringstream result;
20 result <<
"Integer: ";
25 MADARA_GUARD_TYPE guard(mutex_);
27 result << this->name_;
28 result <<
" = " <<
context_->get(variable_).to_string();
45 MADARA_GUARD_TYPE guard(mutex_), guard2(rhs.
mutex_);
48 this->name_ = rhs.
name_;
61 MADARA_GUARD_TYPE guard(mutex_);
64 variable_ =
context_->get_ref(name_, keep_local);
74 MADARA_GUARD_TYPE guard(mutex_);
77 variable_ =
context_->get_ref(name_, keep_local);
87 MADARA_GUARD_TYPE guard(mutex_);
90 variable_ =
context_->get_ref(name_, keep_local);
99 MADARA_GUARD_TYPE guard(mutex_);
100 context_->set(variable_, value, settings_);
111 MADARA_GUARD_TYPE guard(mutex_);
112 return context_->get(variable_, settings_).to_integer() == value;
123 MADARA_GUARD_TYPE guard(mutex_);
124 return context_->get(variable_, settings_).to_integer() != value;
136 MADARA_GUARD_TYPE guard(mutex_);
137 return context_->get(variable_, settings_) ==
150 MADARA_GUARD_TYPE guard(mutex_);
151 return context_->get(variable_, settings_) !=
163 MADARA_GUARD_TYPE guard(mutex_);
164 return context_->get(variable_, settings_).to_integer() < value;
175 MADARA_GUARD_TYPE guard(mutex_);
176 return context_->get(variable_, settings_).to_integer() <= value;
187 MADARA_GUARD_TYPE guard(mutex_);
188 return context_->get(variable_, settings_).to_integer() > value;
199 MADARA_GUARD_TYPE guard(mutex_);
200 return context_->get(variable_, settings_).to_integer() >= value;
219 MADARA_GUARD_TYPE guard(mutex_);
220 result =
context_->exists(variable_);
231 "Integer::is_true: checking for non-zero value\n");
236 MADARA_GUARD_TYPE guard(mutex_);
237 result =
context_->get(variable_, settings_).is_true();
241 "Integer::is_true: final result is %d\n", (
int)result);
251 "Integer::is_false: checking for zero value\n");
256 MADARA_GUARD_TYPE guard(mutex_);
257 result =
context_->get(variable_, settings_).is_false();
261 "Integer::is_false: final result is %d\n", (
int)result);
274 MADARA_GUARD_TYPE guard(mutex_);
275 result =
context_->get(variable_, settings_);
287 MADARA_GUARD_TYPE guard(mutex_);
288 return context_->get(variable_, settings_).to_integer();
302 MADARA_GUARD_TYPE guard(mutex_);
304 result =
context_->get(variable_, settings_).to_integer();
306 context_->set(variable_, result, settings_);
320 MADARA_GUARD_TYPE guard(mutex_);
322 result =
context_->get(variable_, settings_).to_integer();
324 context_->set(variable_, result, settings_);
336 MADARA_GUARD_TYPE guard(mutex_);
337 return context_->inc(variable_, settings_).to_integer();
349 MADARA_GUARD_TYPE guard(mutex_);
350 return context_->dec(variable_, settings_).to_integer();
361 MADARA_GUARD_TYPE guard(mutex_);
362 return context_->get(variable_, settings_).to_double();
373 MADARA_GUARD_TYPE guard(mutex_);
374 return context_->get(variable_, settings_).to_string();
386 MADARA_GUARD_TYPE guard(mutex_);
387 context_->set_quality(name_, quality,
true, settings);
#define madara_logger_log(loggering, level,...)
Fast version of the madara::logger::log method.
madara::knowledge::KnowledgeRecord::Integer Integer
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.
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
This class stores an integer within a variable context.
knowledge::KnowledgeRecord::Integer type
trait that describes the value type
type operator-=(type value)
Decrements by a value.
type operator*(void) const
Returns the value of the variable.
knowledge::KnowledgeRecord to_record(void) const
Returns the value as a knowledge::KnowledgeRecord.
type operator++(void)
Increments the value of the variable and returns the result.
bool operator<=(type value) const
Checks for less than or equal to relationship.
bool exists(void) const
Checks to see if the variable has ever been assigned a value.
bool operator!=(const Integer &value) const
Checks for inequality.
bool operator>(type value) const
Checks for greater than relationship.
void set_quality(uint32_t quality, const KnowledgeReferenceSettings &settings=KnowledgeReferenceSettings(false))
Sets the quality of writing to the variable.
bool operator>=(type value) const
Checks for greater than or equal to relationship.
type operator+=(type value)
Increments by a value.
bool is_false(void) const
Determines if the value is zero.
bool is_true(void) const
Determines if the value is true.
virtual BaseContainer * clone(void) const
Clones this container.
ThreadSafeContext * context_
Variable context that we are modifying.
knowledge::KnowledgeRecord::Integer to_integer(void) const
Returns the value as an integer (same as *)
VariableReference variable_
Variable reference.
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 relationship.
void operator=(const Integer &rhs)
Assignment operator.
void set_name(const std::string &var_name, KnowledgeBase &knowledge)
Sets the variable name that this refers to.
void modify(void)
Mark the value as modified.
std::string to_string(void) const
Returns the value as a string.
double to_double(void) const
Returns the value as a double.
type operator--(void)
Decrements the value of the variable and returns the result.
bool operator==(const Integer &value) const
Checks for equality.
Provides functions and classes for the distributed knowledge base.