MADARA  3.1.8
KnowledgeRecord.h
Go to the documentation of this file.
1 
2 
3 #ifndef _MADARA_KNOWLEDGE_RECORD_H_
4 #define _MADARA_KNOWLEDGE_RECORD_H_
5 
13 #include <string>
14 #include <vector>
15 #include <map>
16 #include <memory>
17 #include <type_traits>
18 #include "madara/MADARA_export.h"
19 #include "madara/utility/stdint.h"
21 #include "ace/os_include/sys/os_types.h"
24 
25 namespace madara
26 {
27 
28  namespace knowledge
29  {
30  class ThreadSafeContext;
31 
38  namespace tags {
39  static constexpr struct integers_t {} integers;
40  static constexpr struct doubles_t {} doubles;
41  static constexpr struct string_t {} string;
42  static constexpr struct binary_t {} binary;
43 
44  template<typename T>
45  struct shared_t {};
46 
49  template<typename T>
50  constexpr inline shared_t<T> shared(T) {
51  return shared_t<T>{};
52  }
53  }
54 
60  class MADARA_Export KnowledgeRecord
61  {
62  public:
63  // allow ThreadSafeContext to modify private members
64  friend class ThreadSafeContext;
65 
66  enum
67  {
68  UNCREATED = 0,
69  MODIFIED = 1
70  };
71 
72  enum
73  {
74  OWNED = 0,
75  SHARED = 1
76  };
77 
79  {
80  EMPTY = 0,
81  INTEGER = 1,
82  STRING = 2,
83  DOUBLE = 4,
84  FLOAT = 4,
85  UNKNOWN_FILE_TYPE = 8,
86  XML = 16,
87  TEXT_FILE = 32,
88  INTEGER_ARRAY = 64,
89  DOUBLE_ARRAY = 128,
90  IMAGE_JPEG = 256,
91  ALL_ARRAYS = INTEGER_ARRAY | DOUBLE_ARRAY,
92  ALL_INTEGERS = INTEGER | INTEGER_ARRAY,
93  ALL_DOUBLES = DOUBLE | DOUBLE_ARRAY,
94  ALL_PRIMITIVE_TYPES = INTEGER | STRING | DOUBLE |
95  INTEGER_ARRAY | DOUBLE_ARRAY,
96  ALL_FILE_TYPES = UNKNOWN_FILE_TYPE | XML | TEXT_FILE | IMAGE_JPEG,
97  ALL_IMAGES = IMAGE_JPEG,
98  ALL_TEXT_FORMATS = XML | TEXT_FILE | STRING,
99  ALL_TYPES = ALL_PRIMITIVE_TYPES | ALL_FILE_TYPES,
100  ALL_CLEARABLES = ALL_ARRAYS | ALL_TEXT_FORMATS | ALL_FILE_TYPES
101  };
102 
103  typedef int64_t Integer;
104 
105  private:
108 
109  public:
113  uint64_t clock = 0;
114 
118  uint32_t quality = 0;
119 
123  uint32_t write_quality = 0;
124 
125  private:
130  union
131  {
132  Integer int_value_ = 0;
134 
135  std::shared_ptr<std::vector<Integer>> int_array_;
136  std::shared_ptr<std::vector<double>> double_array_;
137  std::shared_ptr<std::string> str_value_;
138  std::shared_ptr<std::vector<unsigned char>> file_value_;
139  };
140 
144  uint32_t type_ = EMPTY;
145 
150  mutable bool shared_ = OWNED;
151 
152  public:
153  /* default constructor */
154  KnowledgeRecord () noexcept :
156 
157  explicit KnowledgeRecord (logger::Logger & logger) noexcept;
158 
159  /* Integer constructor */
160  template<typename T,
161  typename std::enable_if<std::is_integral<T>::value,
162  void*>::type = nullptr>
163  explicit KnowledgeRecord (T value,
164  logger::Logger & logger = *logger::global_logger.get ()) noexcept;
165 
166  /* Floating point constructor */
167  template<typename T,
168  typename std::enable_if<std::is_floating_point<T>::value,
169  void*>::type = nullptr>
170  explicit KnowledgeRecord (T value,
171  logger::Logger & logger = *logger::global_logger.get ()) noexcept;
172 
173  /* Integer array constructor */
174  explicit KnowledgeRecord (const std::vector <Integer> & value,
175  logger::Logger & logger = *logger::global_logger.get ());
176 
177  /* Integer array move constructor */
178  explicit KnowledgeRecord (std::vector <Integer> && value,
179  logger::Logger & logger = *logger::global_logger.get ()) noexcept;
180 
181  /* Integer array shared_ptr constructor */
182  explicit KnowledgeRecord (std::shared_ptr<std::vector <Integer>> value,
183  logger::Logger & logger = *logger::global_logger.get ()) noexcept;
184 
185  /* Double array constructor */
186  explicit KnowledgeRecord (const std::vector <double> & value,
187  logger::Logger & logger = *logger::global_logger.get ());
188 
189  /* Double array move constructor */
190  explicit KnowledgeRecord (std::vector <double> && value,
191  logger::Logger & logger = *logger::global_logger.get ()) noexcept;
192 
193  /* Double array shared_ptr constructor */
194  explicit KnowledgeRecord (std::shared_ptr<std::vector <double>> value,
195  logger::Logger & logger = *logger::global_logger.get ()) noexcept;
196 
197  /* String constructor */
198  explicit KnowledgeRecord (const std::string & value,
199  logger::Logger & logger = *logger::global_logger.get ());
200 
201  /* String move constructor */
202  explicit KnowledgeRecord (std::string && value,
203  logger::Logger & logger = *logger::global_logger.get ()) noexcept;
204 
205  /* Double array shared_ptr constructor */
206  explicit KnowledgeRecord (std::shared_ptr<std::string> value,
207  logger::Logger & logger = *logger::global_logger.get ()) noexcept;
208 
209  /* Char pointer constructor for g++ */
210  explicit KnowledgeRecord (const char * value,
211  logger::Logger & logger = *logger::global_logger.get ());
212 
213  /* Binary file shared_ptr constructor */
214  explicit KnowledgeRecord (
215  std::shared_ptr<std::vector<unsigned char>> value,
216  logger::Logger & logger = *logger::global_logger.get ()) noexcept;
217 
218  /* copy constructor */
219  KnowledgeRecord (const KnowledgeRecord & rhs);
220 
221  /* move constructor */
222  KnowledgeRecord (KnowledgeRecord && rhs) noexcept;
223 
224  /* destructor */
225  ~KnowledgeRecord () noexcept;
226 
227  private:
228  template<typename T>
229  using MemberType = std::shared_ptr<T> KnowledgeRecord::*;
230 
231  template<typename T, uint32_t Type, MemberType<T> Member, typename... Args>
232  std::shared_ptr<T> &emplace_shared_val(Args&&... args) {
233  clear_union();
234  type_ = Type;
235  return *new(&(this->*Member)) std::shared_ptr<T>(
236  std::forward<Args>(args)...);
237  }
238 
239  template<typename T, uint32_t Type, MemberType<T> Member, typename... Args>
240  std::shared_ptr<T> &emplace_val(Args&&... args) {
241  return emplace_shared_val<T, Type, Member> (std::move(
242  std::make_shared<T> (
243  std::forward<Args>(args)...)));
244  }
245 
246  template<typename T, uint32_t Type, MemberType<std::vector<T>> Member,
247  typename... Args>
248  std::shared_ptr<std::vector<T>> &emplace_shared_vec(Args&&... args) {
249  return emplace_shared_val<std::vector<T>, Type, Member> (
250  std::forward<Args>(args)...);
251  }
252 
253  template<typename T, uint32_t Type, MemberType<std::vector<T>> Member,
254  typename... Args>
255  std::shared_ptr<std::vector<T>> &emplace_vec(Args&&... args) {
256  return emplace_val<std::vector<T>, Type, Member> (
257  std::forward<Args>(args)...);
258  }
259 
260  public:
270  template<typename... Args>
271  void emplace_shared_integers(Args&&... args) {
272  emplace_shared_vec<Integer, INTEGER_ARRAY,
274  std::forward<Args>(args)...);
275  shared_ = SHARED;
276  }
277 
287  template<typename... Args>
289  emplace_shared_integers(std::forward<Args>(args)...);
290  }
291 
297  template<typename... Args>
298  void emplace_integers(Args&&... args) {
299  emplace_vec<Integer, INTEGER_ARRAY,
301  std::forward<Args>(args)...);
302  }
303 
309  template<typename... Args>
310  void emplace(tags::integers_t, Args&&... args) {
311  emplace_integers(std::forward<Args>(args)...);
312  }
313 
323  template<typename... Args>
324  void emplace_shared_doubles(Args&&... args) {
325  emplace_shared_vec<double, DOUBLE_ARRAY,
327  std::forward<Args>(args)...);
328  shared_ = SHARED;
329  }
330 
340  template<typename... Args>
341  void emplace(tags::shared_t<tags::doubles_t>, Args&&... args) {
342  emplace_shared_doubles(std::forward<Args>(args)...);
343  }
344 
350  template<typename... Args>
351  void emplace_doubles(Args&&... args) {
352  emplace_vec<double, DOUBLE_ARRAY,
354  std::forward<Args>(args)...);
355  }
356 
362  template<typename... Args>
363  void emplace(tags::doubles_t, Args&&... args) {
364  emplace_doubles(std::forward<Args>(args)...);
365  }
366 
375  template<typename... Args>
376  void emplace_shared_string(Args&&... args) {
377  emplace_shared_val<std::string, STRING,
379  std::forward<Args>(args)...);
380  shared_ = SHARED;
381  }
382 
391  template<typename... Args>
392  void emplace(tags::shared_t<tags::string_t>, Args&&... args) {
393  emplace_shared_string(std::forward<Args>(args)...);
394  }
395 
401  template<typename... Args>
402  void emplace_string(Args&&... args) {
403  emplace_val<std::string, STRING,
405  std::forward<Args>(args)...);
406  }
407 
413  template<typename... Args>
414  void emplace(tags::string_t, Args&&... args) {
415  emplace_string(std::forward<Args>(args)...);
416  }
417 
427  template<typename... Args>
428  void emplace_shared_file(Args&&... args) {
429  emplace_shared_vec<unsigned char, UNKNOWN_FILE_TYPE,
431  std::forward<Args>(args)...);
432  shared_ = SHARED;
433  }
434 
444  template<typename... Args>
445  void emplace(tags::shared_t<tags::binary_t>, Args&&... args) {
446  emplace_shared_binary(std::forward<Args>(args)...);
447  }
448 
454  template<typename... Args>
455  void emplace_file(Args&&... args) {
456  emplace_vec<unsigned char, UNKNOWN_FILE_TYPE,
458  std::forward<Args>(args)...);
459  }
460 
466  template<typename... Args>
467  void emplace(tags::binary_t, Args&&... args) {
468  emplace_binary(std::forward<Args>(args)...);
469  }
470 
476  template<typename... Args>
478  : int_array_ (std::make_shared<std::vector<Integer>> (
479  std::forward<Args>(args)...)),
480  type_ (INTEGER_ARRAY) {}
481 
487  template<typename... Args>
489  : int_array_ {std::forward<Args>(args)...},
490  type_ (INTEGER_ARRAY), shared_ (SHARED) {}
491 
497  template<typename... Args>
499  : double_array_ (std::make_shared<std::vector<double>> (
500  std::forward<Args>(args)...)),
501  type_ (DOUBLE_ARRAY) {}
502 
508  template<typename... Args>
510  : double_array_ {std::forward<Args>(args)...},
511  type_ (DOUBLE_ARRAY), shared_ (SHARED) {}
512 
521  template<typename... Args>
523  : str_value_ (std::make_shared<std::string> (
524  std::forward<Args>(args)...)),
525  type_ (STRING) {}
526 
536  template<typename... Args>
538  : str_value_ {std::forward<Args>(args)...},
539  type_ (STRING), shared_ (SHARED) {}
540 
546  template<typename... Args>
548  : file_value_ (std::make_shared<std::vector<unsigned char>> (
549  std::forward<Args>(args)...)),
550  type_ (UNKNOWN_FILE_TYPE) {}
551 
558  template<typename... Args>
560  : file_value_ {std::forward<Args>(args)...},
561  type_ (UNKNOWN_FILE_TYPE), shared_ (SHARED) {}
562 
567  bool exists (void) const;
568 
575  KnowledgeRecord retrieve_index (size_t index) const;
576 
583  KnowledgeRecord dec_index (size_t index);
584 
591  KnowledgeRecord inc_index (size_t index);
592 
600  template<typename T,
601  typename std::enable_if<std::is_integral<T>::value,
602  void*>::type = nullptr>
603  void set_index (size_t index, T value);
604 
612  template<typename T,
613  typename std::enable_if<std::is_floating_point<T>::value,
614  void*>::type = nullptr>
615  void set_index (size_t index, T value);
616 
623  std::string to_string (const std::string & delimiter = ", ") const;
624 
629  std::shared_ptr<std::string> share_string() const;
630 
635  std::shared_ptr<std::string> take_string();
636 
641  ssize_t to_file (const std::string & filename) const;
642 
647  void unshare (void);
648 
652  KnowledgeRecord * clone (void) const;
653 
657  Integer to_integer (void) const;
658 
662  double to_double (void) const;
663 
668  std::vector <Integer> to_integers (void) const;
669 
674  std::shared_ptr<std::vector<Integer>> share_integers() const;
675 
680  std::shared_ptr<std::vector<Integer>> take_integers();
681 
686  std::vector <double> to_doubles (void) const;
687 
692  std::shared_ptr<std::vector<double>> share_doubles() const;
693 
698  std::shared_ptr<std::vector<double>> take_doubles();
699 
704  std::shared_ptr<std::vector<unsigned char>> share_binary() const;
705 
710  std::shared_ptr<std::vector<unsigned char>> take_binary();
711 
726  unsigned char * to_unmanaged_buffer (size_t & size) const;
727 
738  void set_value (const KnowledgeRecord &new_value);
739 
750  void set_value (KnowledgeRecord &&new_value);
751 
756  template<typename T,
757  typename std::enable_if<std::is_integral<T>::value,
758  void*>::type = nullptr>
759  void set_value (T new_value);
760 
766  void set_value (const Integer * new_value, uint32_t size);
767 
772  void set_value (std::vector <Integer> && new_value);
773 
778  void set_value (const std::vector <Integer> & new_value);
779 
784  void set_value (std::shared_ptr<std::vector <Integer>> new_value);
785 
791  void set_value (const char * new_value, uint32_t size);
792 
797  void set_value (std::string && new_value);
798 
803  void set_value (const std::string & new_value);
804 
809  void set_value (std::shared_ptr<std::string> new_value);
810 
815  template<typename T,
816  typename std::enable_if<std::is_floating_point<T>::value,
817  void*>::type = nullptr>
818  void set_value (T new_value);
819 
825  void set_value (const double * new_value, uint32_t size);
826 
831  void set_value (std::vector <double> && new_value);
832 
837  void set_value (const std::vector <double> & new_value);
838 
843  void set_value (std::shared_ptr<std::vector <double>> new_value);
844 
850  void set_xml (const char * new_value, size_t size);
851 
856  void set_xml (std::string && new_value);
857 
862  void set_xml (const std::string & new_value);
863 
868  void set_xml (std::shared_ptr<std::string> new_value);
869 
875  void set_text (const char * new_value, size_t size);
876 
881  void set_text (std::string && new_value);
882 
887  void set_text (const std::string & new_value);
888 
893  void set_text (std::shared_ptr<std::string> new_value);
894 
902  static void set_precision (int new_precision);
903 
907  static void set_scientific (void);
908 
912  static void set_fixed (void);
913 
918  static int get_precision (void);
919 
925  void set_jpeg (const unsigned char * new_value, size_t size);
926 
931  void set_jpeg (std::vector <unsigned char> && new_value);
932 
937  void set_jpeg (const std::vector <unsigned char> & new_value);
938 
943  void set_jpeg (std::shared_ptr<std::vector <unsigned char>> new_value);
944 
950  void set_file (const unsigned char * new_value, size_t size);
951 
956  void set_file (std::vector <unsigned char> && new_value);
957 
962  void set_file (const std::vector <unsigned char> & new_value);
963 
968  void set_file (std::shared_ptr<std::vector <unsigned char>> new_value);
969 
977  void deep_copy (const KnowledgeRecord & source);
978 
986  KnowledgeRecord deep_copy() const;
987 
992  int status (void) const;
993 
997  void set_modified (void);
998 
1003  void resize (size_t new_size);
1004 
1013  int read_file (const std::string & filename, uint32_t read_as_type = 0);
1014 
1018  void reset_value (void) noexcept;
1019 
1020  private:
1021  void clear_union (void) noexcept;
1022 
1023  public:
1029  void clear_value (void) noexcept;
1030 
1034  uint32_t size (void) const;
1035 
1039  int32_t type (void) const;
1040 
1052  bool set_type (int32_t type);
1053 
1058  bool is_ref_counted (void) const;
1059 
1065  static bool is_ref_counted (uint32_t type);
1066 
1071  bool is_string_type (void) const;
1072 
1078  static bool is_string_type (uint32_t type);
1079 
1084  bool is_double_type (void) const;
1085 
1091  static bool is_double_type (uint32_t type);
1092 
1097  bool is_integer_type (void) const;
1098 
1104  static bool is_integer_type (uint32_t type);
1105 
1106 
1111  bool is_array_type (void) const;
1112 
1118  static bool is_array_type (uint32_t type);
1119 
1129  KnowledgeRecord fragment (unsigned int first, unsigned int last);
1130 
1135  bool is_image_type (void) const;
1136 
1142  static bool is_image_type (uint32_t type);
1143 
1148  bool is_file_type (void) const;
1149 
1155  static bool is_file_type (uint32_t type);
1156 
1161  bool is_binary_file_type (void) const;
1162 
1168  static bool is_binary_file_type (uint32_t type);
1169 
1173  bool operator< (const KnowledgeRecord & rhs) const;
1174 
1178  bool operator<= (const KnowledgeRecord & rhs) const;
1179 
1183  bool operator== (const KnowledgeRecord & rhs) const;
1184 
1188  template<typename T,
1189  typename std::enable_if<std::is_integral<T>::value,
1190  void*>::type = nullptr>
1191  bool operator== (T value) const;
1192 
1196  template<typename T,
1197  typename std::enable_if<std::is_floating_point<T>::value,
1198  void*>::type = nullptr>
1199  bool operator== (T value) const;
1200 
1204  bool operator== (const std::string & value) const;
1205 
1209  bool operator== (const char * value) const;
1210 
1214  bool operator!= (const KnowledgeRecord & rhs) const;
1215 
1219  bool operator> (const KnowledgeRecord & rhs) const;
1220 
1224  bool operator>= (const KnowledgeRecord & rhs) const;
1225 
1229  bool operator! (void) const;
1230 
1234  KnowledgeRecord operator- (void) const;
1235 
1239  KnowledgeRecord & operator= (const KnowledgeRecord & rhs);
1240 
1244  KnowledgeRecord & operator= (KnowledgeRecord && rhs) noexcept;
1245 
1250 
1255 
1260 
1265 
1270 
1274  KnowledgeRecord operator* (const KnowledgeRecord & rhs) const;
1275 
1279  KnowledgeRecord operator/ (const KnowledgeRecord & rhs) const;
1280 
1284  KnowledgeRecord operator% (const KnowledgeRecord & rhs) const;
1285 
1289  KnowledgeRecord operator+ (const KnowledgeRecord & rhs) const;
1290 
1294  KnowledgeRecord operator- (const KnowledgeRecord & rhs) const;
1295 
1301  explicit operator bool (void) const;
1302 
1306  KnowledgeRecord & operator++ (void);
1307 
1311  KnowledgeRecord & operator-- (void);
1312 
1321  const char * read (const char * buffer, int64_t & buffer_remaining);
1322 
1332  const char * read (const char * buffer, std::string & key,
1333  int64_t & buffer_remaining);
1334 
1344  const char * read (const char * buffer, uint32_t & key_id,
1345  int64_t & buffer_remaining);
1346 
1363  char * write (char * buffer, int64_t & buffer_remaining) const;
1364 
1384  char * write (char * buffer, const std::string & key,
1385  int64_t & buffer_remaining) const;
1386 
1408  char * write (char * buffer, uint32_t key_id,
1409  int64_t & buffer_remaining) const;
1410 
1414  int apply (madara::knowledge::ThreadSafeContext & context,
1415  const std::string & key, unsigned int quality, uint64_t clock,
1416  bool perform_lock);
1417 
1423  bool is_true (void) const;
1424 
1430  bool is_false (void) const;
1431 
1437  inline bool is_valid (void) const
1438  {
1439  return status() != UNCREATED;
1440  }
1441 
1447  int64_t get_encoded_size (const std::string & key) const;
1448 
1454  int64_t get_encoded_size (void) const;
1455  };
1456 
1457  typedef ::std::map < std::string, KnowledgeRecord> KnowledgeMap;
1458  typedef ::std::vector < KnowledgeRecord> KnowledgeVector;
1459  typedef ::std::vector < std::string> KnowledgeRules;
1460  typedef ::std::vector < std::string> StringVector;
1461  typedef ::std::map < std::string, KnowledgeRecord *> KnowledgeRecords;
1462 
1465 
1471  uint32_t max_quality (const KnowledgeRecords & records);
1472 
1478  uint32_t max_quality (const KnowledgeMap & records);
1479  }
1480 }
1481 
1482 
1486 //inline std::ostream & operator<< (std::ostream & stream,
1487  //const madara::knowledge::KnowledgeRecord & rhs);
1488 
1489 #include "KnowledgeRecord.inl"
1490 
1491 
1492 #endif // _MADARA_KNOWLEDGE_RECORD_H_
This class encapsulates an entry in a KnowledgeBase.
uint32_t max_quality(const KnowledgeRecords &records)
Returns the maximum quality within the records.
auto operator>=(const Tracked< T > &lhs, const Tracked< U > &rhs) -> decltype(lhs.get() >=rhs.get())
Definition: Tracked.h:247
void emplace_shared_file(Args &&...args)
Construct a shared_ptr to a file (vector of unsigned char) within this KnowledgeRecord.
auto operator/=(Tracked< T > &lhs, const Tracked< U > &rhs) -> decltype(lhs.get_mut()/=rhs.get())
Definition: Tracked.h:277
auto operator>(const Tracked< T > &lhs, const Tracked< U > &rhs) -> decltype(lhs.get() >rhs.get())
Definition: Tracked.h:249
void emplace(tags::string_t, Args &&...args)
Construct a string within this KnowledgeRecord.
auto operator*=(Tracked< T > &lhs, const Tracked< U > &rhs) -> decltype(lhs.get_mut()*=rhs.get())
Definition: Tracked.h:276
void emplace_string(Args &&...args)
Construct a string within this KnowledgeRecord.
KnowledgeRecord(tags::string_t, Args &&...args)
Forwarding constructor for strings Each argument past the first will be forwarded to construct a std:...
auto operator<=(const Tracked< T > &lhs, const Tracked< U > &rhs) -> decltype(lhs.get()<=rhs.get())
Definition: Tracked.h:246
void emplace_integers(Args &&...args)
Construct a vector of integers within this KnowledgeRecord.
auto operator<(const Tracked< T > &lhs, const Tracked< U > &rhs) -> decltype(lhs.get()< rhs.get())
Definition: Tracked.h:248
std::shared_ptr< std::vector< T > > & emplace_vec(Args &&...args)
::std::vector< std::string > KnowledgeRules
auto operator--(Tracked< T > &lhs) -> decltype(--lhs.get_mut())
Definition: Tracked.h:302
madara::knowledge::KnowledgeRecord KnowledgeRecord
bool is_valid(void) const
Checks to see if the record is valid.
void emplace(tags::shared_t< tags::integers_t >, Args &&...args)
Construct a shared_ptr to vector of integers within this KnowledgeRecord.
void emplace_file(Args &&...args)
Construct a file (vector of unsigned char) within this KnowledgeRecord.
KnowledgeRecord(tags::integers_t, Args &&...args)
Forwarding constructor for integer arrays Each argument past the first will be forwarded to construct...
auto operator/(const Tracked< T > &lhs, const Tracked< U > &rhs) -> decltype(lhs.get()/rhs.get())
Definition: Tracked.h:277
void emplace(tags::shared_t< tags::binary_t >, Args &&...args)
Construct a shared_ptr to binary (vector of unsigned char) within this KnowledgeRecord.
MADARA_Export int read_file(const std::string &filename, void *&buffer, size_t &size, bool add_zero_char=false)
Reads a file into a provided void pointer.
Definition: Utility.cpp:747
auto operator%(const Tracked< T > &lhs, const Tracked< U > &rhs) -> decltype(lhs.get()%rhs.get())
Definition: Tracked.h:278
STL namespace.
auto operator+=(Tracked< T > &lhs, const Tracked< U > &rhs) -> decltype(lhs.get_mut()+=rhs.get())
Definition: Tracked.h:274
This class stores variables and their values for use by any entity needing state information in a thr...
std::shared_ptr< T > KnowledgeRecord::* MemberType
std::shared_ptr< std::vector< Integer > > int_array_
auto operator-(const Tracked< T > &lhs, const Tracked< U > &rhs) -> decltype(lhs.get()-rhs.get())
Definition: Tracked.h:275
void emplace(tags::integers_t, Args &&...args)
Construct a vector of integers within this KnowledgeRecord.
MADARA_Export utility::Refcounter< logger::Logger > global_logger
void emplace_shared_integers(Args &&...args)
Construct a shared_ptr to vector of integers within this KnowledgeRecord.
void emplace(tags::shared_t< tags::doubles_t >, Args &&...args)
Construct a shared_ptr to vector of doubles within this KnowledgeRecord.
Provides knowledge logging services to files and terminals.
Definition: GlobalLogger.h:11
void emplace(tags::binary_t, Args &&...args)
Construct a binary (vector of unsigned char) within this KnowledgeRecord.
void emplace_shared_doubles(Args &&...args)
Construct a shared_ptr to vector of doubles within this KnowledgeRecord.
auto operator%=(Tracked< T > &lhs, const Tracked< U > &rhs) -> decltype(lhs.get_mut()%=rhs.get())
Definition: Tracked.h:278
std::shared_ptr< T > & emplace_shared_val(Args &&...args)
void emplace_shared_string(Args &&...args)
Construct a shared_ptr to a string within this KnowledgeRecord.
auto operator*(const Tracked< T > &lhs, const Tracked< U > &rhs) -> decltype(lhs.get()*rhs.get())
Definition: Tracked.h:276
A multi-threaded logger for logging to one or more destinations.
Definition: Logger.h:88
::std::vector< KnowledgeRecord > KnowledgeVector
std::string KnowledgeKey
static constexpr struct madara::knowledge::tags::doubles_t doubles
void emplace(tags::shared_t< tags::string_t >, Args &&...args)
Construct a shared_ptr to string within this KnowledgeRecord.
auto operator!(const Tracked< T > &lhs) -> decltype(!lhs.get())
Definition: Tracked.h:292
madara::knowledge::KnowledgeRecord::Integer Integer
::std::map< std::string, KnowledgeRecord * > KnowledgeRecords
::std::map< std::string, KnowledgeRecord > KnowledgeMap
KnowledgeRecord KnowledgeValue
std::shared_ptr< T > & emplace_val(Args &&...args)
std::shared_ptr< std::vector< double > > double_array_
constexpr shared_t< T > shared(T)
Used to signal in-place shared_ptr construction in KnowledgeRecord Example: tags::shared(tags::intege...
auto operator-=(Tracked< T > &lhs, const Tracked< U > &rhs) -> decltype(lhs.get_mut()-=rhs.get())
Definition: Tracked.h:275
static constexpr struct madara::knowledge::tags::string_t string
KnowledgeRecord(tags::shared_t< tags::string_t >, Args &&...args)
Forwarding constructor for double arrays shared_ptr Each argument past the first will be forwarded to...
std::shared_ptr< std::vector< unsigned char > > file_value_
auto operator==(const Tracked< T > &lhs, const Tracked< U > &rhs) -> decltype(lhs.get()==rhs.get())
Definition: Tracked.h:244
KnowledgeRecord(tags::shared_t< tags::binary_t >, Args &&...args)
Forwarding constructor for binary file (blob) shared_ptr Each argument past the first will be forward...
auto operator!=(const Tracked< T > &lhs, const Tracked< U > &rhs) -> decltype(lhs.get()!=rhs.get())
Definition: Tracked.h:245
static constexpr struct madara::knowledge::tags::binary_t binary
std::shared_ptr< std::vector< T > > & emplace_shared_vec(Args &&...args)
KnowledgeRecord(tags::shared_t< tags::doubles_t >, Args &&...args)
Forwarding constructor for double arrays shared_ptr Each argument past the first will be forwarded to...
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.
KnowledgeRecord(tags::binary_t, Args &&...args)
Forwarding constructor for binary files (blobs) Each argument past the first will be forwarded to con...
static constexpr struct madara::knowledge::tags::integers_t integers
Provides functions and classes for the distributed knowledge base.
void emplace(tags::doubles_t, Args &&...args)
Construct a vector of doubles within this KnowledgeRecord.
void emplace_doubles(Args &&...args)
Construct a vector of doubles within this KnowledgeRecord.
void set_value(T &t, const T &v)
Fallback definition of set_value; simply passes through the value.
Definition: BaseTracker.h:40
KnowledgeRecord(tags::shared_t< tags::integers_t >, Args &&...args)
Forwarding constructor for integer arrays shared_ptr Each argument past the first will be forwarded t...
Copyright (c) 2015 Carnegie Mellon University.
KnowledgeRecord(tags::doubles_t, Args &&...args)
Forwarding constructor for double arrays Each argument past the first will be forwarded to construct ...
auto operator+(const Tracked< T > &lhs, const Tracked< U > &rhs) -> decltype(lhs.get()+rhs.get())
Definition: Tracked.h:274
auto operator++(Tracked< T > &lhs) -> decltype(++lhs.get_mut())
Definition: Tracked.h:301
::std::vector< std::string > StringVector
std::shared_ptr< std::string > str_value_