54 std::stringstream result;
56 result <<
"Native Integer Vector: ";
61 MADARA_GUARD_TYPE guard(mutex_);
63 result << this->name_;
64 result <<
" [" << size() <<
"]";
65 result <<
" = " <<
context_->get(vector_).to_string();
79 return get_debug_info();
93 MADARA_GUARD_TYPE guard(mutex_), guard2(rhs.
mutex_);
96 this->name_ = rhs.
name_;
107 MADARA_GUARD_TYPE guard(mutex_);
120 MADARA_GUARD_TYPE guard(mutex_);
126 context_->set(vector_, value, settings_);
133 MADARA_GUARD_TYPE guard(mutex_);
135 return context_->get(vector_, settings_).size();
146 MADARA_GUARD_TYPE guard(mutex_);
150 vector_ =
knowledge.get_ref(var_name, settings_);
153 resize(
size_t(size));
165 MADARA_GUARD_TYPE guard(mutex_);
169 vector_ =
knowledge.get_ref(var_name, settings_);
172 resize(
size_t(size));
184 MADARA_GUARD_TYPE guard(mutex_);
188 vector_ =
knowledge.get_ref(var_name, settings_);
191 resize(
size_t(size));
204 MADARA_GUARD_TYPE guard(mutex_, std::adopt_lock),
205 guard2(other.
mutex_, std::adopt_lock);
210 context_->set(vector_, temp, settings_);
223 MADARA_GUARD_TYPE guard(mutex_, std::adopt_lock),
224 guard2(other.
mutex_, std::adopt_lock);
226 size_t other_size = other.
size();
227 size_t this_size = this->size();
231 size_t size = other_size + this_size;
239 for (
size_t i = 0, j = other_size; i < this_size - 1; ++i, ++j)
257 MADARA_GUARD_TYPE guard(mutex_);
259 target.resize(size());
261 for (
size_t i = 0; i < target.size(); ++i)
277 MADARA_GUARD_TYPE guard(mutex_);
278 result =
context_->get(vector_, settings_);
280 if (index < result.
size())
288 size_t index,
type value)
295 MADARA_GUARD_TYPE guard(mutex_);
296 result =
context_->set_index(vector_, index, value, settings_);
310 MADARA_GUARD_TYPE guard(mutex_);
311 result =
context_->set_index(vector_, index, value, settings);
318 const std::vector<type>& value)
325 MADARA_GUARD_TYPE guard(mutex_);
326 context_->set(vector_, value, settings_);
340 MADARA_GUARD_TYPE guard(mutex_);
341 context_->set(vector_, value, settings);
348 size_t , uint32_t quality,
354 MADARA_GUARD_TYPE guard(mutex_);
355 context_->set_quality(name_, quality,
true, settings);
366 MADARA_GUARD_TYPE guard(mutex_);
373 std::vector<madara::knowledge::KnowledgeRecord::Integer>
376 return context_->get(this->vector_, settings_).to_integers();
384 context_->get(this->vector_, settings_);
392 return context_->get(this->vector_, settings_);
400 "NativeIntegerVector::is_true: checking for non-zero value\n");
405 MADARA_GUARD_TYPE guard(mutex_);
406 result =
context_->get(vector_, settings_).is_true();
410 "NativeIntegerVector::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_
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.
uint32_t size(void) const
returns the size of the value
Integer to_integer(void) const
converts the value to an integer.
void resize(size_t new_size)
resizes an array to a new size
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.
int set(const std::string &key, T &&value, const KnowledgeUpdateSettings &settings=KnowledgeUpdateSettings())
Atomically sets the value of a variable to the specific record.
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 vector of doubles inside of KaRL.
virtual void modify_(void)
Polymorphic modify method used by collection containers.
bool is_false(void) const
Determines if the value of the vector is false.
VariableReference vector_
Reference to the size field of the vector space.
void set_name(const std::string &var_name, KnowledgeBase &knowledge, int size=-1)
Sets the variable name that this refers to.
void copy_to(KnowledgeVector &target) const
Copies the vector elements to an STL vector of Knowledge Records.
virtual ~NativeIntegerVector()
Destructor.
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 operator=(const NativeIntegerVector &rhs)
Assignment operator.
void resize(size_t size)
Resizes the vector.
bool exists(void) const
Checks to see if the variable has ever been assigned a value.
void push_back(type value)
Pushes the value to the end of the array after incrementing the array size.
NativeIntegerVector(const KnowledgeUpdateSettings &settings=KnowledgeUpdateSettings())
Default constructor.
void transfer_to(NativeIntegerVector &other)
Transfers elements from this vector to another.
virtual std::string get_debug_info_(void)
Returns the type of the container along with name and any other useful information.
type operator[](size_t index) const
Retrieves a copy of the record from the map.
knowledge::KnowledgeRecord to_record(void) const
Retrieves the entire vector as a native double array in a record.
ThreadSafeContext * context_
Variable context that we are modifying.
void modify(void)
Mark the value as modified.
int set(size_t index, type value)
Sets a knowledge variable to a specified value.
size_t size(void) const
Returns the size of the vector.
virtual bool is_true_(void) const
Polymorphic is true method which can be used to determine if all values in the container are true.
void exchange(NativeIntegerVector &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.
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.
std::vector< KnowledgeRecord::Integer > to_integers(void) const
Retrieves the native integer array from inside the record.
virtual BaseContainer * clone(void) const
Clones this container.
knowledge::KnowledgeRecord::Integer type
trait that describes the value type
Provides functions and classes for the distributed knowledge base.
::std::vector< KnowledgeRecord > KnowledgeVector