MADARA  3.1.8
DoubleVector2D.h
Go to the documentation of this file.
1 
2 #ifndef _MADARA_CONTAINERS_DOUBLE_VECTOR2D_H_
3 #define _MADARA_CONTAINERS_DOUBLE_VECTOR2D_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  {
32  class MADARA_Export DoubleVector2D : public BaseContainer
33  {
34  public:
36  struct Indices
37  {
38  std::size_t x, y;
39  };
40 
43 
45  typedef double type;
46 
52  DoubleVector2D (const KnowledgeUpdateSettings & settings =
54  const std::string & delimiter = ".");
55 
65  DoubleVector2D (const std::string & name,
67  const Dimensions & dimensions = {0,0},
68  bool delete_vars = true,
69  const KnowledgeUpdateSettings & settings =
71  const std::string & delimiter = ".");
72 
82  DoubleVector2D (const std::string & name,
83  Variables & knowledge,
84  const Dimensions & dimensions = {0,0},
85  bool delete_vars = true,
86  const KnowledgeUpdateSettings & settings =
88  const std::string & delimiter = ".");
89 
93  DoubleVector2D (const DoubleVector2D & rhs);
94 
98  virtual ~DoubleVector2D ();
99 
104  void copy_to (std::vector<std::vector<type> > & target) const;
105 
110  void modify (void);
111 
117  void modify (const Indices & index);
118 
123  void operator= (const DoubleVector2D & rhs);
124 
131  void resize (const Dimensions & dimensions, bool delete_vars = true);
132 
138  Dimensions size (void) const;
139 
146  void set_name (const std::string & var_name,
147  KnowledgeBase & knowledge, const Dimensions & dimensions = {0,0});
148 
155  void set_name (const std::string & var_name,
156  Variables & knowledge, const Dimensions & dimensions = {0,0});
157 
164  void set_name (const std::string & var_name,
165  ThreadSafeContext & knowledge, const Dimensions & dimensions = {0,0});
166 
174  void set_delimiter (const std::string & delimiter);
175 
183  std::string get_delimiter (void);
184 
191  type operator[] (const Indices & index) const;
192 
199  bool exists (const Indices & index) const;
200 
209  int set (const Indices & index, double value);
210 
217  int set (const std::vector<std::vector<type> > & value);
218 
228  int set (const Indices & index,
229  type value,
230  const KnowledgeUpdateSettings & settings);
231 
239  int set (
240  const std::vector<std::vector<type> > & value,
241  const KnowledgeUpdateSettings & settings);
242 
250  void set_quality (const Indices & index, uint32_t quality,
251  const KnowledgeReferenceSettings & settings =
253 
258  VariableReference get_size_ref (void);
259 
269  std::string get_debug_info (void);
270 
276  virtual BaseContainer * clone (void) const;
277 
282  bool is_true (void) const;
283 
288  bool is_false (void) const;
289 
290  private:
291 
296  virtual bool is_true_ (void) const;
297 
302  virtual bool is_false_ (void) const;
303 
312  virtual void modify_ (void);
313 
323  virtual std::string get_debug_info_ (void);
324 
329 
333  std::vector <std::vector <VariableReference> > vector_;
334 
339 
344  };
345  }
346  }
347 }
348 
349 #endif // _MADARA_CONTAINERS_DOUBLE_VECTOR2D_H_
350 
This class stores variables and their values for use by any entity needing state information in a thr...
Manages a 2D array of doubles as a virtual overlay in the KnowledgeBase.
Optimized reference to a variable within the knowledge base.
Provides container classes for fast knowledge base access and mutation.
Definition: Barrier.h:27
Indices Dimensions
convenience typedef for size
double type
convenience typedef for element type
std::vector< std::vector< VariableReference > > vector_
Values of the array.
This class provides a distributed knowledge base to users.
Definition: KnowledgeBase.h:44
ThreadSafeContext * context_
Variable context that we are modifying.
static constexpr struct madara::knowledge::tags::string_t string
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.
std::string delimiter_
Delimiter for the prefix to subvars.
Settings for applying knowledge updates.
Copyright (c) 2015 Carnegie Mellon University.
VariableReference size_
Reference to the size of 2D array.
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