MADARA  3.4.1
BufferVector.h
Go to the documentation of this file.
1 
2 #ifndef _MADARA_CONTAINERS_BUFFER_VECTOR_H_
3 #define _MADARA_CONTAINERS_BUFFER_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 BufferVector : public BaseContainer
32 {
33 public:
41  const std::string& delimiter = ".");
42 
52  BufferVector(const std::string& name, KnowledgeBase& knowledge, int size = -1,
53  bool delete_vars = true,
55  const std::string& delimiter = ".");
56 
66  BufferVector(const std::string& name, Variables& knowledge, int size = -1,
67  bool delete_vars = true,
69  const std::string& delimiter = ".");
70 
74  BufferVector(const BufferVector& rhs);
75 
79  virtual ~BufferVector();
80 
85  void modify(void);
86 
92  void modify(size_t index);
93 
98  void operator=(const BufferVector& rhs);
99 
106  void push_back(const unsigned char* value, size_t size);
107 
114  void resize(int size = -1, bool delete_vars = true);
115 
124  void exchange(
125  BufferVector& other, bool refresh_keys = true, bool delete_keys = true);
126 
131  void transfer_to(BufferVector& other);
132 
137  void copy_to(KnowledgeVector& target) const;
138 
144  size_t size(void) const;
145 
152  void set_name(
153  const std::string& var_name, KnowledgeBase& knowledge, int size = -1);
154 
161  void set_name(
162  const std::string& var_name, Variables& knowledge, int size = -1);
163 
170  void set_name(
171  const std::string& var_name, ThreadSafeContext& knowledge, int size = -1);
172 
180  void set_delimiter(const std::string& delimiter);
181 
189  std::string get_delimiter(void);
190 
197  knowledge::KnowledgeRecord operator[](size_t index) const;
198 
207  knowledge::KnowledgeRecord to_record(size_t index) const;
208 
215  bool exists(size_t index) const;
216 
222  int read_file(size_t index, const std::string& filename);
223 
230  int read_file(size_t index, const std::string& filename,
231  const KnowledgeUpdateSettings& settings);
232 
239  int set(size_t index, const knowledge::KnowledgeRecord& value);
240 
249  int set_file(size_t index, const unsigned char* value, size_t size);
250 
260  int set_file(size_t index, const unsigned char* value, size_t size,
261  const KnowledgeUpdateSettings& settings);
262 
270  int set_jpeg(size_t index, const unsigned char* value, size_t size);
271 
280  int set_jpeg(size_t index, const unsigned char* value, size_t size,
281  const KnowledgeUpdateSettings& settings);
282 
290  void set_quality(size_t index, uint32_t quality,
292  false));
293 
298  VariableReference get_size_ref(void) const;
299 
309  std::string get_debug_info(void);
310 
316  virtual BaseContainer* clone(void) const;
317 
322  bool is_true(void) const;
323 
328  bool is_false(void) const;
329 
330 private:
335  virtual bool is_true_(void) const;
336 
341  virtual bool is_false_(void) const;
342 
351  virtual void modify_(void);
352 
362  virtual std::string get_debug_info_(void);
363 
368 
372  std::vector<VariableReference> vector_;
373 
378 
383 };
384 
387 }
388 }
389 }
390 
391 #endif // _MADARA_CONTAINERS_BUFFER_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 character buffers.
Definition: BufferVector.h:32
std::vector< VariableReference > vector_
Values of the array.
Definition: BufferVector.h:372
std::string delimiter_
Delimiter for the prefix to subvars.
Definition: BufferVector.h:382
VariableReference size_
Reference to the size field of the vector space.
Definition: BufferVector.h:377
ThreadSafeContext * context_
Variable context that we are modifying.
Definition: BufferVector.h:367
Provides container classes for fast knowledge base access and mutation.
Definition: Barrier.h:27
BufferVector BufferArray
provide the Array alias for the BufferVector class
Definition: BufferVector.h:386
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.
int read_file(const std::string &filename, void *&buffer, size_t &size, bool add_zero_char)
Reads a file into a provided void pointer.
Definition: Utility.cpp:418
Copyright(c) 2020 Galois.