// Copyright (c) 2023 Dominic Masters // // This software is released under the MIT License. // https://opensource.org/licenses/MIT #pragma once #include "assert/assert.hpp" #include "event/Event.hpp" namespace Dawn { class IStateEvent; template class StateEvent; template class StateOwnerEventLegacy; class IStateOwnerEventLegacy { public: virtual void removeListener() = 0; virtual void teardown() = 0; }; class IStateOwner { public: virtual void _stateEventDisposed(IStateEvent *evt) = 0; virtual void _stateLegacyEventDisposed(IStateOwnerEventLegacy *evt) = 0; }; template struct StateEventListener { uint32_t id; IStateOwner *owner; std::function listener; std::function)> unsubWithParams; std::function unsub; StateEvent *event; }; class IStateProperty { public: IStateOwner *owner = nullptr; std::vector> _effectListners; std::vector()>> _effectListnersWithTeardown; std::vector> _effectTeardowns; }; class IStateEvent { protected: virtual void _stateOwnerDestroyed(IStateOwner *owner) = 0; friend class StateOwner; }; }