MADARA  3.2.3
StringVector.h
Go to the documentation of this file.
1 
2 #ifndef _MADARA_CONTAINERS_STRING_VECTOR_H_
3 #define _MADARA_CONTAINERS_STRING_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 StringVector : public BaseContainer
32  {
33  public:
35  typedef std::string type;
36 
42  StringVector (const KnowledgeUpdateSettings & settings =
44  const std::string & delimiter = ".");
45 
55  StringVector (const std::string & name,
57  int size = -1,
58  bool delete_vars = true,
59  const KnowledgeUpdateSettings & settings =
61  const std::string & delimiter = ".");
62 
72  StringVector (const std::string & name,
73  Variables & knowledge,
74  int size = -1,
75  bool delete_vars = true,
76  const KnowledgeUpdateSettings & settings =
78  const std::string & delimiter = ".");
79 
83  StringVector (const StringVector & rhs);
84 
88  virtual ~StringVector ();
89 
94  void modify (void);
95 
101  void modify (size_t index);
102 
107  void operator= (const StringVector & rhs);
108 
114  void push_back (type value);
115 
122  void resize (int size = -1, bool delete_vars = true);
123 
132  void exchange (StringVector & other, bool refresh_keys = true,
133  bool delete_keys = true);
134 
139  void copy_to (KnowledgeVector & target) const;
140 
145  void copy_to (std::vector <type> & target) const;
146 
151  void transfer_to (StringVector & other);
152 
158  size_t size (void) const;
159 
166  void set_name (const std::string & var_name,
167  KnowledgeBase & knowledge, int size = -1);
168 
175  void set_name (const std::string & var_name,
176  Variables & knowledge, int size = -1);
177 
184  void set_name (const std::string & var_name,
185  ThreadSafeContext & knowledge, int size = -1);
186 
194  void set_delimiter (const std::string & delimiter);
195 
203  std::string get_delimiter (void);
204 
211  type operator[] (size_t index) const;
212 
219  knowledge::KnowledgeRecord to_record (size_t index) const;
220 
225  knowledge::KnowledgeRecord to_record (void) const;
226 
233  bool exists (size_t index) const;
234 
243  int set (size_t index,
244  const type & value);
245 
255  int set (size_t index,
256  const type & value,
257  const KnowledgeUpdateSettings & settings);
258 
266  int set (
267  const std::vector <type> & value);
268 
277  int set (
278  const std::vector <type> & value,
279  const KnowledgeUpdateSettings & settings);
280 
288  void set_quality (size_t index, uint32_t quality,
289  const KnowledgeReferenceSettings & settings =
291 
296  VariableReference get_size_ref (void);
297 
307  std::string get_debug_info (void);
308 
314  virtual BaseContainer * clone (void) const;
315 
320  bool is_true (void) const;
321 
326  bool is_false (void) const;
327 
328  private:
329 
334  virtual bool is_true_ (void) const;
335 
340  virtual bool is_false_ (void) const;
341 
350  virtual void modify_ (void);
351 
361  virtual std::string get_debug_info_ (void);
362 
367 
371  std::vector <VariableReference> vector_;
372 
377 
382  };
383 
386  }
387  }
388 }
389 
390 #endif // _MADARA_CONTAINERS_STRING_VECTOR_H_
This class encapsulates an entry in a KnowledgeBase.
std::string delimiter_
Delimiter for the prefix to subvars.
Definition: StringVector.h:381
This class stores variables and their values for use by any entity needing state information in a thr...
ThreadSafeContext * context_
Variable context that we are modifying.
Definition: StringVector.h:366
Optimized reference to a variable within the knowledge base.
Provides container classes for fast knowledge base access and mutation.
Definition: Barrier.h:27
This class stores a vector of strings inside of KaRL.
Definition: StringVector.h:31
::std::vector< KnowledgeRecord > KnowledgeVector
std::vector< VariableReference > vector_
Values of the array.
Definition: StringVector.h:371
static struct madara::knowledge::tags::string_t string
This class provides a distributed knowledge base to users.
Definition: KnowledgeBase.h:45
StringVector StringArray
provide the Array alias for the StringVector class
Definition: StringVector.h:385
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.
VariableReference size_
Reference to the size field of the vector space.
Definition: StringVector.h:376
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::string > StringVector
std::string type
trait that describes the value type
Definition: StringVector.h:35