62 std::stringstream result;
69 MADARA_GUARD_TYPE guard(mutex_);
71 result << this->name_;
72 result <<
" = " <<
context_->get(variable_).to_string();
85 return get_debug_info();
98 MADARA_GUARD_TYPE guard(mutex_), guard2(rhs.
mutex_);
101 this->name_ = rhs.
name_;
115 MADARA_GUARD_TYPE guard(mutex_, std::adopt_lock),
116 guard2(other.
mutex_, std::adopt_lock);
131 MADARA_GUARD_TYPE guard(mutex_);
134 variable_ =
context_->get_ref(name_, keep_local);
144 MADARA_GUARD_TYPE guard(mutex_);
147 variable_ =
context_->get_ref(name_, keep_local);
157 MADARA_GUARD_TYPE guard(mutex_);
160 variable_ =
context_->get_ref(name_, keep_local);
169 MADARA_GUARD_TYPE guard(mutex_);
170 context_->set(variable_, value, settings_);
184 MADARA_GUARD_TYPE guard(mutex_);
186 result =
context_->get(variable_, settings_).to_string();
188 context_->set(variable_, result, settings_);
199 MADARA_GUARD_TYPE guard(mutex_);
200 return context_->get(variable_, settings_).to_string() == value;
211 MADARA_GUARD_TYPE guard(mutex_);
212 return context_->get(variable_, settings_).to_string() != value;
219 const String& value)
const
224 MADARA_GUARD_TYPE guard(mutex_);
225 return context_->get(variable_, settings_) ==
233 const String& value)
const
238 MADARA_GUARD_TYPE guard(mutex_);
239 return context_->get(variable_, settings_) !=
251 MADARA_GUARD_TYPE guard(mutex_);
252 return context_->get(variable_, settings_).to_string() < value;
263 MADARA_GUARD_TYPE guard(mutex_);
264 return context_->get(variable_, settings_).to_string() <= value;
275 MADARA_GUARD_TYPE guard(mutex_);
276 return context_->get(variable_, settings_).to_string() > value;
287 MADARA_GUARD_TYPE guard(mutex_);
288 return context_->get(variable_, settings_).to_string() >= value;
307 MADARA_GUARD_TYPE guard(mutex_);
308 result =
context_->exists(variable_);
322 MADARA_GUARD_TYPE guard(mutex_);
323 result =
context_->get(variable_, settings_);
334 MADARA_GUARD_TYPE guard(mutex_);
335 return context_->get(variable_, settings_).to_string();
346 MADARA_GUARD_TYPE guard(mutex_);
347 return context_->get(variable_, settings_).to_double();
359 MADARA_GUARD_TYPE guard(mutex_);
360 return context_->get(variable_, settings_).to_integer();
372 MADARA_GUARD_TYPE guard(mutex_);
373 context_->set_quality(name_, quality,
true, settings);
382 "String::is_true: checking for non-zero value\n");
387 MADARA_GUARD_TYPE guard(mutex_);
388 result =
context_->get(variable_, settings_).is_true();
392 "String::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.
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 string within a variable context.
std::string type
trait that describes the value type
type operator*(void) const
Returns the value of the variable.
String(const KnowledgeUpdateSettings &settings=KnowledgeUpdateSettings())
Default constructor.
bool operator!=(const type &value) const
Checks for inequality.
type operator+=(const type &value)
Increments by a value.
void modify(void)
Mark the value as modified.
void set_name(const std::string &var_name, KnowledgeBase &knowledge)
Sets the variable name that this refers to.
bool operator>=(const type &value) const
Checks for greater than or equal to relationship.
bool operator==(const type &value) const
Checks for equality.
bool exists(void) const
Checks to see if the variable has ever been assigned a value.
ThreadSafeContext * context_
Variable context that we are modifying.
virtual std::string get_debug_info_(void)
Returns the type of the container along with name and any other useful information.
bool operator>(const type &value) const
Checks for greater than relationship.
std::string to_string(void) const
Returns the value as a string (alias of *)
double to_double(void) const
Returns the value as a double.
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.
void set_quality(uint32_t quality, const KnowledgeReferenceSettings &settings=KnowledgeReferenceSettings(false))
Sets the quality of writing to the variable.
std::string get_debug_info(void)
Returns the type of the container along with name and any other useful information.
void exchange(String &other)
Exchanges the string at this location with the string at another location.
virtual ~String()
Destructor.
virtual BaseContainer * clone(void) const
Clones this container.
void operator=(const String &rhs)
Assignment operator.
madara::knowledge::KnowledgeRecord::Integer to_integer(void) const
Returns the value as an integer.
VariableReference variable_
Variable reference.
virtual void modify_(void)
Polymorphic modify method used by collection containers.
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 ...
bool is_false(void) const
Determines if the value is zero.
knowledge::KnowledgeRecord to_record(void) const
Returns the value as a knowledge::KnowledgeRecord.
bool operator<=(const type &value) const
Checks for less than or equal to relationship.
bool operator<(const type &value) const
Checks for less than relationship.
Provides functions and classes for the distributed knowledge base.