10 "NativeDoubleVector::constructor: new object\n");
19 "NativeDoubleVector::constructor called for %s[%d]\n", name.c_str(),
35 "NativeDoubleVector::constructor called for %s[%d]\n", name.c_str(),
50 "NativeDoubleVector::copy constructor called on %s\n", rhs.
name_.c_str());
56 "NativeDoubleVector::destructor called on %s\n", this->name_.c_str());
62 "NativeDoubleVector::modify called\n");
68 "NativeDoubleVector::modify: context is valid. Marking %s.\n",
78 std::stringstream result;
80 result <<
"Native Double Vector: ";
85 MADARA_GUARD_TYPE guard(mutex_);
87 result << this->name_;
88 result <<
" [" << size() <<
"]";
89 result <<
" = " <<
context_->get(vector_).to_string();
103 return get_debug_info();
110 "NativeDoubleVector::clone: cloning %s\n", this->name_.c_str());
120 MADARA_GUARD_TYPE guard(mutex_), guard2(rhs.
mutex_);
123 "NativeDoubleVector::assignment: %s: copying from %s.\n",
124 this->name_.c_str(), rhs.
name_.c_str());
127 this->name_ = rhs.
name_;
138 "NativeDoubleVector::push_back: %s: valid context, pushing.\n",
139 this->name_.c_str());
142 MADARA_GUARD_TYPE guard(mutex_);
155 MADARA_GUARD_TYPE guard(mutex_);
158 "NativeDoubleVector::resize: %s: resizing to %d\n", this->name_.c_str(),
165 context_->set(vector_, value, settings_);
172 MADARA_GUARD_TYPE guard(mutex_);
174 return context_->get(vector_, settings_).size();
185 MADARA_GUARD_TYPE guard(mutex_);
188 "NativeDoubleVector::set_name: setting name to %s\n", var_name.c_str());
192 vector_ =
knowledge.get_ref(var_name, settings_);
195 resize(
size_t(size));
207 MADARA_GUARD_TYPE guard(mutex_);
210 "NativeDoubleVector::set_name: setting name to %s\n", var_name.c_str());
214 vector_ =
knowledge.get_ref(var_name, settings_);
217 resize(
size_t(size));
229 MADARA_GUARD_TYPE guard(mutex_);
232 "NativeDoubleVector::set_name: setting name to %s\n", var_name.c_str());
236 vector_ =
knowledge.get_ref(var_name, settings_);
239 resize(
size_t(size));
252 MADARA_GUARD_TYPE guard(mutex_, std::adopt_lock),
253 guard2(other.
mutex_, std::adopt_lock);
256 "NativeDoubleVector::exchange: %s exchanging with %s\n",
257 this->name_.c_str(), other.
name_.c_str());
262 context_->set(vector_, temp, settings_);
275 MADARA_GUARD_TYPE guard(mutex_, std::adopt_lock),
276 guard2(other.
mutex_, std::adopt_lock);
279 "NativeDoubleVector::transfer_to: %s transfering to %s\n",
280 this->name_.c_str(), other.
name_.c_str());
282 size_t other_size = other.
size();
283 size_t this_size = this->size();
288 "NativeDoubleVector::transfer_to: %s has elements\n",
289 this->name_.c_str());
291 size_t size = other_size + this_size;
299 for (
size_t i = 0, j = other_size; i < this_size - 1; ++i, ++j)
317 MADARA_GUARD_TYPE guard(mutex_);
320 "NativeDoubleVector::copy_to: %s: copying elements to vector\n",
321 this->name_.c_str());
323 target.resize(size());
325 for (
size_t i = 0; i < target.size(); ++i)
341 MADARA_GUARD_TYPE guard(mutex_);
344 "NativeDoubleVector[]: %s: retrieving element from container\n",
345 this->name_.c_str());
347 result =
context_->get(vector_, settings_);
349 if (index < result.
size())
357 size_t index,
type value)
364 MADARA_GUARD_TYPE guard(mutex_);
367 "NativeDoubleVector::set: %s: setting element [%d] to %f\n",
368 this->name_.c_str(), (
int)index, value);
370 result =
context_->set_index(vector_, index, value, settings_);
384 MADARA_GUARD_TYPE guard(mutex_);
387 "NativeDoubleVector::set: %s: setting element [%d] "
388 "to %f with custom settings\n",
389 this->name_.c_str(), (
int)index, value);
391 result =
context_->set_index(vector_, index, value, settings);
398 const std::vector<type>& value)
405 MADARA_GUARD_TYPE guard(mutex_);
408 "NativeDoubleVector::set: %s: setting all elements\n",
409 this->name_.c_str());
411 context_->set(vector_, value, settings_);
425 MADARA_GUARD_TYPE guard(mutex_);
428 "NativeDoubleVector::set: %s: setting all elements "
429 "with custom settings\n",
430 this->name_.c_str());
432 context_->set(vector_, value, settings);
439 const double* values, uint32_t size)
446 MADARA_GUARD_TYPE guard(mutex_);
449 "NativeDoubleVector::set: %s: setting all elements\n",
450 this->name_.c_str());
452 context_->set(vector_, values, size, settings_);
466 MADARA_GUARD_TYPE guard(mutex_);
469 "NativeDoubleVector::set: %s: setting all elements "
470 "with custom settings\n",
471 this->name_.c_str());
473 context_->set(vector_, values, size, settings);
480 size_t , uint32_t quality,
486 MADARA_GUARD_TYPE guard(mutex_);
489 "NativeDoubleVector::set: %s: setting quality of knowledge\n",
490 this->name_.c_str());
492 context_->set_quality(name_, quality,
true, settings);
503 MADARA_GUARD_TYPE guard(mutex_);
514 "NativeDoubleVector::to)doubles: %s: retrieving double vector\n",
515 this->name_.c_str());
517 return context_->get(this->vector_, settings_).to_doubles();
524 "NativeDoubleVector::to_record: %s: retrieving record\n",
525 this->name_.c_str());
528 context_->get(this->vector_, settings_);
538 "NativeDoubleVector::to_record: %s: retrieving record\n",
539 this->name_.c_str());
541 return context_->get(this->vector_, settings_);
549 "NativeDoubleVector::is_true: %s: Checking for non-zero value\n",
550 this->name_.c_str());
555 MADARA_GUARD_TYPE guard(mutex_);
556 result =
context_->get(vector_, settings_).is_true();
560 "NativeDoubleVector::is_true: %s: final result is %d\n",
561 this->name_.c_str(), (
int)result);
#define madara_logger_ptr_log(loggering, level,...)
Fast version of the madara::logger::log method for Logger pointers.
#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
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.
void modify(void)
Mark the value as modified.
size_t size(void) const
Returns the size of the vector.
virtual BaseContainer * clone(void) const
Clones this container.
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.
NativeDoubleVector(const KnowledgeUpdateSettings &settings=KnowledgeUpdateSettings())
Default constructor.
void operator=(const NativeDoubleVector &rhs)
Assignment operator.
void resize(size_t size)
Resizes the vector.
double type
trait that describes the value type
void set_name(const std::string &var_name, KnowledgeBase &knowledge, int size=-1)
Sets the variable name that this refers to.
int set(size_t index, type value)
Sets a knowledge variable to a specified value.
void transfer_to(NativeDoubleVector &other)
Transfers elements from this vector to another.
std::vector< double > to_doubles(void) const
Retrieves the native double array from inside the record.
knowledge::KnowledgeRecord to_record(void) const
Retrieves the entire vector as a native double array in a record.
virtual std::string get_debug_info_(void)
Returns the type of the container along with name and any other useful information.
void push_back(type value)
Pushes the value to the end of the array after incrementing the array size.
bool is_true(void) const
Determines if all values in the vector are true.
ThreadSafeContext * context_
Variable context that we are modifying.
virtual bool is_true_(void) const
Polymorphic is true method which can be used to determine if all values in the container are true.
bool exists(void) const
Checks to see if the variable has ever been assigned a value.
type operator[](size_t index) const
Retrieves a copy of the record from the map.
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 copy_to(KnowledgeVector &target) const
Copies the vector elements to an STL vector of Knowledge Records.
void exchange(NativeDoubleVector &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.
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.
virtual ~NativeDoubleVector()
Destructor.
Provides functions and classes for the distributed knowledge base.
::std::vector< KnowledgeRecord > KnowledgeVector
T get(const KnowledgeRecord &kr)
Get the value of a KnowlegeRecord.
MADARA_EXPORT utility::Refcounter< logger::Logger > global_logger