MADARA  3.2.3
NativeIntegerVectorStaged.cpp
Go to the documentation of this file.
3 
5  const KnowledgeUpdateSettings & settings)
6 : BaseContainer ("", settings), context_ (0), has_changed_ (false)
7 {
10  "NativeIntegerVectorStaged::constructor: new object\n");
11 }
12 
14  const std::string & name,
16  int size,
17  const KnowledgeUpdateSettings & settings)
18 : BaseContainer (name, settings), context_ (&(knowledge.get_context ())),
19  has_changed_ (false)
20 {
23  "NativeIntegerVectorStaged::constructor called for %s[%d]\n",
24  name.c_str (), size);
25 
26  vector_ = knowledge.get_ref (name, KnowledgeUpdateSettings (true));
27  if (size >= 0)
28  {
29  resize (size);
30  }
31 }
32 
34  const std::string & name,
36  int size,
37  const KnowledgeUpdateSettings & settings)
38 : BaseContainer (name, settings), context_ (knowledge.get_context ()),
39  has_changed_ (false)
40 {
43  "NativeIntegerVectorStaged::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 NativeIntegerVectorStaged & rhs)
55 : BaseContainer (rhs), context_ (rhs.context_),
56  vector_ (rhs.vector_), has_changed_ (false)
57 {
60  "NativeIntegerVectorStaged::copy constructor called on %s\n",
61  rhs.name_.c_str ());
62 }
63 
65 {
68  "NativeIntegerVectorStaged::destructor called on %s\n",
69  this->name_.c_str ());
70 
71  write ();
72 }
73 
76 {
77  return new NativeIntegerVectorStaged (*this);
78 }
79 
80 bool
82 {
83  return is_false ();
84 }
85 
86 bool
88 {
89  return is_true ();
90 }
91 
92 inline void
94 {
95  modify ();
96 }
This class stores a vector of doubles inside of KaRL.
VariableReference get_ref(const std::string &key, const KnowledgeReferenceSettings &settings=knowledge::KnowledgeReferenceSettings(false))
Retrieves the value of a variable.
NativeIntegerVectorStaged(const KnowledgeUpdateSettings &settings=KnowledgeUpdateSettings())
Default constructor.
ThreadSafeContext * context_
Variable context that we are modifying.
std::string name_
Prefix of variable.
MADARA_EXPORT utility::Refcounter< logger::Logger > global_logger
size_t size(void) const
Returns the size of the vector.
bool is_true(void) const
Determines if all values in the vector are true.
void write(void)
Writes the value to the knowledge base.
static struct madara::knowledge::tags::string_t string
VariableReference vector_
Reference to the size field of the vector space.
bool is_false(void) const
Determines if the value of the vector is false.
#define madara_logger_ptr_log(logger, level,...)
Fast version of the madara::logger::log method for Logger pointers.
Definition: Logger.h:32
bool has_changed_
Tracks if value_ has changed since last read.
This class provides a distributed knowledge base to users.
Definition: KnowledgeBase.h:45
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.
Provides functions and classes for the distributed knowledge base.
virtual void modify_(void)
Polymorphic modify method used by collection 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 ...
Settings for applying knowledge updates.
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
VariableReference get_ref(const std::string &key, const KnowledgeReferenceSettings &settings=KnowledgeReferenceSettings(false))
Atomically returns a reference to the variable.