22 "NativeDoubleVector::constructor called for %s[%d]\n",
37 :
context_ (knowledge.get_context ())
41 "NativeDoubleVector::constructor called for %s[%d]\n",
58 "NativeDoubleVector::copy constructor called on %s\n",
67 "NativeDoubleVector::destructor called on %s\n",
68 this->
name_.c_str ());
76 "NativeDoubleVector::modify called\n");
83 "NativeDoubleVector::modify: context is valid. Marking %s.\n",
84 this->
name_.c_str ());
94 std::stringstream result;
96 result <<
"Native Double Vector: ";
101 MADARA_GUARD_TYPE guard (
mutex_);
103 result << this->
name_;
104 result <<
" [" <<
size () <<
"]";
108 return result.str ();
129 "NativeDoubleVector::clone: cloning %s\n",
130 this->
name_.c_str ());
145 "NativeDoubleVector::assignment: %s: copying from %s.\n",
146 this->
name_.c_str (),
164 "NativeDoubleVector::push_back: %s: valid context, pushing.\n",
165 this->
name_.c_str ());
168 MADARA_GUARD_TYPE guard (
mutex_);
183 MADARA_GUARD_TYPE guard (
mutex_);
187 "NativeDoubleVector::resize: %s: resizing to %d\n",
188 this->
name_.c_str (),
203 MADARA_GUARD_TYPE guard (
mutex_);
218 MADARA_GUARD_TYPE guard (
mutex_);
222 "NativeDoubleVector::set_name: setting name to %s\n",
244 MADARA_GUARD_TYPE guard (
mutex_);
248 "NativeDoubleVector::set_name: setting name to %s\n",
270 MADARA_GUARD_TYPE guard (
mutex_);
274 "NativeDoubleVector::set_name: setting name to %s\n",
294 MADARA_GUARD_TYPE guard (
mutex_), guard2 (other.
mutex_);
298 "NativeDoubleVector::exchange: %s exchanging with %s\n",
299 this->
name_.c_str (),
300 other.
name_.c_str ());
317 MADARA_GUARD_TYPE guard (
mutex_);
318 MADARA_GUARD_TYPE guard2 (other.
mutex_);
322 "NativeDoubleVector::transfer_to: %s transfering to %s\n",
323 this->
name_.c_str (),
324 other.
name_.c_str ());
326 size_t other_size = other.
size ();
327 size_t this_size = this->
size ();
333 "NativeDoubleVector::transfer_to: %s has elements\n",
334 this->
name_.c_str ());
336 size_t size = other_size + this_size;
342 rhs.
set_index (size - 1, lhs.retrieve_index (this_size - 1).to_double ());
344 for (
size_t i = 0, j = other_size; i < this_size - 1; ++i, ++j)
346 rhs.set_index (other_size, lhs.retrieve_index (i).to_double ());
363 MADARA_GUARD_TYPE guard (
mutex_);
367 "NativeDoubleVector::copy_to: %s: copying elements to vector\n",
368 this->
name_.c_str ());
370 target.resize (
size ());
372 for (
size_t i = 0; i < target.size (); ++i)
388 MADARA_GUARD_TYPE guard (
mutex_);
392 "NativeDoubleVector[]: %s: retrieving element from container\n",
393 this->
name_.c_str ());
397 if (index < result.size ())
414 MADARA_GUARD_TYPE guard (
mutex_);
418 "NativeDoubleVector::set: %s: setting element [%d] to %f\n",
419 this->
name_.c_str (),
439 MADARA_GUARD_TYPE guard (
mutex_);
443 "NativeDoubleVector::set: %s: setting element [%d] " 444 "to %f with custom settings\n",
445 this->
name_.c_str (),
456 const std::vector <type> & value)
463 MADARA_GUARD_TYPE guard (
mutex_);
467 "NativeDoubleVector::set: %s: setting all elements\n",
468 this->
name_.c_str ());
478 const std::vector <type> & value,
486 MADARA_GUARD_TYPE guard (
mutex_);
490 "NativeDoubleVector::set: %s: setting all elements " 491 "with custom settings\n",
492 this->
name_.c_str ());
509 MADARA_GUARD_TYPE guard (
mutex_);
513 "NativeDoubleVector::set: %s: setting quality of knowledge\n",
514 this->
name_.c_str ());
526 "NativeDoubleVector::to_record: %s: retrieving record\n",
527 this->
name_.c_str ());
541 "NativeDoubleVector::to_record: %s: retrieving record\n",
542 this->
name_.c_str ());
553 "NativeDoubleVector::is_true: %s: Checking for non-zero value\n",
554 this->
name_.c_str ());
559 MADARA_GUARD_TYPE guard (
mutex_);
564 "NativeDoubleVector::is_true: %s: final result is %d\n",
565 this->
name_.c_str (),
This class encapsulates an entry in a KnowledgeBase.
knowledge::KnowledgeRecord to_record(void) const
Retrieves the entire vector as a native double array in a record.
int set(const std::string &key, T &&value, const KnowledgeUpdateSettings &settings=KnowledgeUpdateSettings())
Atomically sets the value of a variable to the specific record.
bool is_true(void) const
Checks to see if the record is true.
void copy_to(KnowledgeVector &target) const
Copies the vector elements to an STL vector of Knowledge Records.
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
double to_double(void) const
converts the value to a float/double
NativeDoubleVector(const KnowledgeUpdateSettings &settings=KnowledgeUpdateSettings())
Default constructor.
std::string name_
Prefix of variable.
bool is_true(void) const
Determines if all values in the vector are true.
virtual BaseContainer * clone(void) const
Clones this container.
double 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...
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 ...
size_t size(void) const
Returns the size of the vector.
MADARA_Export utility::Refcounter< logger::Logger > global_logger
void resize(size_t size)
Resizes the vector.
MADARA_LOCK_TYPE mutex_
guard for access and changes
virtual void modify_(void)
Polymorphic modify method used by collection containers.
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.
int set(size_t index, type value)
Sets a knowledge variable to a specified value.
#define madara_logger_log(logger, level,...)
Fast version of the madara::logger::log method.
type operator[](size_t index) const
Retrieves a copy of the record from the map.
void transfer_to(NativeDoubleVector &other)
Transfers elements from this vector to another.
void set_name(const std::string &var_name, KnowledgeBase &knowledge, int size=-1)
Sets the variable name that this refers to.
::std::vector< KnowledgeRecord > KnowledgeVector
ThreadSafeContext * context_
Variable context that we are modifying.
A thread-safe guard for a context or knowledge base.
std::string get_debug_info(void)
Returns the type of the container along with name and any other useful information.
VariableReference vector_
Reference to the size field of the vector space.
#define madara_logger_ptr_log(logger, level,...)
Fast version of the madara::logger::log method for Logger pointers.
This class provides a distributed knowledge base to users.
bool is_false(void) const
Determines if the value of the vector is false.
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.
This class stores a vector of doubles inside of KaRL.
void set_index(size_t index, T value)
sets the value at the index to the specified value.
void push_back(type value)
Pushes the value to the end of the array after incrementing the array size.
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 operator=(const NativeDoubleVector &rhs)
Assignment operator.
void exchange(NativeDoubleVector &other)
Exchanges the vector at this location with the vector at another location.
ThreadSafeContext & get_context(void)
Returns the ThreadSafeContext associated with this Knowledge Base.
void modify(void)
Mark the value as modified.
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.
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.
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
virtual 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(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.
virtual ~NativeDoubleVector()
Destructor.