MADARA  3.2.3
IntegerVector2D.h
Go to the documentation of this file.
1 
2 #ifndef _MADARA_CONTAINERS_INTEGER_VECTOR2D_H_
3 #define _MADARA_CONTAINERS_INTEGER_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 IntegerVector2D : public BaseContainer
33  {
34  public:
36  struct Indices
37  {
38  std::size_t x, y;
39  };
40 
43 
46 
52  IntegerVector2D (const KnowledgeUpdateSettings & settings =
54  const std::string & delimiter = ".");
55 
65  IntegerVector2D (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  IntegerVector2D (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  IntegerVector2D (const IntegerVector2D & rhs);
94 
98  virtual ~IntegerVector2D ();
99 
104  void copy_to (
105  std::vector<std::vector<type> > & target) const;
106 
111  void modify (void);
112 
118  void modify (const Indices & index);
119 
124  void operator= (const IntegerVector2D & rhs);
125 
132  void resize (const Dimensions & dimensions, bool delete_vars = true);
133 
139  Dimensions size (void) const;
140 
147  void set_name (const std::string & var_name,
148  KnowledgeBase & knowledge, const Dimensions & dimensions = {0,0});
149 
156  void set_name (const std::string & var_name,
157  Variables & knowledge, const Dimensions & dimensions = {0,0});
158 
165  void set_name (const std::string & var_name,
166  ThreadSafeContext & knowledge, const Dimensions & dimensions = {0,0});
167 
175  void set_delimiter (const std::string & delimiter);
176 
184  std::string get_delimiter (void);
185 
192  type operator[] (const Indices & index) const;
193 
200  bool exists (const Indices & index) const;
201 
210  int set (const Indices & index, type value);
211 
218  int set (const std::vector<std::vector<type> > & value);
219 
229  int set (const Indices & index,
230  type value,
231  const KnowledgeUpdateSettings & settings);
232 
240  int set (
241  const std::vector<std::vector<type> > & value,
242  const KnowledgeUpdateSettings & settings);
243 
251  void set_quality (const Indices & index, uint32_t quality,
252  const KnowledgeReferenceSettings & settings =
254 
259  VariableReference get_size_ref (void);
260 
270  std::string get_debug_info (void);
271 
277  virtual BaseContainer * clone (void) const;
278 
283  bool is_true (void) const;
284 
289  bool is_false (void) const;
290 
291  private:
292 
297  virtual bool is_true_ (void) const;
298 
303  virtual bool is_false_ (void) const;
304 
313  virtual void modify_ (void);
314 
324  virtual std::string get_debug_info_ (void);
325 
330 
334  std::vector <std::vector <VariableReference> > vector_;
335 
340 
345  };
346  }
347  }
348 }
349 
350 #endif // _MADARA_CONTAINERS_INTEGER_VECTOR2D_H_
351 
Manages a 2D array of integers as a virtual overlay in the KnowledgeBase.
This class stores variables and their values for use by any entity needing state information in a thr...
std::string delimiter_
Delimiter for the prefix to subvars.
ThreadSafeContext * context_
Variable context that we are modifying.
Optimized reference to a variable within the knowledge base.
Provides container classes for fast knowledge base access and mutation.
Definition: Barrier.h:27
static struct madara::knowledge::tags::string_t string
This class provides a distributed knowledge base to users.
Definition: KnowledgeBase.h:45
VariableReference size_
Reference to the size of 2D array.
Indices Dimensions
convenience typedef for size
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.
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
std::vector< std::vector< VariableReference > > vector_
Values of the array.
KnowledgeRecord::Integer type
convenience typedef for element type