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_);
374 MADARA_GUARD_TYPE guard (
mutex_), guard2 (other.
mutex_);
382 size_t other_size = other.
vector_.size ();
383 size_t this_size = this->
vector_.size ();
385 for (
size_t i = 0; i < this_size; ++i)
404 std::stringstream buffer;
405 buffer << this->
name_;
417 std::stringstream buffer;
418 buffer << other.
name_;
430 for (
size_t i = this_size; i < other_size; ++i)
432 std::stringstream buffer;
433 buffer << this->
name_;
463 MADARA_GUARD_TYPE guard (
mutex_);
464 MADARA_GUARD_TYPE guard2 (other.
mutex_);
466 size_t other_size = other.
vector_.size ();
467 size_t this_size = this->
vector_.size ();
469 size_t size = other_size + this_size;
472 for (
size_t i = 0, j = other_size; i < this_size; ++i, ++j)
488 MADARA_GUARD_TYPE guard (
mutex_);
490 target.resize (
vector_.size ());
492 for (
size_t i = 0; i <
vector_.size (); ++i)
501 std::vector <IntegerVectorVector::type > & target)
const 506 MADARA_GUARD_TYPE guard (
mutex_);
508 target.resize (
vector_.size ());
510 for (
size_t i = 0; i <
vector_.size (); ++i)
512 target[i] = (*this)[i];
527 MADARA_GUARD_TYPE guard (
mutex_);
545 MADARA_GUARD_TYPE guard (
mutex_);
563 MADARA_GUARD_TYPE guard (
mutex_);
579 MADARA_GUARD_TYPE guard (
mutex_);
596 MADARA_GUARD_TYPE guard (
mutex_);
606 const std::vector <type> & value)
613 MADARA_GUARD_TYPE guard (
mutex_);
614 if (
vector_.size () < value.size ())
615 resize ((
int)value.size (),
false);
617 for (
size_t i = 0; i < value.size (); ++i)
639 MADARA_GUARD_TYPE guard (
mutex_);
649 const std::vector <type> & value,
657 MADARA_GUARD_TYPE guard (
mutex_);
658 if (
vector_.size () < value.size ())
659 resize ((
int)value.size (),
false);
661 for (
size_t i = 0; i < value.size (); ++i)
681 MADARA_GUARD_TYPE guard (
mutex_);
693 "IntegerVectorVector::is_true: Checking for truth\n");
698 MADARA_GUARD_TYPE guard (
mutex_);
703 "IntegerVectorVector::is_true: context was not null. Result changed to %d\n",
706 for (
size_t index = 0; index <
vector_.size (); ++index)
710 "IntegerVectorVector::is_true: checking index %d, is_false of %d. \n",
716 "IntegerVectorVector::is_true: result is false, breaking\n");
728 "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 get(const std::string &key, const KnowledgeReferenceSettings &settings=KnowledgeReferenceSettings()) const
Atomically returns the value of a variable.
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.
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.
VariableReference get_ref(const std::string &key, const KnowledgeReferenceSettings &settings=KnowledgeReferenceSettings())
Atomically returns a reference to the variable.
Settings for applying knowledge updates.
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.