Loading...
Searching...
No Matches
dirty_tracked.hpp
Go to the documentation of this file.
//
// Copyright 2010-2015 Ettus Research LLC
// Copyright 2018 Ettus Research, a National Instruments Company
//
// SPDX-License-Identifier: GPL-3.0-or-later
//
#pragma once
namespace uhd {
template <typename data_t>
class dirty_tracked
{
public:
dirty_tracked()
: _data()
, // data_t must have a default ctor
_dirty(true)
{
}
dirty_tracked(const data_t& value)
: _data(value)
, // data_t must have a copy ctor
_dirty(true)
{
}
dirty_tracked(const uhd::dirty_tracked<data_t>&) = default;
inline const data_t& get() const
{
return _data;
}
inline bool is_dirty() const
{
return _dirty;
}
inline void mark_clean()
{
_dirty = false;
}
inline void force_dirty()
{
_dirty = true;
}
inline dirty_tracked& operator=(const data_t& value)
{
if (!(_data == value)) { // data_t must have an equality operator
_dirty = true;
_data = value; // data_t must have an assignment operator
}
return *this;
}
inline dirty_tracked& operator=(const dirty_tracked& source)
{
if (!(_data == source._data)) {
_dirty = true;
_data = source._data;
}
return *this;
}
inline operator const data_t&() const
{
return get();
}
private:
data_t _data;
bool _dirty;
};
} // namespace uhd
uhd::dirty_tracked
Definition dirty_tracked.hpp:25
uhd::dirty_tracked::force_dirty
void force_dirty()
Definition dirty_tracked.hpp:77
uhd::dirty_tracked::dirty_tracked
dirty_tracked(const data_t &value)
Definition dirty_tracked.hpp:40
uhd::dirty_tracked::is_dirty
bool is_dirty() const
Definition dirty_tracked.hpp:61
uhd::dirty_tracked::operator=
dirty_tracked & operator=(const data_t &value)
Definition dirty_tracked.hpp:87
uhd::dirty_tracked::dirty_tracked
dirty_tracked()
Definition dirty_tracked.hpp:30
uhd::dirty_tracked::mark_clean
void mark_clean()
Definition dirty_tracked.hpp:69
uhd::dirty_tracked::get
const data_t & get() const
Definition dirty_tracked.hpp:52
uhd::dirty_tracked::dirty_tracked
dirty_tracked(const uhd::dirty_tracked< data_t > &)=default
uhd::dirty_tracked::operator=
dirty_tracked & operator=(const dirty_tracked &source)
Definition dirty_tracked.hpp:103
uhd
Definition build_info.hpp:12