MADARA  3.2.3
NativeDoubleVectorStaged.cpp
Go to the documentation of this file.
4 
6  const KnowledgeUpdateSettings & settings)
7 : BaseContainer ("", settings), context_ (0), has_changed_ (false)
8 {
11  "NativeDoubleVectorStaged::constructor: new object\n");
12 }
13 
15  const std::string & name,
17  int size,
18  const KnowledgeUpdateSettings & settings)
19  : BaseContainer (name, settings), context_ (&(knowledge.get_context ())),
20  has_changed_ (false)
21 {
24  "NativeDoubleVectorStaged::constructor called for %s[%d]\n",
25  name.c_str (), size);
26 
27  vector_ = knowledge.get_ref (name, settings_);
28  if (size >= 0)
29  {
30  resize (size);
31  }
32 }
33 
35  const std::string & name,
37  int size,
38  const KnowledgeUpdateSettings & settings)
39 : context_ (knowledge.get_context ()), has_changed_ (false)
40 {
43  "NativeDoubleVectorStaged::constructor called for %s[%d]\n",
44  name.c_str (), size);
45 
46  vector_ = knowledge.get_ref (name, settings);
47  if (size >= 0)
48  {
49  resize (size);
50  }
51 }
52 
54  const NativeDoubleVectorStaged & rhs)
55 : BaseContainer (rhs), context_ (rhs.context_),
56  vector_ (rhs.vector_)
57 {
60  "NativeDoubleVectorStaged::copy constructor called on %s\n",
61  rhs.name_.c_str ());
62 }
63 
64 
66 {
69  "NativeDoubleVectorStaged::destructor called on %s\n",
70  this->name_.c_str ());
71 
72  write ();
73 }
74 
77 {
80  "NativeDoubleVectorStaged::clone: cloning %s\n",
81  this->name_.c_str ());
82 
83  return new NativeDoubleVectorStaged (*this);
84 }
85 
86 bool
88 {
89  return is_false ();
90 }
91 
92 bool
94 {
95  return is_true ();
96 }
97 
98 void
100 {
101  modify ();
102 }
bool has_changed_
Tracks if value_ has changed since last read.
VariableReference get_ref(const std::string &key, const KnowledgeReferenceSettings &settings=knowledge::KnowledgeReferenceSettings(false))
Retrieves the value of a variable.
virtual void modify_(void)
Polymorphic modify method used by collection containers.
This class stores a vector of doubles inside of KaRL.
std::string name_
Prefix of variable.
bool is_true(void) const
Determines if all values in the vector are true.
VariableReference vector_
Reference to the size field of the vector space.
void write(void)
Writes the value to the knowledge base.
MADARA_EXPORT utility::Refcounter< logger::Logger > global_logger
size_t size(void) const
Returns the size of the vector.
virtual bool is_true_(void) const
Polymorphic is true method which can be used to determine if all values in the container are true...
virtual BaseContainer * clone(void) const
Clones this container.
static struct madara::knowledge::tags::string_t string
ThreadSafeContext * context_
Variable context that we are modifying.
#define madara_logger_ptr_log(logger, level,...)
Fast version of the madara::logger::log method for Logger pointers.
Definition: Logger.h:32
This class provides a distributed knowledge base to users.
Definition: KnowledgeBase.h:45
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 ...
Provides functions and classes for the distributed knowledge base.
KnowledgeUpdateSettings settings_
Settings for modifications.
Settings for applying knowledge updates.
bool is_false(void) const
Determines if the value of the vector is false.
Provides an interface for external functions into the MADARA KaRL variable settings.
This class is an abstract base class for all containers.
Definition: BaseContainer.h:33
NativeDoubleVectorStaged(const KnowledgeUpdateSettings &settings=KnowledgeUpdateSettings())
Default constructor.
VariableReference get_ref(const std::string &key, const KnowledgeReferenceSettings &settings=KnowledgeReferenceSettings(false))
Atomically returns a reference to the variable.