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 <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_);
564 MADARA_GUARD_TYPE guard (
mutex_);
580 MADARA_GUARD_TYPE guard (
mutex_);
597 MADARA_GUARD_TYPE guard (
mutex_);
607 const std::vector <type> & value)
614 MADARA_GUARD_TYPE guard (
mutex_);
615 if (
vector_.size () < value.size ())
616 resize ((
int)value.size (),
false);
618 for (
size_t i = 0; i < value.size (); ++i)
640 MADARA_GUARD_TYPE guard (
mutex_);
650 const std::vector <type> & value,
658 MADARA_GUARD_TYPE guard (
mutex_);
659 if (
vector_.size () < value.size ())
660 resize ((
int)value.size (),
false);
662 for (
size_t i = 0; i < value.size (); ++i)
682 MADARA_GUARD_TYPE guard (
mutex_);
694 "DoubleVectorVector::is_true: Checking for truth\n");
699 MADARA_GUARD_TYPE guard (
mutex_);
704 "DoubleVectorVector::is_true: context was not null. Result changed to %d\n",
707 for (
size_t index = 0; index <
vector_.size (); ++index)
711 "DoubleVectorVector::is_true: checking index %d, is_false of %d. \n",
717 "DoubleVectorVector::is_true: result is false, breaking\n");
729 "DoubleVectorVector::is_true: final result is %d\n", (int)result);
This class encapsulates an entry in a KnowledgeBase.
This class stores a vector of NativeDoubleVectors.
int set(const std::string &key, T &&value, const KnowledgeUpdateSettings &settings=KnowledgeUpdateSettings())
Atomically sets the value of a variable to the specific record.
std::string get_delimiter(void)
Gets the delimiter for adding and detecting subvariables.
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.
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.
virtual ~DoubleVectorVector()
Destructor.
virtual BaseContainer * clone(void) const
Clones this container.
madara::knowledge::KnowledgeRecord KnowledgeRecord
int set(size_t index, type value)
Sets a knowledge variable to a specified value.
virtual std::string get_debug_info_(void)
Returns the type of the container along with name and any other useful information.
double to_double(void) const
converts the value to a float/double
std::string name_
Prefix of variable.
void transfer_to(DoubleVectorVector &other)
Transfers elements from this vector to another.
knowledge::KnowledgeRecord to_record(size_t index) const
Retrieves a copy of the record from the vector.
This class stores variables and their values for use by any entity needing state information in a thr...
bool is_true(void) const
Determines if all values in the vector are true.
MADARA_LOCK_TYPE mutex_
guard for access and changes
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_false(void) const
Determines if the value of the vector is false.
type operator[](size_t index) const
Retrieves a copy of the record from the vector.
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.
void operator=(const DoubleVectorVector &rhs)
Assignment operator.
::std::vector< KnowledgeRecord > KnowledgeVector
DoubleVectorVector(const KnowledgeUpdateSettings &settings=KnowledgeUpdateSettings(), const std::string &delimiter=".")
Default constructor.
A thread-safe guard for a context or knowledge base.
void exchange(DoubleVectorVector &other, bool refresh_keys=true, bool delete_keys=true)
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.
std::vector< VariableReference > vector_
Values of the array.
void push_back(const type &value)
Pushes the value to the end of the array after incrementing the array size.
void set_delimiter(const std::string &delimiter)
Sets the delimiter for adding and detecting subvariables.
This class provides a distributed knowledge base to users.
std::vector< double > to_doubles(void) const
converts the value to a vector of doubles
void resize(int size=-1, bool delete_vars=true)
Resizes the vector.
void copy_to(KnowledgeVector &target) const
Copies the vector elements to an STL vector of Knowledge Records.
Integer to_integer(void) const
converts the value to an integer
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 modify(void)
Mark the vector as modified.
ThreadSafeContext * context_
Variable context that we are modifying.
bool exists(size_t index) const
Checks to see if the index has ever been assigned a value.
std::vector< double > type
trait that describes the value type
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.
size_t size(void) const
Returns the size of the local vector.
virtual void modify_(void)
Polymorphic modify method used by collection containers.
VariableReference get_size_ref(void)
Returns a reference to the size field of the current name.
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.
VariableReference size_
Reference to the size field of the vector space.
Settings for applying knowledge updates.
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.
bool is_false(void) const
Checks to see if the record is false.
Settings for applying knowledge updates.
std::string to_string(const std::string &delimiter=", ") const
converts the value to a string.
std::string delimiter_
Delimiter for the prefix to subvars.
Provides an interface for external functions into the MADARA KaRL variable settings.
This class is an abstract base class for all containers.
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_name(const std::string &var_name, KnowledgeBase &knowledge, int size=-1)
Sets the variable name that this refers to.
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.