MADARA  3.2.3
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:
39  BufferVector (const KnowledgeUpdateSettings & settings =
41  const std::string & delimiter = ".");
42 
52  BufferVector (const std::string & name,
54  int size = -1,
55  bool delete_vars = true,
56  const KnowledgeUpdateSettings & settings =
58  const std::string & delimiter = ".");
59 
69  BufferVector (const std::string & name,
70  Variables & knowledge,
71  int size = -1,
72  bool delete_vars = true,
73  const KnowledgeUpdateSettings & settings =
75  const std::string & delimiter = ".");
76 
80  BufferVector (const BufferVector & rhs);
81 
85  virtual ~BufferVector ();
86 
91  void modify (void);
92 
98  void modify (size_t index);
99 
104  void operator= (const BufferVector & rhs);
105 
112  void push_back (const unsigned char * value, size_t size);
113 
120  void resize (int size = -1, bool delete_vars = true);
121 
130  void exchange (BufferVector & other, bool refresh_keys = true,
131  bool delete_keys = true);
132 
137  void transfer_to (BufferVector & other);
138 
143  void copy_to (KnowledgeVector & target) const;
144 
150  size_t size (void) const;
151 
158  void set_name (const std::string & var_name,
159  KnowledgeBase & knowledge, int size = -1);
160 
167  void set_name (const std::string & var_name,
168  Variables & knowledge, int size = -1);
169 
176  void set_name (const std::string & var_name,
177  ThreadSafeContext & knowledge, int size = -1);
178 
186  void set_delimiter (const std::string & delimiter);
187 
195  std::string get_delimiter (void);
196 
203  knowledge::KnowledgeRecord operator[] (size_t index) const;
204 
213  knowledge::KnowledgeRecord to_record (size_t index) const;
214 
221  bool exists (size_t index) const;
222 
228  int read_file (size_t index,
229  const std::string & filename);
230 
237  int read_file (size_t index,
238  const std::string & filename,
239  const KnowledgeUpdateSettings & settings);
240 
247  int set (size_t index, const knowledge::KnowledgeRecord & value);
248 
257  int set_file (size_t index,
258  const unsigned char * value, size_t size);
259 
269  int set_file (size_t index,
270  const unsigned char * value, size_t size,
271  const KnowledgeUpdateSettings & settings);
272 
280  int set_jpeg (size_t index,
281  const unsigned char * value, size_t size);
282 
291  int set_jpeg (size_t index,
292  const unsigned char * value, size_t size,
293  const KnowledgeUpdateSettings & settings);
294 
302  void set_quality (size_t index, uint32_t quality,
303  const KnowledgeReferenceSettings & settings =
305 
310  VariableReference get_size_ref (void) const;
311 
321  std::string get_debug_info (void);
322 
328  virtual BaseContainer * clone (void) const;
329 
334  bool is_true (void) const;
335 
340  bool is_false (void) const;
341 
342  private:
343 
348  virtual bool is_true_ (void) const;
349 
354  virtual bool is_false_ (void) const;
355 
364  virtual void modify_ (void);
365 
375  virtual std::string get_debug_info_ (void);
376 
381 
385  std::vector <VariableReference> vector_;
386 
391 
396  };
397 
400  }
401  }
402 }
403 
404 #endif // _MADARA_CONTAINERS_BUFFER_VECTOR_H_
This class encapsulates an entry in a KnowledgeBase.
This class stores a vector of character buffers.
Definition: BufferVector.h:31
VariableReference size_
Reference to the size field of the vector space.
Definition: BufferVector.h:390
std::vector< VariableReference > vector_
Values of the array.
Definition: BufferVector.h:385
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:480
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
::std::vector< KnowledgeRecord > KnowledgeVector
static struct madara::knowledge::tags::string_t string
This class provides a distributed knowledge base to users.
Definition: KnowledgeBase.h:45
std::string delimiter_
Delimiter for the prefix to subvars.
Definition: BufferVector.h:395
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.
ThreadSafeContext * context_
Variable context that we are modifying.
Definition: BufferVector.h:380
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.
BufferVector BufferArray
provide the Array alias for the BufferVector class
Definition: BufferVector.h:399
This class is an abstract base class for all containers.
Definition: BaseContainer.h:33