USRP Hardware Driver and USRP Manual  Version: 003.009.001-0-gf7a15853
UHD and USRP Manual
dirty_tracked.hpp
Go to the documentation of this file.
1 //
2 // Copyright 2010-2014 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  inline const data_t& get() const {
64  return _data;
65  }
66 
71  inline bool is_dirty() const {
72  return _dirty;
73  }
74 
78  inline void mark_clean() {
79  _dirty = false;
80  }
81 
85  inline void force_dirty() {
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  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  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 */
void mark_clean()
Definition: dirty_tracked.hpp:78
dirty_tracked & operator=(const data_t &value)
Definition: dirty_tracked.hpp:94
bool is_dirty() const
Definition: dirty_tracked.hpp:71
Definition: convert.hpp:28
Definition: dirty_tracked.hpp:35
dirty_tracked(const data_t &value)
Definition: dirty_tracked.hpp:48
void force_dirty()
Definition: dirty_tracked.hpp:85
dirty_tracked & operator=(const dirty_tracked &source)
Definition: dirty_tracked.hpp:110
dirty_tracked()
Definition: dirty_tracked.hpp:40
dirty_tracked(const dirty_tracked &source)
Definition: dirty_tracked.hpp:56