8 :
BaseContainer (
"", settings), context_ (0), delimiter_ (delimiter)
23 resize (size, delete_vars);
37 resize (size, delete_vars);
61 for (
size_t index = 0; index <
vector_.size (); ++index)
71 std::stringstream result;
73 result <<
"Double Vector: ";
78 MADARA_GUARD_TYPE guard (
mutex_);
79 size_t elements =
vector_.size ();
81 result << this->
name_;
82 result <<
" [" << elements <<
"]";
89 for (
size_t index = 1; index < elements; ++index)
152 MADARA_GUARD_TYPE guard (
mutex_);
173 std::stringstream buffer;
176 MADARA_GUARD_TYPE guard (
mutex_);
190 int size,
bool delete_vars)
195 MADARA_GUARD_TYPE guard (
mutex_);
204 size_t old_size =
vector_.size ();
206 if (old_size != (
size_t)size)
212 if ((
size_t)size > old_size)
214 for (; old_size < (size_t)size; ++old_size)
216 std::stringstream buffer;
223 else if (delete_vars)
225 for (; (size_t)size < old_size; ++
size)
227 std::stringstream buffer;
243 size_t old_size =
vector_.size ();
245 if (old_size != cur_size)
249 if (cur_size > old_size)
251 for (; old_size < (size_t)cur_size; ++old_size)
253 std::stringstream buffer;
260 else if (delete_vars)
262 for (; (size_t)cur_size < old_size; ++cur_size)
264 std::stringstream buffer;
280 MADARA_GUARD_TYPE guard (
mutex_);
294 MADARA_GUARD_TYPE guard (
mutex_);
316 MADARA_GUARD_TYPE guard (
mutex_);
335 MADARA_GUARD_TYPE guard (
mutex_);
352 MADARA_GUARD_TYPE guard (
mutex_);
376 MADARA_GUARD_TYPE guard (
mutex_, std::adopt_lock),
377 guard2 (other.
mutex_, std::adopt_lock);
386 size_t other_size = other.
vector_.size ();
387 size_t this_size = this->
vector_.size ();
389 for (
size_t i = 0; i < this_size; ++i)
408 std::stringstream buffer;
409 buffer << this->
name_;
421 std::stringstream buffer;
422 buffer << other.
name_;
434 for (
size_t i = this_size; i < other_size; ++i)
436 std::stringstream buffer;
437 buffer << this->
name_;
469 MADARA_GUARD_TYPE guard (
mutex_, std::adopt_lock),
470 guard2 (other.
mutex_, std::adopt_lock);
473 size_t other_size = other.
vector_.size ();
474 size_t this_size = this->
vector_.size ();
476 size_t size = other_size + this_size;
479 for (
size_t i = 0, j = other_size; i < this_size; ++i, ++j)
495 MADARA_GUARD_TYPE guard (
mutex_);
497 target.resize (
vector_.size ());
499 for (
size_t i = 0; i <
vector_.size (); ++i)
508 std::vector <IntegerVectorVector::type > & target)
const 513 MADARA_GUARD_TYPE guard (
mutex_);
515 target.resize (
vector_.size ());
517 for (
size_t i = 0; i <
vector_.size (); ++i)
519 target[i] = (*this)[i];
534 MADARA_GUARD_TYPE guard (
mutex_);
552 MADARA_GUARD_TYPE guard (
mutex_);
570 MADARA_GUARD_TYPE guard (
mutex_);
586 MADARA_GUARD_TYPE guard (
mutex_);
603 MADARA_GUARD_TYPE guard (
mutex_);
613 const std::vector <type> & value)
620 MADARA_GUARD_TYPE guard (
mutex_);
621 if (
vector_.size () < value.size ())
622 resize ((
int)value.size (),
false);
624 for (
size_t i = 0; i < value.size (); ++i)
646 MADARA_GUARD_TYPE guard (
mutex_);
656 const std::vector <type> & value,
664 MADARA_GUARD_TYPE guard (
mutex_);
665 if (
vector_.size () < value.size ())
666 resize ((
int)value.size (),
false);
668 for (
size_t i = 0; i < value.size (); ++i)
688 MADARA_GUARD_TYPE guard (
mutex_);
700 "IntegerVectorVector::is_true: Checking for truth\n");
705 MADARA_GUARD_TYPE guard (
mutex_);
710 "IntegerVectorVector::is_true: context was not null. Result changed to %d\n",
713 for (
size_t index = 0; index <
vector_.size (); ++index)
717 "IntegerVectorVector::is_true: checking index %d, is_false of %d. \n",
723 "IntegerVectorVector::is_true: result is false, breaking\n");
735 "IntegerVectorVector::is_true: final result is %d\n", (int)result);
This class encapsulates an entry in a KnowledgeBase.
void operator=(const IntegerVectorVector &rhs)
Assignment operator.
int set(const std::string &key, T &&value, const KnowledgeUpdateSettings &settings=KnowledgeUpdateSettings())
Atomically sets the value of a variable to the specific record.
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 push_back(const type &value)
Pushes the value to the end of the array after incrementing the array size.
std::string get_name(void) const
Returns the name of the container.
madara::knowledge::KnowledgeRecord KnowledgeRecord
std::string name_
Prefix of variable.
std::vector< int64_t > type
trait that describes the value type
This class stores variables and their values for use by any entity needing state information in a thr...
VariableReference size_
Reference to the size field of the vector space.
size_t size(void) const
Returns the size of the local vector.
IntegerVectorVector(const KnowledgeUpdateSettings &settings=KnowledgeUpdateSettings(), const std::string &delimiter=".")
Default constructor.
type operator[](size_t index) const
Retrieves a copy of the record from the vector.
virtual BaseContainer * clone(void) const
Clones this container.
MADARA_LOCK_TYPE mutex_
guard for access and changes
std::vector< VariableReference > vector_
Values of the array.
Optimized reference to a variable within the knowledge base.
#define madara_logger_log(logger, level,...)
Fast version of the madara::logger::log method.
bool is_valid(void) const
Checks to see if the variable reference has been initialized.
bool exists(const std::string &key, const KnowledgeReferenceSettings &settings=KnowledgeReferenceSettings()) const
Atomically checks to see if a variable already exists.
bool exists(size_t index) const
Checks to see if the index has ever been assigned a value.
bool is_false(void) const
Determines if the value of the vector is false.
VariableReference get_size_ref(void)
Returns a reference to the size field of the current name.
::std::vector< KnowledgeRecord > KnowledgeVector
void transfer_to(IntegerVectorVector &other)
Transfers elements from this vector to another.
A thread-safe guard for a context or knowledge base.
virtual void modify_(void)
Polymorphic modify method used by collection containers.
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.
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 ...
void set_delimiter(const std::string &delimiter)
Sets the delimiter for adding and detecting subvariables.
This class provides a distributed knowledge base to users.
This class stores a vector of NativeIntegerVectors.
std::string delimiter_
Delimiter for the prefix to subvars.
std::string get_debug_info(void)
Returns the type of the container along with name and any other useful information.
VariableReference get_ref(const std::string &key, const KnowledgeReferenceSettings &settings=KnowledgeReferenceSettings())
Atomically returns a reference to the variable.
Integer to_integer(void) const
converts the value to an integer.
void resize(int size=-1, bool delete_vars=true)
Resizes the vector.
virtual ~IntegerVectorVector()
Destructor.
ThreadSafeContext & get_context(void)
Returns the ThreadSafeContext associated with this Knowledge Base.
bool delete_variable(const std::string &key, const KnowledgeReferenceSettings &settings=KnowledgeReferenceSettings())
Deletes the key.
void modify(void)
Mark the vector as modified.
int set(size_t index, type value)
Sets a knowledge variable to a specified value.
std::vector< Integer > to_integers(void) const
converts the value to a vector of integers
Provides functions and classes for the distributed knowledge base.
std::string get_delimiter(void)
Gets the delimiter for adding and detecting subvariables.
KnowledgeUpdateSettings settings_
Settings for modifications.
Settings for applying knowledge updates.
madara::knowledge::KnowledgeRecord get(const std::string &key, const KnowledgeReferenceSettings &settings=KnowledgeReferenceSettings()) const
Atomically returns the value of a variable.
virtual std::string get_debug_info_(void)
Returns the type of the container along with name and any other useful information.
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.
knowledge::KnowledgeRecord to_record(size_t index) const
Retrieves a copy of the record from the vector.
void copy_to(KnowledgeVector &target) const
Copies the vector elements to an STL vector of Knowledge Records.
bool is_false(void) const
Checks to see if the record is false.
Settings for applying knowledge updates.
bool is_true(void) const
Determines if all values in the vector are true.
std::string to_string(const std::string &delimiter=", ") const
converts the value to a string.
void exchange(IntegerVectorVector &other, bool refresh_keys=true, bool delete_keys=true)
Exchanges the vector at this location with the vector at another location.
void set_name(const std::string &var_name, KnowledgeBase &knowledge, int size=-1)
Sets the variable name that this refers to.
Provides an interface for external functions into the MADARA KaRL variable settings.
This class is an abstract base class for all containers.
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.
ThreadSafeContext * context_
Variable context that we are modifying.