66 std::stringstream result;
68 result <<
"Native Integer Vector: ";
73 MADARA_GUARD_TYPE guard (
mutex_);
75 result << this->
name_;
76 result <<
" [" <<
size () <<
"]";
124 MADARA_GUARD_TYPE guard (
mutex_);
139 MADARA_GUARD_TYPE guard (
mutex_);
153 MADARA_GUARD_TYPE guard (
mutex_);
168 MADARA_GUARD_TYPE guard (
mutex_);
189 MADARA_GUARD_TYPE guard (
mutex_);
210 MADARA_GUARD_TYPE guard (
mutex_);
229 MADARA_GUARD_TYPE guard (
mutex_), guard2 (other.
mutex_);
246 MADARA_GUARD_TYPE guard (
mutex_);
247 MADARA_GUARD_TYPE guard2 (other.
mutex_);
249 size_t other_size = other.
size ();
250 size_t this_size = this->
size ();
254 size_t size = other_size + this_size;
260 rhs.
set_index (size - 1, lhs.retrieve_index (this_size - 1).to_double ());
262 for (
size_t i = 0, j = other_size; i < this_size - 1; ++i, ++j)
264 rhs.set_index (other_size, lhs.retrieve_index (i).to_double ());
281 MADARA_GUARD_TYPE guard (
mutex_);
283 target.resize (
size ());
285 for (
size_t i = 0; i < target.size (); ++i)
301 MADARA_GUARD_TYPE guard (
mutex_);
304 if (index < result.
size ())
321 MADARA_GUARD_TYPE guard (
mutex_);
339 MADARA_GUARD_TYPE guard (
mutex_);
348 const std::vector <type> & value)
355 MADARA_GUARD_TYPE guard (
mutex_);
364 const std::vector <type> & value,
372 MADARA_GUARD_TYPE guard (
mutex_);
388 MADARA_GUARD_TYPE guard (
mutex_);
415 "NativeIntegerVector::is_true: checking for non-zero value\n");
420 MADARA_GUARD_TYPE guard (
mutex_);
425 "NativeIntegerVector::is_true: final result is %d\n",
This class encapsulates an entry in a KnowledgeBase.
knowledge::KnowledgeRecord::Integer type
trait that describes the value type
int set(const std::string &key, T &&value, const KnowledgeUpdateSettings &settings=KnowledgeUpdateSettings())
Atomically sets the value of a variable to the specific record.
virtual BaseContainer * clone(void) const
Clones this container.
bool is_true(void) const
Checks to see if the record is true.
This class stores a vector of doubles inside of KaRL.
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.
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.
madara::knowledge::KnowledgeRecord KnowledgeRecord
void modify(void)
Mark the value as modified.
double to_double(void) const
converts the value to a float/double
std::string name_
Prefix of variable.
ThreadSafeContext * context_
Variable context that we are modifying.
NativeIntegerVector(const KnowledgeUpdateSettings &settings=KnowledgeUpdateSettings())
Default constructor.
bool is_false(void) const
Determines if the value of the vector is false.
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_true(void) const
Determines if all values in the vector are true.
This class stores variables and their values for use by any entity needing state information in a thr...
void push_back(type value)
Pushes the value to the end of the array after incrementing the array size.
virtual void modify_(void)
Polymorphic modify method used by collection containers.
virtual bool is_true_(void) const
Polymorphic is true method which can be used to determine if all values in the container are true...
MADARA_LOCK_TYPE mutex_
guard for access and changes
int set_index(const std::string &key, size_t index, T &&value, const KnowledgeUpdateSettings &settings=KnowledgeUpdateSettings())
Atomically sets the value of an array index to a value.
#define madara_logger_log(logger, level,...)
Fast version of the madara::logger::log method.
std::string get_debug_info(void)
Returns the type of the container along with name and any other useful information.
::std::vector< KnowledgeRecord > KnowledgeVector
void copy_to(KnowledgeVector &target) const
Copies the vector elements to an STL vector of Knowledge Records.
type operator[](size_t index) const
Retrieves a copy of the record from the map.
A thread-safe guard for a context or knowledge base.
virtual ~NativeIntegerVector()
Destructor.
void operator=(const NativeIntegerVector &rhs)
Assignment operator.
This class provides a distributed knowledge base to users.
VariableReference vector_
Reference to the size field of the vector space.
void set_index(size_t index, T value)
sets the value at the index to the specified value.
knowledge::KnowledgeRecord to_record(void) const
Retrieves the entire vector as a native double array in a record.
int set(size_t index, type value)
Sets a knowledge variable to a specified value.
ThreadSafeContext & get_context(void)
Returns the ThreadSafeContext associated with this Knowledge Base.
void set_name(const std::string &var_name, KnowledgeBase &knowledge, int size=-1)
Sets the variable name that this refers to.
void exchange(NativeIntegerVector &other)
Exchanges the vector at this location with the vector at another location.
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.
Settings for applying knowledge updates.
size_t size(void) const
Returns the size of the vector.
void transfer_to(NativeIntegerVector &other)
Transfers elements from this vector to another.
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.
void resize(size_t size)
Resizes the vector.
virtual std::string get_debug_info_(void)
Returns the type of the container along with name and any other useful information.
Settings for applying knowledge updates.
std::string to_string(const std::string &delimiter=", ") const
converts the value to a string.
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.
This class is an abstract base class for all containers.
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.