USRP Hardware Driver and USRP Manual  Version: 3.14.0.HEAD-0-g6875d061
UHD and USRP Manual
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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  UHD_INLINE const data_t& get() const
59  {
60  return _data;
61  }
62 
67  UHD_INLINE bool is_dirty() const
68  {
69  return _dirty;
70  }
71 
76  {
77  _dirty = false;
78  }
79 
84  {
85  _dirty = true;
86  }
87 
93  UHD_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 
110  {
111  if (!(_data == source._data)) {
112  _dirty = true;
113  _data = source._data;
114  }
115  return *this;
116  }
117 
121  UHD_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 */
UHD_INLINE bool is_dirty() const
Definition: dirty_tracked.hpp:67
UHD_INLINE void force_dirty()
Definition: dirty_tracked.hpp:83
Definition: build_info.hpp:13
Definition: dirty_tracked.hpp:24
UHD_INLINE dirty_tracked & operator=(const dirty_tracked &source)
Definition: dirty_tracked.hpp:109
UHD_INLINE void mark_clean()
Definition: dirty_tracked.hpp:75
dirty_tracked(const data_t &value)
Definition: dirty_tracked.hpp:40
#define UHD_INLINE
Definition: config.h:53
dirty_tracked()
Definition: dirty_tracked.hpp:30
dirty_tracked(const dirty_tracked &source)
Definition: dirty_tracked.hpp:50
UHD_INLINE dirty_tracked & operator=(const data_t &value)
Definition: dirty_tracked.hpp:93