USRP Hardware Driver and USRP Manual  Version: 3.15.0.0-4+b1satnogs1
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>
26 {
27 public:
32  : _data()
33  , // data_t must have a default ctor
34  _dirty(true)
35  {
36  }
37 
41  dirty_tracked(const data_t& value)
42  : _data(value)
43  , // data_t must have a copy ctor
44  _dirty(true)
45  {
46  }
47 
52  {
53  *this = source;
54  }
55 
59  inline const data_t& get() const
60  {
61  return _data;
62  }
63 
68  inline bool is_dirty() const
69  {
70  return _dirty;
71  }
72 
76  inline void mark_clean()
77  {
78  _dirty = false;
79  }
80 
84  inline void force_dirty()
85  {
86  _dirty = true;
87  }
88 
94  inline dirty_tracked& operator=(const data_t& value)
95  {
96  if (!(_data == value)) { // data_t must have an equality operator
97  _dirty = true;
98  _data = value; // data_t must have an assignment operator
99  }
100  return *this;
101  }
102 
110  inline dirty_tracked& operator=(const dirty_tracked& source)
111  {
112  if (!(_data == source._data)) {
113  _dirty = true;
114  _data = source._data;
115  }
116  return *this;
117  }
118 
122  inline operator const data_t&() const
123  {
124  return get();
125  }
126 
127 private:
128  data_t _data;
129  bool _dirty;
130 };
131 
132 } // namespace uhd
133 
134 #endif /* INCLUDED_UHD_UTILS_DIRTY_TRACKED_HPP */
Definition: dirty_tracked.hpp:26
const data_t & get() const
Definition: dirty_tracked.hpp:59
void force_dirty()
Definition: dirty_tracked.hpp:84
dirty_tracked(const data_t &value)
Definition: dirty_tracked.hpp:41
dirty_tracked & operator=(const dirty_tracked &source)
Definition: dirty_tracked.hpp:110
bool is_dirty() const
Definition: dirty_tracked.hpp:68
dirty_tracked()
Definition: dirty_tracked.hpp:31
dirty_tracked(const dirty_tracked &source)
Definition: dirty_tracked.hpp:51
void mark_clean()
Definition: dirty_tracked.hpp:76
dirty_tracked & operator=(const data_t &value)
Definition: dirty_tracked.hpp:94
Definition: build_info.hpp:13