USRP Hardware Driver and USRP Manual  Version: 3.11.0.HEAD-0-gdca39145
UHD and USRP Manual
dirty_tracked.hpp
Go to the documentation of this file.
1 //
2 // Copyright 2010-2015 Ettus Research LLC
3 //
4 // SPDX-License-Identifier: GPL-3.0
5 //
6 
7 #ifndef INCLUDED_UHD_UTILS_DIRTY_TRACKED_HPP
8 #define INCLUDED_UHD_UTILS_DIRTY_TRACKED_HPP
9 
10 namespace uhd{
23  template<typename data_t>
24  class dirty_tracked {
25  public:
30  _data(), //data_t must have a default ctor
31  _dirty(true)
32  {}
33 
37  dirty_tracked(const data_t& value) :
38  _data(value), //data_t must have a copy ctor
39  _dirty(true)
40  {}
41 
45  dirty_tracked(const dirty_tracked& source) {
46  *this = source;
47  }
48 
52  UHD_INLINE const data_t& get() const {
53  return _data;
54  }
55 
60  UHD_INLINE bool is_dirty() const {
61  return _dirty;
62  }
63 
68  _dirty = false;
69  }
70 
75  _dirty = true;
76  }
77 
83  UHD_INLINE dirty_tracked& operator=(const data_t& value)
84  {
85  if(!(_data == value)) { //data_t must have an equality operator
86  _dirty = true;
87  _data = value; //data_t must have an assignment operator
88  }
89  return *this;
90  }
91 
100  if (!(_data == source._data)) {
101  _dirty = true;
102  _data = source._data;
103  }
104  return *this;
105  }
106 
110  UHD_INLINE operator const data_t&() const {
111  return get();
112  }
113 
114  private:
115  data_t _data;
116  bool _dirty;
117  };
118 
119 } //namespace uhd
120 
121 #endif /* INCLUDED_UHD_UTILS_DIRTY_TRACKED_HPP */
UHD_INLINE bool is_dirty() const
Definition: dirty_tracked.hpp:60
UHD_INLINE void force_dirty()
Definition: dirty_tracked.hpp:74
Definition: build_info.hpp:14
Definition: dirty_tracked.hpp:24
UHD_INLINE dirty_tracked & operator=(const dirty_tracked &source)
Definition: dirty_tracked.hpp:99
UHD_INLINE void mark_clean()
Definition: dirty_tracked.hpp:67
dirty_tracked(const data_t &value)
Definition: dirty_tracked.hpp:37
#define UHD_INLINE
Definition: config.h:52
dirty_tracked()
Definition: dirty_tracked.hpp:29
dirty_tracked(const dirty_tracked &source)
Definition: dirty_tracked.hpp:45
UHD_INLINE dirty_tracked & operator=(const data_t &value)
Definition: dirty_tracked.hpp:83