MADARA  3.1.8
Tracked.h
Go to the documentation of this file.
1 
2 
3 #ifndef INCL_MADARA_RCW_TRACKED_H
4 #define INCL_MADARA_RCW_TRACKED_H
5 
14 #include <string>
15 #include <vector>
16 #include <map>
17 #include <list>
18 #include <type_traits>
19 #include <initializer_list>
22 #include "madara/utility/stdint.h"
23 #include "madara/MADARA_export.h"
28 
29 namespace madara { namespace knowledge { namespace rcw
30 {
33  template<class T, class Impl>
35  {
36  public:
38  const T& get() const;
39 
42  T& get_mut();
43 
47  T& get_mutable();
48 
50  void set(T val);
51 
53  void modify();
54 
57  bool is_dirty() const;
58 
60  void clear_dirty();
61  };
62 
64  template<class T, class Impl>
66 
74  template<class T>
75  class Tracked : public TrackedExtra<T, Tracked<T>>
76  {
77  private:
78  T val_;
79  char dirty_;
80 
82 
83  friend class TrackedExtra<T, Tracked<T>>;
84  friend class TrackedCollection<T, Tracked<T>>;
85  friend class TrackedCollection<T, TrackedExtra<T, Tracked<T>>>;
86  public:
88  Tracked() : val_(), dirty_(true) {}
89 
92  explicit Tracked(T val) : val_(val), dirty_(true) {}
93 
95  const T& get() const
96  {
97  return val_;
98  }
99 
101  explicit operator const T& () const
102  {
103  return get();
104  }
105 
108  T& get_mut()
109  {
110  modify();
111  return val_;
112  }
113 
118  {
119  modify();
120  return val_;
121  }
122 
124  void set(T val)
125  {
126  modify();
127  val_ = val;
128  }
129 
132  const T& operator*() const
133  {
134  return this->get();
135  }
136 
139  const T* operator->() const
140  {
141  return &this->get();
142  }
143 
146  {
147  this->set(val);
148  return *this;
149  }
150 
152  Tracked &operator=(const Tracked &) = delete;
153 
155  void modify()
156  {
157  dirty_ = true;
158  }
159 
162  bool is_dirty() const
163  {
164  return dirty_;
165  }
166 
168  void clear_dirty()
169  {
170  dirty_ = false;
171  }
172 
173  using Base::get;
174  using Base::get_mut;
175  using Base::set;
176  using Base::modify;
177  using Base::is_dirty;
178  using Base::clear_dirty;
179 
181  explicit operator bool()
182  {
183  return val_ ? true : false;
184  }
185 
188  template<class U, typename std::enable_if<std::is_convertible<T, U>::value,
189  void*>::type = nullptr>
190  operator Tracked<U>() const
191  {
192  Tracked<U> ret(get());
193  if (!is_dirty()) ret.clear_dirty();
194  return ret;
195  }
196 
198  friend void swap(Tracked &lhs, Tracked &rhs)
199  {
200  using std::swap;
201  swap(lhs.val_, rhs.val_);
202  swap(lhs.dirty_, rhs.dirty_);
203  }
204 
206  friend void swap(Tracked &lhs, T &rhs)
207  {
208  using std::swap;
209  swap(lhs.val_, rhs);
210  lhs.dirty_ = true;
211  }
212 
214  friend void swap(T &lhs, Tracked &rhs)
215  {
216  using std::swap;
217  swap(lhs, rhs.val_);
218  rhs.dirty_ = true;
219  }
220  };
221 
224  template<class T>
226  {
227  return Tracked<typename std::decay<T>::type>(std::forward<T>(val));
228  }
229 
230 #define MADARA_AUTOTYPE_BODY(body) \
231  -> decltype(body) { return (body); }
232 
233 #define MADARA_MAKE_BINARY_COMPARE_OP(op) \
234  template<class T, class U> \
235  auto operator op(const Tracked<T> &lhs, const Tracked<U> &rhs) \
236  MADARA_AUTOTYPE_BODY(lhs.get() op rhs.get()) \
237  template<class T, class U> \
238  auto operator op(const Tracked<T> &lhs, U &&rhs) \
239  MADARA_AUTOTYPE_BODY(lhs.get() op std::forward<U>(rhs)) \
240  template<class T, class U> \
241  auto operator op(T &&lhs, const Tracked<U> &rhs) \
242  MADARA_AUTOTYPE_BODY(std::forward<T>(lhs) op rhs.get())
243 
250 
251 #define MADARA_MAKE_COMPOUND_OP(op) \
252  template<class T, class U> \
253  auto operator op##=(Tracked<T> &lhs, const Tracked<U> &rhs) \
254  MADARA_AUTOTYPE_BODY(lhs.get_mut() op##= rhs.get()) \
255  template<class T, class U> \
256  auto operator op##=(Tracked<T> &lhs, U &&rhs) \
257  MADARA_AUTOTYPE_BODY(lhs.get_mut() op##= std::forward<U>(rhs)) \
258  template<class T, class U> \
259  auto operator op##=(T &lhs, const Tracked<U> &rhs) \
260  MADARA_AUTOTYPE_BODY(lhs op##= rhs.get())
261 
262 #define MADARA_MAKE_BINARY_ARITH_OP(op) \
263  template<class T, class U> \
264  auto operator op(const Tracked<T> &lhs, const Tracked<U> &rhs) \
265  MADARA_AUTOTYPE_BODY(lhs.get() op rhs.get()) \
266  template<class T, class U> \
267  auto operator op(const Tracked<T> &lhs, U &&rhs) \
268  MADARA_AUTOTYPE_BODY(lhs.get() op std::forward<U>(rhs)) \
269  template<class T, class U> \
270  auto operator op(T &&lhs, const Tracked<U> &rhs) \
271  MADARA_AUTOTYPE_BODY(std::forward<T>(lhs) op rhs.get()) \
272  MADARA_MAKE_COMPOUND_OP(op)
273 
284 
285 #define MADARA_MAKE_UNARY_ARITH_OP(op) \
286  template<class T> \
287  auto operator op(const Tracked<T> &lhs) \
288  MADARA_AUTOTYPE_BODY(op lhs.get())
289 
294 
295 #define MADARA_MAKE_INCDEC_OP(op) \
296  template<class T> auto operator op(Tracked<T> &lhs) \
297  MADARA_AUTOTYPE_BODY(op lhs.get_mut()) \
298  template<class T> auto operator op(Tracked<T> &lhs, int) \
299  MADARA_AUTOTYPE_BODY(lhs.get_mut() op)
300 
303 
304  typedef Tracked<bool> TrackedBool;
316 
325 
329 
331  template<typename T, typename Impl>
332  class TrackedCollection
333  {
334  private:
335  Impl &impl() { return static_cast<Impl&>(*this); }
336  const Impl &impl() const { return static_cast<const Impl&>(*this); }
337 
338  public:
339  typedef typename T::value_type value_type;
340  typedef typename T::const_iterator const_iterator;
341 
345  void set(size_t i, value_type val)
346  {
347  impl().val_.at(i) = val;
348  impl().modify(i);
349  }
350 
352  const value_type &at(size_t i) const
353  {
354  return impl().val_.at(i);
355  }
356 
358  const value_type &operator[](size_t i) const
359  {
360  return impl().val_[i];
361  }
362 
364  const value_type &get(size_t i) const
365  {
366  return at(i);
367  }
368 
371  value_type &at_mut(size_t i)
372  {
373  impl().modify(i);
374  return impl().val_.at(i);
375  }
376 
378  value_type &at_mutable(size_t i)
379  {
380  return at_mut(i);
381  }
382 
384  value_type &get_mut(size_t i)
385  {
386  return at_mut(i);
387  }
388 
390  value_type &get_mutable(size_t i)
391  {
392  return at_mut(i);
393  }
394 
396  size_t size() { return impl().val_.size(); }
398  bool empty() { return impl().val_.empty(); }
400  size_t max_size() { return impl().val_.max_size(); }
401 
403  const value_type& front() const
404  {
405  return at(0);
406  }
407 
409  const value_type& back() const
410  {
411  return at(size() - 1);
412  }
413 
415  value_type& front_mut()
416  {
417  return at_mut(0);
418  }
420  value_type& back()
421  {
422  return at_mut(size() - 1);
423  }
424 
426  const_iterator begin() const
427  {
428  return impl().val_.begin();
429  }
430 
432  const_iterator cbegin() const
433  {
434  return begin();
435  }
436 
438  const_iterator end() const
439  {
440  return impl().val_.end();
441  }
442 
444  const_iterator cend() const
445  {
446  return end();
447  }
448  };
449 
451  template<typename Char, typename Impl>
452  class TrackedExtra<std::basic_string<Char>, Impl> : public TrackedCollection<std::basic_string<Char>, Impl>
453  {
454  private:
455  Impl &impl() { return static_cast<Impl&>(*this); }
456  const Impl &impl() const { return static_cast<const Impl&>(*this); }
457  template<class U, class I> friend class TrackedCollection;
458  public:
459  typedef typename std::basic_string<Char>::value_type value_type;
460  typedef typename std::basic_string<Char>::const_iterator const_iterator;
461 
464  void modify(size_t)
465  {
466  impl().modify();
467  }
468 
471  bool is_dirty(size_t i) const
472  {
473  return impl().is_dirty();
474  }
475 
478  bool clear_dirty(size_t i) const
479  {
480  return impl().clear_dirty();
481  }
482 
484  void resize(size_t count)
485  {
486  impl().val_.resize(count);
487  impl().modify();
488  }
489 
491  size_t capacity() const
492  {
493  return impl().val_.capacity();
494  }
495 
497  void reserve(size_t count)
498  {
499  impl().val_.reserve(count);
500  }
501 
503  void push_back(const value_type &value)
504  {
505  impl().val_.push_back(value);
506  impl().modify();
507  }
508 
510  void pop_back()
511  {
512  impl().val_.pop_back();
513  impl().modify();
514  }
515 
517  void clear()
518  {
519  impl().val_.clear();
520  impl().modify();
521  }
522 
524  const value_type *c_str() const { return impl().val_.c_str(); }
526  const value_type *data() const { return impl().val_.data(); }
527  };
528 
530 
532  template<typename T>
533  bool is_dirty(const Tracked<T> &t)
534  {
535  return t.is_dirty();
536  }
537 
539  template<typename T>
541  {
542  t.clear_dirty();
543  }
544 
546  template<typename T>
547  bool is_dirty(const std::vector<Tracked<T>> &t, size_t i)
548  {
549  return is_dirty(t[i]);
550  }
551 
553  template<typename T>
554  void clear_dirty(std::vector<Tracked<T>> &t, size_t i)
555  {
556  clear_dirty(t[i]);
557  }
558 
560  template<typename T>
561  auto get_value(const Tracked<T> &t) -> decltype(get_value(t.get()))
562  {
563  return get_value(t.get());
564  }
565 
567  template<typename T>
568  void set_value(Tracked<T> &t, decltype(get_value(t.get())) v)
569  {
570  set_value(t.get_mut(), v);
571  }
572 
574  char get_value(const Tracked<std::string> &t, size_t i)
575  {
576  return get_value(t.get(i));
577  }
578 
579 
581  void set_value(Tracked<std::string> &t, size_t i, char v)
582  {
583  set_value(t.get_mut(i), v);
584  }
585 
587  template<typename T>
588  class Tracked<std::vector<T>> : public TrackedCollection<std::vector<T>, Tracked<std::vector<T>>>
589  {
590  private:
591  typedef std::vector<T> Vec;
593 
595  Vec val_;
596 
598  std::vector<uint64_t> dirty_;
599 
602 
605 
607  static std::pair<size_t, uint64_t> to_dirty_bit(size_t i)
608  {
609  size_t idx = i >> 6;
610  size_t shift = i - (idx << 6);
611  return {idx, 1 << shift};
612  }
613 
615  static size_t to_dirty_size(size_t i)
616  {
617  return (i + 63) >> 6;
618  }
619 
620  friend class TrackedCollection<std::vector<T>, Tracked<std::vector<T>>>;
621 
622  public:
623  typedef typename std::vector<T>::value_type value_type;
624  typedef typename std::vector<T>::const_iterator const_iterator;
625 
627  Tracked() : val_(), dirty_(), all_dirty_(true), size_dirty_(true) {}
629  explicit Tracked(std::vector<T> val)
630  : val_(val), dirty_(to_dirty_size(val.size())),
631  all_dirty_(true), size_dirty_(true) {}
632 
634  const std::vector<T>& get() const
635  {
636  return val_;
637  }
638 
641  std::vector<T>& get_mut()
642  {
643  modify();
644  return val_;
645  }
646 
650  std::vector<T>& get_mutable()
651  {
652  modify();
653  return val_;
654  }
655 
657  const std::vector<T>& operator*() const
658  {
659  return get();
660  }
661 
663  const std::vector<T>* operator->() const
664  {
665  return &get();
666  }
667 
669  void set(const std::vector<T> &val)
670  {
671  val_ = val;
672  dirty_.resize(to_dirty_size(val_.size()));
673  modify();
674  }
675 
677  Tracked &operator=(const std::vector<T> &val)
678  {
679  set(val);
680  return *this;
681  }
682 
684  void modify()
685  {
686  all_dirty_ = true;
687  }
688 
693  bool is_all_dirty() const
694  {
695  return all_dirty_;
696  }
697 
699  bool is_size_dirty() const
700  {
701  return size_dirty_;
702  }
703 
705  bool is_dirty() const
706  {
707  if (all_dirty_)
708  return true;
709  for (const uint64_t &cur : dirty_)
710  if (cur)
711  return true;
712  return false;
713  }
714 
716  void clear_dirty()
717  {
718  all_dirty_ = false;
719  size_dirty_ = false;
720  for (uint64_t &cur : dirty_)
721  cur = 0;
722  }
723 
725  void modify(size_t i)
726  {
727  dirty_.resize(to_dirty_size(val_.size()));
728  std::pair<size_t, uint64_t> x = to_dirty_bit(i);
729  dirty_.at(x.first) |= x.second;
730  }
731 
733  void clear_dirty(size_t i)
734  {
735  dirty_.resize(to_dirty_size(val_.size()));
736  std::pair<size_t, uint64_t> x = to_dirty_bit(i);
737  dirty_.at(x.first) &= ~x.second;
738  }
739 
741  bool is_dirty(size_t i) const
742  {
743  std::pair<size_t, uint64_t> x = to_dirty_bit(i);
744  if (x.first >= dirty_.size())
745  return false;
746  return dirty_.at(x.first) & x.second;
747  }
748 
750  void resize(size_t count)
751  {
752  val_.resize(count);
753  dirty_.resize(to_dirty_size(val_.size()));
754  all_dirty_ = true;
755  }
756 
758  size_t capacity() const
759  {
760  size_t vc = val_.capacity();
761  size_t dc = to_dirty_size(dirty_.capacity());
762  return vc > dc ? dc : vc;
763  }
764 
766  void reserve(size_t count)
767  {
768  val_.reserve(count);
769  dirty_.reserve(to_dirty_size(count));
770  }
771 
773  void push_back(const value_type &value)
774  {
775  val_.push_back(value);
776  dirty_.resize(to_dirty_size(val_.size()));
777  size_dirty_ = true;
778  modify(val_.size() - 1);
779  }
780 
782  void pop_back()
783  {
784  val_.pop_back();
785  dirty_.resize(to_dirty_size(val_.size()));
786  size_dirty_ = true;
787  }
788 
790  void clear()
791  {
792  val_.clear();
793  dirty_.clear();
794  all_dirty_ = true;
795  }
796 
797  using Base::get;
798  using Base::get_mut;
799  using Base::get_mutable;
800  using Base::set;
801 
802  friend bool operator==(const Tracked &lhs, const Tracked &rhs) { return lhs.val_ == rhs.val_; }
803  friend bool operator!=(const Tracked &lhs, const Tracked &rhs) { return lhs.val_ != rhs.val_; }
804  friend bool operator<=(const Tracked &lhs, const Tracked &rhs) { return lhs.val_ <= rhs.val_; }
805  friend bool operator>=(const Tracked &lhs, const Tracked &rhs) { return lhs.val_ >= rhs.val_; }
806  friend bool operator<(const Tracked &lhs, const Tracked &rhs) { return lhs.val_ < rhs.val_; }
807  friend bool operator>(const Tracked &lhs, const Tracked &rhs) { return lhs.val_ > rhs.val_; }
808 
810  friend void swap(Tracked &lhs, Tracked &rhs)
811  {
812  using std::swap;
813  swap(lhs.val_, rhs.val_);
814  swap(lhs.dirty_, rhs.dirty_);
815  swap(lhs.all_dirty_, rhs.all_dirty_);
816  swap(lhs.size_dirty_, rhs.size_dirty_);
817  }
818  };
819 
821  template<typename T>
822  bool is_dirty(const Tracked<std::vector<T>> &t, size_t i)
823  {
824  return t.is_dirty(i);
825  }
826 
828  template<typename T>
829  bool is_all_dirty(const Tracked<std::vector<T>> &t)
830  {
831  return t.is_all_dirty();
832  }
833 
835  template<typename T>
836  bool is_size_dirty(const Tracked<std::vector<T>> &t)
837  {
838  return t.is_size_dirty();
839  }
840 
842  template<typename T>
843  void clear_dirty(Tracked<std::vector<T>> &t, size_t i)
844  {
845  t.clear_dirty(i);
846  }
847 
849  template<typename T>
850  const T &get_value(const Tracked<std::vector<T>> &t, size_t i)
851  {
852  return t.get(i);
853  }
854 
856  template<typename T>
857  void set_value(Tracked<std::vector<T>> &t, size_t i, const T &v)
858  {
859  t.set(i, v);
860  }
861 
864 } } } // end namespace knowledge::rcw
865 
866 #endif // INCL_MADARA_RCW_TRACKED_H
bool all_dirty_
dirty status to treat entire vector as modified
Definition: Tracked.h:601
Tracked< int16_t > TrackedI16
Definition: Tracked.h:319
Tracked< unsigned long > TrackedULong
Definition: Tracked.h:314
static std::pair< size_t, uint64_t > to_dirty_bit(size_t i)
Get dirty flag bit offset into dirty_ vector, plus mask.
Definition: Tracked.h:607
value_type & get_mut(size_t i)
Synonym for.
Definition: Tracked.h:384
Tracked< unsigned long long > TrackedULongLong
Definition: Tracked.h:315
size_t max_size()
Pass through to max_size method of underlying collection.
Definition: Tracked.h:400
Tracked()
Default constructor; default constructs wrapped object.
Definition: Tracked.h:88
#define MADARA_MAKE_BINARY_COMPARE_OP(op)
Definition: Tracked.h:233
Tracked< std::string > TrackedString
Definition: Tracked.h:529
friend bool operator<=(const Tracked &lhs, const Tracked &rhs)
Definition: Tracked.h:804
bool is_dirty() const
Get modification status.
Definition: Tracked.h:162
const value_type & back() const
Equivalent to back method of underlying collection.
Definition: Tracked.h:409
void pop_back()
Pass through pop_back method to underlying vector.
Definition: Tracked.h:782
Tracked< long double > TrackedLongDouble
Definition: Tracked.h:328
bool is_dirty(const Tracked< std::vector< T >> &t, size_t i)
Return dirty flag at index of Tracked vector.
Definition: Tracked.h:822
Tracked< bool > TrackedBool
Definition: Tracked.h:302
#define MADARA_MAKE_BINARY_ARITH_OP(op)
Definition: Tracked.h:262
bool is_dirty(size_t i) const
Check i-th element modification status.
Definition: Tracked.h:741
bool is_size_dirty(const Tracked< std::vector< T >> &t)
Return size changed dirty flag of Tracked vector.
Definition: Tracked.h:836
bool is_all_dirty() const
Has entire vector been marked as modified? Note that this will still return false if every entry has ...
Definition: Tracked.h:693
void modify()
Treat object as modified, even if it isn&#39;t.
T & get_mut()
Get a non-const ref to underlying object.
const_iterator cend() const
Pass through to cend method of underlying collection.
Definition: Tracked.h:444
Tracked(std::vector< T > val)
Construct from an existing vector.
Definition: Tracked.h:629
Tracked< uint32_t > TrackedU32
Definition: Tracked.h:322
bool is_dirty(size_t i) const
Check dirty status for given index, which is same as overall dirty status, since we don&#39;t track per c...
Definition: Tracked.h:471
char dirty_
Wrapped value.
Definition: Tracked.h:79
T & get_mutable()
Get a non-const ref to underlying object.
Definition: Tracked.h:117
Tracked< int > TrackedInt
Definition: Tracked.h:307
Tracked< long long > TrackedLongLong
Definition: Tracked.h:309
Tracked< int32_t > TrackedI32
Definition: Tracked.h:321
Tracked< signed char > TrackedSChar
Definition: Tracked.h:311
void modify()
Flag entire vector as modified.
Definition: Tracked.h:684
friend void swap(T &lhs, Tracked &rhs)
Implement swap between tracked object, and object of underlying type.
Definition: Tracked.h:214
friend void swap(Tracked &lhs, Tracked &rhs)
Implement swap between two tracked objects of same type.
Definition: Tracked.h:198
STL namespace.
size_t capacity() const
Pass through capacity to underlying string.
Definition: Tracked.h:491
bool is_size_dirty() const
Has the size of this vector changed?
Definition: Tracked.h:699
Tracked< short > TrackedShort
Definition: Tracked.h:306
const std::vector< T > * operator->() const
Use to call const methods on underlying vector.
Definition: Tracked.h:663
void clear_dirty()
Clear all modification tracking.
Definition: Tracked.h:716
Tracks the modification status of a wrapped object of the given type.
Definition: Tracked.h:75
const value_type & operator[](size_t i) const
Pass through operator[] to underlying collection.
Definition: Tracked.h:358
Tracked< long > TrackedLong
Definition: Tracked.h:308
value_type & get_mutable(size_t i)
Synonym for.
Definition: Tracked.h:390
#define MADARA_MAKE_UNARY_ARITH_OP(op)
Definition: Tracked.h:285
void resize(size_t count)
Pass through resize method to underlying vector.
Definition: Tracked.h:750
Tracked & operator=(T val)
Assignment writes to the underlying object.
Definition: Tracked.h:145
void clear_dirty(Tracked< std::vector< T >> &t, size_t i)
Clear dirty flag at index of Tracked vector.
Definition: Tracked.h:843
Tracked< std::vector< double > > TrackedDoubleVector
Definition: Tracked.h:863
Vec val_
the vector we&#39;re wrapping
Definition: Tracked.h:595
size_t capacity() const
Pass through capacity method to underlying vector.
Definition: Tracked.h:758
value_type & at_mutable(size_t i)
Synonym for.
Definition: Tracked.h:378
void clear_dirty()
Resets modification status.
Definition: Tracked.h:168
const T & operator*() const
Dereference to underlying object.
Definition: Tracked.h:132
friend bool operator==(const Tracked &lhs, const Tracked &rhs)
Definition: Tracked.h:802
const_iterator end() const
Pass through to const end method of underlying collection.
Definition: Tracked.h:438
T & get_mutable()
Get a non-const ref to underlying object.
std::vector< uint64_t > dirty_
dirty status for each entry
Definition: Tracked.h:598
void push_back(const value_type &value)
Pass through push_back to underlying string.
Definition: Tracked.h:503
bool is_all_dirty(const Tracked< std::vector< T >> &t)
Return global dirty flag of Tracked vector.
Definition: Tracked.h:829
bool size_dirty_
dirty status for size of vector
Definition: Tracked.h:604
std::vector< T > & get_mut()
Get non-const reference to underlying vector; mark all elements as dirty immediately.
Definition: Tracked.h:641
const T * operator->() const
Pass through to underlying object.
Definition: Tracked.h:139
TrackedExtra< T, Tracked< T > > Base
Flag for modification status.
Definition: Tracked.h:81
Tracked< uint64_t > TrackedU64
Definition: Tracked.h:324
std::vector< T > & get_mutable()
Get non-const reference to underlying vector; mark all elements as dirty immediately.
Definition: Tracked.h:650
T & get_mut()
Get a non-const ref to underlying object.
Definition: Tracked.h:108
bool empty()
Pass through to empty method of underlying collection.
Definition: Tracked.h:398
Tracked< int64_t > TrackedI64
Definition: Tracked.h:323
Tracked< double > TrackedDouble
Definition: Tracked.h:327
Tracked< uint8_t > TrackedU8
Definition: Tracked.h:318
const T & get() const
Get a const ref to the underlying object.
Definition: Tracked.h:95
value_type & back()
Equivalent to non-const back method of underlying collection.
Definition: Tracked.h:420
const value_type * c_str() const
Pass through c_str data method underlying string.
Definition: Tracked.h:524
Tracked< typename std::decay< T >::type > track(T &&val)
Create a tracked version of a given object.
Definition: Tracked.h:225
friend void swap(Tracked &lhs, Tracked &rhs)
Implement swap for tracked vectors.
Definition: Tracked.h:810
std::basic_string< Char >::const_iterator const_iterator
Definition: Tracked.h:460
Tracked< char > TrackedChar
Definition: Tracked.h:305
bool is_dirty() const
Has anything about this vector changed?
Definition: Tracked.h:705
Tracked & operator=(const std::vector< T > &val)
Set entire vector to new vector.
Definition: Tracked.h:677
Used internally by Tracked.
Definition: Tracked.h:65
void pop_back()
Pass through pop_back to underlying string.
Definition: Tracked.h:510
Tracked< float > TrackedFloat
Definition: Tracked.h:326
Tracked< uint16_t > TrackedU16
Definition: Tracked.h:320
void clear()
Pass through clear method to underlying vector.
Definition: Tracked.h:790
void clear()
Pass through clear to underlying string.
Definition: Tracked.h:517
void push_back(const value_type &value)
Pass through push_back method to underlying vector.
Definition: Tracked.h:773
#define MADARA_MAKE_INCDEC_OP(op)
Definition: Tracked.h:295
const_iterator begin() const
Pass through to const begin method of underlying collection.
Definition: Tracked.h:426
void modify()
Treat object as modified, even if it isn&#39;t.
Definition: Tracked.h:155
void reserve(size_t count)
Pass through reserve method to underlying vector.
Definition: Tracked.h:766
Tracked< unsigned int > TrackedUInt
Definition: Tracked.h:313
Tracked< unsigned char > TrackedUChar
Definition: Tracked.h:310
value_type & front_mut()
Equivalent to non-const front method of underlying collection.
Definition: Tracked.h:415
friend bool operator<(const Tracked &lhs, const Tracked &rhs)
Definition: Tracked.h:806
bool clear_dirty(size_t i) const
Clear dirty status for given index, which is same as overall dirty status, since we don&#39;t track per c...
Definition: Tracked.h:478
const T & get_value(const T &t)
Fallback definition of get_value; simply passes through the value.
Definition: BaseTracker.h:33
Tracked< int8_t > TrackedI8
Definition: Tracked.h:317
Provides functions and classes for the distributed knowledge base.
const std::vector< T > & operator*() const
Dereference to const reference.
Definition: Tracked.h:657
void set(T val)
Set the underlying object, and mark as modified.
Definition: Tracked.h:124
void modify(size_t i)
Mark i-th element as modified.
Definition: Tracked.h:725
size_t size()
Pass through to size method of underlying collection.
Definition: Tracked.h:396
Tracked(T val)
Create a Tracked version of the given object, which is copied.
Definition: Tracked.h:92
void set_value(T &t, const T &v)
Fallback definition of set_value; simply passes through the value.
Definition: BaseTracker.h:40
const_iterator cbegin() const
Pass through to cbegin method of underlying collection.
Definition: Tracked.h:432
static size_t to_dirty_size(size_t i)
Get size of dirty_ vector needed to fit i-th dirty bit.
Definition: Tracked.h:615
void reserve(size_t count)
Pass through reserve to underlying string.
Definition: Tracked.h:497
bool is_dirty() const
Get modification status.
void clear_dirty(size_t i)
Clear i-th element modification status.
Definition: Tracked.h:733
const value_type * data() const
Pass through data method to underlying string.
Definition: Tracked.h:526
std::vector< T >::value_type value_type
Definition: Tracked.h:623
friend bool operator>=(const Tracked &lhs, const Tracked &rhs)
Definition: Tracked.h:805
Copyright (c) 2015 Carnegie Mellon University.
TrackedCollection< Vec, Tracked< std::vector< T > > > Base
Definition: Tracked.h:592
Tracked< std::vector< int64_t > > TrackedIntVector
Definition: Tracked.h:862
friend bool operator>(const Tracked &lhs, const Tracked &rhs)
Definition: Tracked.h:807
value_type & at_mut(size_t i)
Pass through to non-const version of at method of underlying collection Immediately mark that index a...
Definition: Tracked.h:371
Tracked< unsigned short > TrackedUShort
Definition: Tracked.h:312
Provides default versions of methods below.
Definition: Tracked.h:34
friend void swap(Tracked &lhs, T &rhs)
Implement swap between tracked object, and object of underlying type.
Definition: Tracked.h:206
std::vector< T >::const_iterator const_iterator
Definition: Tracked.h:624
const value_type & at(size_t i) const
Pass through at method to underlying collection.
Definition: Tracked.h:352
const value_type & front() const
Equivalent to front method of underlying collection.
Definition: Tracked.h:403
friend bool operator!=(const Tracked &lhs, const Tracked &rhs)
Definition: Tracked.h:803
void modify(size_t)
Flag this as modified; we don&#39;t track individual characters as dirty, so flags entire string...
Definition: Tracked.h:464
void clear_dirty()
Resets modification status.
void resize(size_t count)
Pass through resize to underlying string.
Definition: Tracked.h:484