USRP Hardware Driver and USRP Manual  Version: 3.15.0.HEAD-0-gaea0e2de
UHD and USRP Manual
dirty_tracked.hpp
Go to the documentation of this file.
1 //
2 // Copyright 2010-2015 Ettus Research LLC
3 // Copyright 2018 Ettus Research, a National Instruments Company
4 //
5 // SPDX-License-Identifier: GPL-3.0-or-later
6 //
7 
8 #ifndef INCLUDED_UHD_UTILS_DIRTY_TRACKED_HPP
9 #define INCLUDED_UHD_UTILS_DIRTY_TRACKED_HPP
10 
11 namespace uhd {
24 template <typename data_t> class dirty_tracked
25 {
26 public:
31  : _data()
32  , // data_t must have a default ctor
33  _dirty(true)
34  {
35  }
36 
40  dirty_tracked(const data_t& value)
41  : _data(value)
42  , // data_t must have a copy ctor
43  _dirty(true)
44  {
45  }
46 
51  {
52  *this = source;
53  }
54 
58  inline const data_t& get() const
59  {
60  return _data;
61  }
62 
67  inline bool is_dirty() const
68  {
69  return _dirty;
70  }
71 
75  inline void mark_clean()
76  {
77  _dirty = false;
78  }
79 
83  inline void force_dirty()
84  {
85  _dirty = true;
86  }
87 
93  inline dirty_tracked& operator=(const data_t& value)
94  {
95  if (!(_data == value)) { // data_t must have an equality operator
96  _dirty = true;
97  _data = value; // data_t must have an assignment operator
98  }
99  return *this;
100  }
101 
109  inline dirty_tracked& operator=(const dirty_tracked& source)
110  {
111  if (!(_data == source._data)) {
112  _dirty = true;
113  _data = source._data;
114  }
115  return *this;
116  }
117 
121  inline operator const data_t&() const
122  {
123  return get();
124  }
125 
126 private:
127  data_t _data;
128  bool _dirty;
129 };
130 
131 } // namespace uhd
132 
133 #endif /* INCLUDED_UHD_UTILS_DIRTY_TRACKED_HPP */
void mark_clean()
Definition: dirty_tracked.hpp:75
dirty_tracked & operator=(const data_t &value)
Definition: dirty_tracked.hpp:93
bool is_dirty() const
Definition: dirty_tracked.hpp:67
Definition: build_info.hpp:13
Definition: dirty_tracked.hpp:24
dirty_tracked(const data_t &value)
Definition: dirty_tracked.hpp:40
void force_dirty()
Definition: dirty_tracked.hpp:83
dirty_tracked & operator=(const dirty_tracked &source)
Definition: dirty_tracked.hpp:109
dirty_tracked()
Definition: dirty_tracked.hpp:30
dirty_tracked(const dirty_tracked &source)
Definition: dirty_tracked.hpp:50