mirror of
https://github.com/copyrighttxt/watrbx-game-engine.git
synced 2026-09-04 20:57:49 +00:00
fahhh
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
#pragma once
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <boost/functional/hash/hash.hpp>
|
||||
|
||||
namespace RBX {
|
||||
|
||||
template<class Type>
|
||||
class ProtectedGeneric
|
||||
{
|
||||
private:
|
||||
Type value;
|
||||
std::size_t hash;
|
||||
public:
|
||||
const Type& peekValue() const
|
||||
{
|
||||
return value;
|
||||
}
|
||||
bool getValue(Type& _value) const
|
||||
{
|
||||
_value = this->value;
|
||||
|
||||
boost::hash<Type> hasher;
|
||||
std::size_t newHash = hasher(_value);
|
||||
return (hash == newHash);
|
||||
}
|
||||
void setValue(Type _value)
|
||||
{
|
||||
this->value = _value;
|
||||
|
||||
boost::hash<Type> hasher;
|
||||
hash = hasher(_value);
|
||||
}
|
||||
|
||||
ProtectedGeneric(Type _value)
|
||||
{
|
||||
setValue(_value);
|
||||
}
|
||||
private:
|
||||
ProtectedGeneric(const ProtectedGeneric& other)
|
||||
{}
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user