2013-01-19 20:02:34 +00:00
|
|
|
#ifndef BINDABLE_VAR_H_INCLUDED
|
|
|
|
#define BINDABLE_VAR_H_INCLUDED
|
|
|
|
|
2024-06-05 18:19:20 +00:00
|
|
|
#include "boost/signals2.hpp"
|
2013-01-19 20:02:34 +00:00
|
|
|
#include "boost/variant.hpp"
|
|
|
|
|
|
|
|
namespace SE
|
|
|
|
{
|
|
|
|
|
|
|
|
//Must be stored in shared_ptr:
|
|
|
|
|
|
|
|
template<typename TYPENAME>
|
|
|
|
class TBindableVar
|
|
|
|
{
|
|
|
|
protected:
|
|
|
|
TYPENAME Variable;
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
2024-06-05 18:19:20 +00:00
|
|
|
boost::signals2::signal<void(const TYPENAME&)> OnVarChanged;
|
2013-01-19 20:02:34 +00:00
|
|
|
|
|
|
|
TBindableVar()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
TBindableVar(const TYPENAME&& var)
|
|
|
|
: Variable(var)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
operator TYPENAME()
|
|
|
|
{
|
|
|
|
return Variable;
|
|
|
|
}
|
|
|
|
|
|
|
|
TYPENAME operator()()
|
|
|
|
{
|
|
|
|
return Variable;
|
|
|
|
}
|
|
|
|
|
|
|
|
TBindableVar<TYPENAME>& operator=(const TYPENAME& var)
|
|
|
|
{
|
|
|
|
Variable = var;
|
|
|
|
OnVarChanged(Variable);
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
} //namespace SE
|
|
|
|
|
|
|
|
#endif
|