USRP Hardware Driver and USRP Manual  Version: 004.000.000.HEAD-0-g8773fb2c
UHD and USRP Manual
dirty_tracked.hpp
Go to the documentation of this file.
1 //
2 // Copyright 2010-2015 Ettus Research LLC
3 //
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
16 //
17 
18 #ifndef INCLUDED_UHD_UTILS_DIRTY_TRACKED_HPP
19 #define INCLUDED_UHD_UTILS_DIRTY_TRACKED_HPP
20 
21 namespace uhd{
34  template<typename data_t>
35  class dirty_tracked {
36  public:
41  _data(), //data_t must have a default ctor
42  _dirty(true)
43  {}
44 
48  dirty_tracked(const data_t& value) :
49  _data(value), //data_t must have a copy ctor
50  _dirty(true)
51  {}
52 
56  dirty_tracked(const dirty_tracked& source) {
57  *this = source;
58  }
59 
63  UHD_INLINE const data_t& get() const {
64  return _data;
65  }
66 
71  UHD_INLINE bool is_dirty() const {
72  return _dirty;
73  }
74 
79  _dirty = false;
80  }
81 
86  _dirty = true;
87  }
88 
94  UHD_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 
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  return get();
123  }
124 
125  private:
126  data_t _data;
127  bool _dirty;
128  };
129 
130 } //namespace uhd
131 
132 #endif /* INCLUDED_UHD_UTILS_DIRTY_TRACKED_HPP */
UHD_INLINE bool is_dirty() const
Definition: dirty_tracked.hpp:71
UHD_INLINE void force_dirty()
Definition: dirty_tracked.hpp:85
Definition: build_info.hpp:25
Definition: dirty_tracked.hpp:35
UHD_INLINE dirty_tracked & operator=(const dirty_tracked &source)
Definition: dirty_tracked.hpp:110
UHD_INLINE void mark_clean()
Definition: dirty_tracked.hpp:78
dirty_tracked(const data_t &value)
Definition: dirty_tracked.hpp:48
#define UHD_INLINE
Definition: config.h:63
dirty_tracked()
Definition: dirty_tracked.hpp:40
dirty_tracked(const dirty_tracked &source)
Definition: dirty_tracked.hpp:56
UHD_INLINE dirty_tracked & operator=(const data_t &value)
Definition: dirty_tracked.hpp:94