blob: bcce09faa7bfe24d460891a5bf6b25880d5b1354 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
#ifndef __TRACYDECAYVALUE_HPP__
#define __TRACYDECAYVALUE_HPP__
#include "../common/TracyForceInline.hpp"
namespace tracy
{
template<typename T>
class DecayValue
{
public:
DecayValue( const T& init )
: m_value( init )
, m_active( false )
{
}
tracy_force_inline operator const T& () const { return m_value; }
tracy_force_inline T operator->() const { return m_value; }
tracy_force_inline DecayValue& operator=( const T& value )
{
m_value = value;
m_active = true;
return *this;
}
tracy_force_inline void Decay( const T& value )
{
if( m_active )
{
m_active = false;
}
else
{
m_value = value;
}
}
private:
T m_value;
bool m_active;
};
}
#endif
|