Added state event.
This commit is contained in:
@ -4,15 +4,23 @@
|
||||
// https://opensource.org/licenses/MIT
|
||||
|
||||
#pragma once
|
||||
#include "StateOwner.hpp"
|
||||
#include "assert/assert.hpp"
|
||||
|
||||
namespace Dawn {
|
||||
class StateOwner;
|
||||
|
||||
template<class V>
|
||||
class StateProperty {
|
||||
private:
|
||||
StateOwner *owner;
|
||||
V value;
|
||||
|
||||
/**
|
||||
* Method that is invoked every time that the value of this state property
|
||||
* is updated.
|
||||
*
|
||||
* @param val Value that is to be used for this property.
|
||||
*/
|
||||
void setInternal(V val) {
|
||||
if(val == this->value) return;// TODO: can I omit this? kinda bad tbh.
|
||||
assertNotNull(this->owner);
|
||||
@ -44,6 +52,9 @@ namespace Dawn {
|
||||
return this->value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Destructor for StateProperty.
|
||||
*/
|
||||
~StateProperty() {
|
||||
this->owner->_statePropertyDestroyed(this);
|
||||
}
|
||||
|
Reference in New Issue
Block a user