USRP Hardware Driver and USRP Manual  Version: 3.13.0.HEAD-0-gf114cfa0
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>
25  class dirty_tracked {
26  public:
31  _data(), //data_t must have a default ctor
32  _dirty(true)
33  {}
34 
38  dirty_tracked(const data_t& value) :
39  _data(value), //data_t must have a copy ctor
40  _dirty(true)
41  {}
42 
46  dirty_tracked(const dirty_tracked& source) {
47  *this = source;
48  }
49 
53  UHD_INLINE const data_t& get() const {
54  return _data;
55  }
56 
61  UHD_INLINE bool is_dirty() const {
62  return _dirty;
63  }
64 
69  _dirty = false;
70  }
71 
76  _dirty = true;
77  }
78 
84  UHD_INLINE dirty_tracked& operator=(const data_t& value)
85  {
86  if(!(_data == value)) { //data_t must have an equality operator
87  _dirty = true;
88  _data = value; //data_t must have an assignment operator
89  }
90  return *this;
91  }
92 
101  if (!(_data == source._data)) {
102  _dirty = true;
103  _data = source._data;
104  }
105  return *this;
106  }
107 
111  UHD_INLINE operator const data_t&() const {
112  return get();
113  }
114 
115  private:
116  data_t _data;
117  bool _dirty;
118  };
119 
120 } //namespace uhd
121 
122 #endif /* INCLUDED_UHD_UTILS_DIRTY_TRACKED_HPP */
UHD_INLINE bool is_dirty() const
Definition: dirty_tracked.hpp:61
UHD_INLINE void force_dirty()
Definition: dirty_tracked.hpp:75
Definition: build_info.hpp:14
Definition: dirty_tracked.hpp:25
UHD_INLINE dirty_tracked & operator=(const dirty_tracked &source)
Definition: dirty_tracked.hpp:100
UHD_INLINE void mark_clean()
Definition: dirty_tracked.hpp:68
dirty_tracked(const data_t &value)
Definition: dirty_tracked.hpp:38
#define UHD_INLINE
Definition: config.h:53
dirty_tracked()
Definition: dirty_tracked.hpp:30
dirty_tracked(const dirty_tracked &source)
Definition: dirty_tracked.hpp:46
UHD_INLINE dirty_tracked & operator=(const data_t &value)
Definition: dirty_tracked.hpp:84