Added state event.

This commit is contained in:
2023-02-27 12:46:02 -08:00
parent e625078efe
commit fc34ae94ff
5 changed files with 88 additions and 18 deletions

View File

@ -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);
}