Play-/Source/OsVariableWrapper.h

37 lines
590 B
C
Raw Normal View History

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