2 #ifndef _MADARA_NATIVE_INTEGER_VECTOR_STAGED_INL_ 3 #define _MADARA_NATIVE_INTEGER_VECTOR_STAGED_INL_ 22 std::stringstream result;
24 result <<
"Native Integer Vector Staged: ";
28 result << this->
name_;
29 result <<
" [" <<
size () <<
"]";
62 const std::vector <type> & rhs)
109 MADARA_GUARD_TYPE guard (
mutex_);
138 MADARA_GUARD_TYPE guard (
mutex_);
167 MADARA_GUARD_TYPE guard (
mutex_);
205 size_t other_size = other.
size ();
206 size_t this_size = this->
size ();
210 size_t size = other_size + this_size;
218 for (
size_t i = 0, j = other_size; i < this_size - 1; ++i, ++j)
234 target.resize (
size ());
236 for (
size_t i = 0; i < target.size (); ++i)
266 const std::vector <type> & value)
283 MADARA_GUARD_TYPE guard (
mutex_);
310 "NativeIntegerVectorStaged::is_true: checking for non-zero value\n");
315 "NativeIntegerVectorStaged::is_true: final result is %d\n",
342 #endif // _MADARA_NATIVE_INTEGER_VECTOR_STAGED_INL_ This class encapsulates an entry in a KnowledgeBase.
int set(const std::string &key, T &&value, const KnowledgeUpdateSettings &settings=KnowledgeUpdateSettings())
Atomically sets the value of a variable to the specific record.
virtual std::string get_debug_info_(void)
Returns the type of the container along with name and any other useful information.
bool is_true(void) const
Checks to see if the record is true.
void operator=(const NativeIntegerVectorStaged &rhs)
Assignment operator.
This class stores a vector of doubles inside of KaRL.
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 reset_value(void) noexcept
resets the variable to an integer
void transfer_to(NativeIntegerVectorStaged &other)
Transfers elements from this vector to another.
VariableReference get_ref(const std::string &key, const KnowledgeReferenceSettings &settings=knowledge::KnowledgeReferenceSettings(false))
Retrieves the value of a variable.
madara::knowledge::KnowledgeRecord get(const std::string &key, const KnowledgeReferenceSettings &settings=KnowledgeReferenceSettings()) const
Atomically returns the value of a variable.
knowledge::KnowledgeRecord to_record(void) const
Retrieves the entire vector as a native double array in a record.
madara::knowledge::KnowledgeRecord KnowledgeRecord
void set(size_t index, type value)
Sets a knowledge variable to a specified value.
ThreadSafeContext * context_
Variable context that we are modifying.
void push_back(type value)
Pushes the value to the end of the array after incrementing the array size.
double to_double(void) const
converts the value to a float/double
std::string name_
Prefix of variable.
type operator[](size_t index) const
Retrieves a copy of the record from the map.
This class stores variables and their values for use by any entity needing state information in a thr...
void modify(void)
Mark the value as modified.
size_t size(void) const
Returns the size of the vector.
MADARA_LOCK_TYPE mutex_
guard for access and changes
KnowledgeRecord value_
The staged value of the vector.
#define madara_logger_log(logger, level,...)
Fast version of the madara::logger::log method.
madara::knowledge::KnowledgeRecord get(const std::string &key, const KnowledgeReferenceSettings &settings=KnowledgeReferenceSettings(false))
Retrieves a knowledge value.
bool is_true(void) const
Determines if all values in the vector are true.
void read(void)
Reads the value from the knowledge base.
void set_value(const KnowledgeRecord &new_value)
Sets the value from another KnowledgeRecord, does not copy clock and write_quality.
::std::vector< KnowledgeRecord > KnowledgeVector
void write(void)
Writes the value to the knowledge base.
A thread-safe guard for a context or knowledge base.
VariableReference vector_
Reference to the size field of the vector space.
bool is_false(void) const
Determines if the value of the vector is false.
bool has_changed_
Tracks if value_ has changed since last read.
This class provides a distributed knowledge base to users.
void exchange(NativeIntegerVectorStaged &other)
Exchanges the vector at this location with the vector at another location.
std::string get_debug_info(void)
Returns the type of the container along with name and any other useful information.
void set_index(size_t index, T value)
sets the value at the index to the specified value.
Integer to_integer(void) const
converts the value to an integer
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 resize(size_t size)
Resizes the vector.
knowledge::KnowledgeRecord::Integer type
trait that describes the value type
ThreadSafeContext & get_context(void)
Returns the ThreadSafeContext associated with this Knowledge Base.
std::vector< Integer > to_integers(void) const
converts the value to a vector of integers
Provides functions and classes for the distributed knowledge base.
KnowledgeUpdateSettings settings_
Settings for modifications.
VariableReference get_ref(const std::string &key, const KnowledgeReferenceSettings &settings=KnowledgeReferenceSettings())
Atomically returns a reference to the variable.
uint32_t set_quality(const std::string &key, uint32_t quality, bool force_update, const KnowledgeReferenceSettings &settings)
Atomically sets quality of this process for a variable.
logger::Logger & get_logger(void) const
Gets the logger used for information printing.
KnowledgeRecord retrieve_index(size_t index) const
retrieves the value at an array index.
Settings for applying knowledge updates.
std::string to_string(const std::string &delimiter=", ") const
converts the value to a string.
knowledge::KnowledgeRecord get(const std::string &key, const KnowledgeReferenceSettings &settings=knowledge::KnowledgeReferenceSettings(false))
Retrieves the value of a variable.
void copy_to(KnowledgeVector &target) const
Copies the vector elements to an STL vector of Knowledge Records.
void resize(size_t new_size)
resizes an array to a new size
Provides an interface for external functions into the MADARA KaRL variable settings.
uint32_t size(void) const
returns the size of the value
VariableReference get_ref(const std::string &key, const KnowledgeReferenceSettings &settings=KnowledgeReferenceSettings(false))
Atomically returns a reference to the 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...
ThreadSafeContext * get_context(void)
Returns the ThreadSafeContext associated with this Variables facade.