2018-08-05 14:45:34 +00:00
|
|
|
#ifndef __TRACYDECAYVALUE_HPP__
|
|
|
|
#define __TRACYDECAYVALUE_HPP__
|
|
|
|
|
2022-07-17 11:41:40 +00:00
|
|
|
#include "../public/common/TracyForceInline.hpp"
|
2018-08-05 14:45:34 +00:00
|
|
|
|
|
|
|
namespace tracy
|
|
|
|
{
|
|
|
|
|
|
|
|
template<typename T>
|
|
|
|
class DecayValue
|
|
|
|
{
|
|
|
|
public:
|
2020-05-07 23:48:37 +00:00
|
|
|
DecayValue( const T& init, bool active = false )
|
2018-08-05 14:45:34 +00:00
|
|
|
: m_value( init )
|
2020-05-07 23:48:37 +00:00
|
|
|
, m_active( active )
|
2018-08-05 14:45:34 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
tracy_force_inline operator const T& () const { return m_value; }
|
2018-10-05 18:39:42 +00:00
|
|
|
tracy_force_inline T operator->() const { return m_value; }
|
2018-08-05 14:45:34 +00:00
|
|
|
|
|
|
|
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
|