MADARA  3.2.3
DoubleVector.h
Go to the documentation of this file.
1 
2 #ifndef _MADARA_CONTAINERS_DOUBLE_VECTOR_H_
3 #define _MADARA_CONTAINERS_DOUBLE_VECTOR_H_
4 
5 #include <vector>
6 #include <string>
7 #include "madara/LockType.h"
11 #include "BaseContainer.h"
12 
21 namespace madara
22 {
23  namespace knowledge
24  {
25  namespace containers
26  {
31  class MADARA_EXPORT DoubleVector : public BaseContainer
32  {
33  public:
35  typedef double type;
36 
42  DoubleVector (const KnowledgeUpdateSettings & settings =
44  const std::string & delimiter = ".");
45 
55  DoubleVector (const std::string & name,
57  int size = -1,
58  bool delete_vars = true,
59  const KnowledgeUpdateSettings & settings =
61  const std::string & delimiter = ".");
62 
72  DoubleVector (const std::string & name,
73  Variables & knowledge,
74  int size = -1,
75  bool delete_vars = true,
76  const KnowledgeUpdateSettings & settings =
78  const std::string & delimiter = ".");
79 
83  DoubleVector (const DoubleVector & rhs);
84 
88  virtual ~DoubleVector ();
89 
94  void modify (void);
95 
101  void modify (size_t index);
102 
107  void operator= (const DoubleVector & rhs);
108 
114  void push_back (type value);
115 
122  void resize (int size = -1, bool delete_vars = true);
123 
132  void exchange (DoubleVector & other, bool refresh_keys = true,
133  bool delete_keys = true);
134 
139  void copy_to (KnowledgeVector & target) const;
140 
145  void copy_to (std::vector <type> & target) const;
146 
151  void transfer_to (DoubleVector & other);
152 
158  size_t size (void) const;
159 
166  void set_name (const std::string & var_name,
167  KnowledgeBase & knowledge, int size = -1);
168 
175  void set_name (const std::string & var_name,
176  Variables & knowledge, int size = -1);
177 
184  void set_name (const std::string & var_name,
185  ThreadSafeContext & knowledge, int size = -1);
186 
194  void set_delimiter (const std::string & delimiter);
195 
203  std::string get_delimiter (void);
204 
211  type operator[] (size_t index) const;
212 
219  knowledge::KnowledgeRecord to_record (size_t index) const;
220 
225  knowledge::KnowledgeRecord to_record (void) const;
226 
233  bool exists (size_t index) const;
234 
243  int set (size_t index, type value);
244 
252  int set (const std::vector <type> & value);
253 
263  int set (size_t index,
264  type value,
265  const KnowledgeUpdateSettings & settings);
266 
275  int set (
276  const std::vector <type> & value,
277  const KnowledgeUpdateSettings & settings);
278 
286  void set_quality (size_t index, uint32_t quality,
287  const KnowledgeReferenceSettings & settings =
289 
294  VariableReference get_size_ref (void);
295 
305  std::string get_debug_info (void);
306 
312  virtual BaseContainer * clone (void) const;
313 
318  bool is_true (void) const;
319 
324  bool is_false (void) const;
325 
326  private:
327 
332  virtual bool is_true_ (void) const;
333 
338  virtual bool is_false_ (void) const;
339 
348  virtual void modify_ (void);
349 
359  virtual std::string get_debug_info_ (void);
360 
365 
369  std::vector <VariableReference> vector_;
370 
375 
380  };
381 
384  }
385  }
386 }
387 
388 #endif // _MADARA_CONTAINERS_DOUBLE_VECTOR_H_
This class encapsulates an entry in a KnowledgeBase.
double type
trait that describes the value type
Definition: DoubleVector.h:35
VariableReference size_
Reference to the size field of the vector space.
Definition: DoubleVector.h:374
This class stores variables and their values for use by any entity needing state information in a thr...
Optimized reference to a variable within the knowledge base.
Provides container classes for fast knowledge base access and mutation.
Definition: Barrier.h:27
DoubleVector DoubleArray
provide the Array alias for the DoubleVector class
Definition: DoubleVector.h:383
::std::vector< KnowledgeRecord > KnowledgeVector
std::string delimiter_
Delimiter for the prefix to subvars.
Definition: DoubleVector.h:379
static struct madara::knowledge::tags::string_t string
This class provides a distributed knowledge base to users.
Definition: KnowledgeBase.h:45
std::vector< VariableReference > vector_
Values of the array.
Definition: DoubleVector.h:369
ThreadSafeContext * context_
Variable context that we are modifying.
Definition: DoubleVector.h:364
MADARA_EXPORT bool exists(const char *originator, uint64_t clock, uint32_t update_number, OriginatorFragmentMap &map)
Checks if a fragment already exists within a fragment map.
Provides functions and classes for the distributed knowledge base.
Settings for applying knowledge updates.
Copyright (c) 2015 Carnegie Mellon University.
Settings for applying knowledge updates.
This class stores a vector of doubles inside of KaRL.
Definition: DoubleVector.h:31
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