2 #ifndef _MADARA_NATIVE_INTEGER_VECTOR_STAGED_INL_
3 #define _MADARA_NATIVE_INTEGER_VECTOR_STAGED_INL_
21 std::stringstream result;
23 result <<
"Native Integer Vector Staged: ";
27 result << this->name_;
28 result <<
" [" << size() <<
"]";
29 result <<
" = " << value_.to_string();
38 return get_debug_info();
46 MADARA_GUARD_TYPE guard(mutex_), guard2(rhs.
mutex_);
49 this->name_ = rhs.
name_;
53 this->has_changed_ =
true;
58 const std::vector<type>& rhs)
100 MADARA_GUARD_TYPE guard(mutex_);
104 vector_ =
knowledge.get_ref(var_name, settings_);
108 resize(
size_t(size));
112 std::vector<type> values =
knowledge.get(vector_).to_integers();
113 value_.set_value(values);
126 MADARA_GUARD_TYPE guard(mutex_);
130 vector_ =
knowledge.get_ref(var_name, settings_);
134 resize(
size_t(size));
138 std::vector<type> values =
knowledge.get(vector_).to_integers();
139 value_.set_value(values);
153 MADARA_GUARD_TYPE guard(mutex_);
157 vector_ =
knowledge.get_ref(var_name, settings_);
161 resize(
size_t(size));
165 std::vector<type> values =
knowledge.get(vector_).to_integers();
166 value_.set_value(values);
190 size_t other_size = other.
size();
191 size_t this_size = this->size();
195 size_t size = other_size + this_size;
203 for (
size_t i = 0, j = other_size; i < this_size - 1; ++i, ++j)
218 target.resize(size());
220 for (
size_t i = 0; i < target.size(); ++i)
222 target[i] = value_.retrieve_index(i);
238 size_t index,
type value)
243 value_.set_index(index, value);
247 const std::vector<type>& value)
257 size_t , uint32_t quality,
263 MADARA_GUARD_TYPE guard(mutex_);
264 context_->set_quality(name_, quality,
true, settings);
289 "NativeIntegerVectorStaged::is_true: checking for non-zero value\n");
291 result = value_.is_true();
294 "NativeIntegerVectorStaged::is_true: final result is %d\n", (
int)result);
307 has_changed_ =
false;
#define madara_logger_log(loggering, level,...)
Fast version of the madara::logger::log method.
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.
void set_index(size_t index, T value)
sets the value at the index to the specified value.
double to_double(void) const
converts the value to a float/double.
KnowledgeRecord retrieve_index(size_t index) const
retrieves the value at an array index.
Integer to_integer(void) const
converts the value to an integer.
void reset_value(void) noexcept
resets the variable to an integer
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.
KnowledgeUpdateSettings settings_
Settings for modifications.
std::string name_
Prefix of variable.
MADARA_LOCK_TYPE mutex_
guard for access and changes
This class stores a vector of doubles inside of KaRL.
bool has_changed_
Tracks if value_ has changed since last read.
void operator=(const NativeIntegerVectorStaged &rhs)
Assignment operator.
virtual std::string get_debug_info_(void)
Returns the type of the container along with name and any other useful information.
bool is_false(void) const
Determines if the value of the vector is false.
void modify(void)
Mark the value as modified.
void write(void)
Writes the value to the knowledge base.
std::string get_debug_info(void)
Returns the type of the container along with name and any other useful information.
void set_quality(size_t index, uint32_t quality, const KnowledgeReferenceSettings &settings=KnowledgeReferenceSettings(false))
Sets the quality of writing to a certain variable from this entity.
void set_name(const std::string &var_name, KnowledgeBase &knowledge, int size=-1, bool sync=true)
Sets the variable name that this refers to.
void push_back(type value)
Pushes the value to the end of the array after incrementing the array size.
void copy_to(KnowledgeVector &target) const
Copies the vector elements to an STL vector of Knowledge Records.
void read(void)
Reads the value from the knowledge base.
void transfer_to(NativeIntegerVectorStaged &other)
Transfers elements from this vector to another.
void set(size_t index, type value)
Sets a knowledge variable to a specified value.
KnowledgeRecord value_
The staged value of the vector.
knowledge::KnowledgeRecord::Integer type
trait that describes the value type
size_t size(void) const
Returns the size of the vector.
ThreadSafeContext * context_
Variable context that we are modifying.
void resize(size_t size)
Resizes the vector.
knowledge::KnowledgeRecord to_record(void) const
Retrieves the entire vector as a native double array in a record.
VariableReference vector_
Reference to the size field of the vector space.
void exchange(NativeIntegerVectorStaged &other)
Exchanges the vector at this location with the vector at another location.
type operator[](size_t index) const
Retrieves a copy of the record from the map.
bool is_true(void) const
Determines if all values in the vector are true.
Provides functions and classes for the distributed knowledge base.
::std::vector< KnowledgeRecord > KnowledgeVector