Play-/Source/OsVariableWrapper.h

40 lines
593 B
C
Raw Permalink Normal View History

2015-08-06 01:05:34 -04:00
#pragma once
template <typename Type>
struct OsVariableWrapper
{
public:
2018-04-30 21:01:23 +01:00
explicit OsVariableWrapper(Type* storage)
: m_storage(storage)
{
}
2015-08-06 01:05:34 -04:00
OsVariableWrapper(const OsVariableWrapper&) = delete;
2018-04-30 21:01:23 +01:00
OsVariableWrapper& operator=(const OsVariableWrapper&) = delete;
2015-08-06 01:05:34 -04:00
2018-04-30 21:01:23 +01:00
OsVariableWrapper& operator=(const Type& value)
2015-08-06 01:05:34 -04:00
{
(*m_storage) = value;
return (*this);
}
2018-04-30 21:01:23 +01:00
Type& operator+=(const Type& addend)
2018-02-05 13:17:46 -05:00
{
(*m_storage) += addend;
return (*m_storage);
}
2015-08-06 01:05:34 -04:00
operator Type() const
{
return *m_storage;
}
uint32 Get() const
{
return *m_storage;
}
2015-08-06 01:05:34 -04:00
private:
2018-04-30 21:01:23 +01:00
Type* m_storage;
2015-08-06 01:05:34 -04:00
};