MADARA  3.4.1
IntegerVector.h
Go to the documentation of this file.
1 
2 #ifndef _MADARA_CONTAINERS_INTEGER_VECTOR_H_
3 #define _MADARA_CONTAINERS_INTEGER_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 IntegerVector : public BaseContainer
32 {
33 public:
36 
44  const std::string& delimiter = ".");
45 
56  int size = -1, bool delete_vars = true,
58  const std::string& delimiter = ".");
59 
69  IntegerVector(const std::string& name, Variables& knowledge, int size = -1,
70  bool delete_vars = true,
72  const std::string& delimiter = ".");
73 
77  IntegerVector(const IntegerVector& rhs);
78 
82  virtual ~IntegerVector();
83 
88  void modify(void);
89 
95  void modify(size_t index);
96 
101  void operator=(const IntegerVector& rhs);
102 
108  void push_back(type value);
109 
116  void resize(int size = -1, bool delete_vars = true);
117 
126  void exchange(
127  IntegerVector& other, bool refresh_keys = true, bool delete_keys = true);
128 
133  void transfer_to(IntegerVector& other);
134 
139  void copy_to(KnowledgeVector& target) const;
140 
145  void copy_to(std::vector<type>& target) const;
146 
152  size_t size(void) const;
153 
160  void set_name(
161  const std::string& var_name, KnowledgeBase& knowledge, int size = -1);
162 
169  void set_name(
170  const std::string& var_name, Variables& knowledge, int size = -1);
171 
178  void set_name(
179  const std::string& var_name, ThreadSafeContext& knowledge, int size = -1);
180 
188  void set_delimiter(const std::string& delimiter);
189 
197  std::string get_delimiter(void);
198 
205  type operator[](size_t index) const;
206 
213  knowledge::KnowledgeRecord to_record(size_t index) const;
214 
219  knowledge::KnowledgeRecord to_record(void) const;
220 
227  bool exists(size_t index) const;
228 
235  type inc(size_t index);
236 
245  int set(size_t index,
247 
257  int set(
258  size_t index, const type& value, const KnowledgeUpdateSettings& settings);
259 
267  int set(const std::vector<type>& value);
268 
277  int set(
278  const std::vector<type>& value, const KnowledgeUpdateSettings& settings);
279 
287  void set_quality(size_t index, uint32_t quality,
289  false));
290 
295  VariableReference get_size_ref(void);
296 
306  std::string get_debug_info(void);
307 
313  virtual BaseContainer* clone(void) const;
314 
319  bool is_true(void) const;
320 
325  bool is_false(void) const;
326 
327 private:
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_INTEGER_VECTOR_H_
This class provides a distributed knowledge base to users.
Definition: KnowledgeBase.h:45
This class encapsulates an entry in a KnowledgeBase.
Settings for applying knowledge updates.
Settings for applying knowledge updates.
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 an interface for external functions into the MADARA KaRL variable settings.
Definition: Variables.h:53
This class is an abstract base class for all containers.
Definition: BaseContainer.h:34
This class stores a vector of integers inside of KaRL.
Definition: IntegerVector.h:32
VariableReference size_
Reference to the size field of the vector space.
knowledge::KnowledgeRecord::Integer type
trait that describes the value type
Definition: IntegerVector.h:35
std::vector< VariableReference > vector_
Values of the array.
std::string delimiter_
Delimiter for the prefix to subvars.
ThreadSafeContext * context_
Variable context that we are modifying.
Provides container classes for fast knowledge base access and mutation.
Definition: Barrier.h:27
IntegerVector IntegerArray
provide the Array alias for the IntegerVector class
constexpr string_t string
Provides functions and classes for the distributed knowledge base.
::std::vector< KnowledgeRecord > KnowledgeVector
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.
Copyright(c) 2020 Galois.