More work on State System
This commit is contained in:
53
src/dawn/state/StateInterfaces.hpp
Normal file
53
src/dawn/state/StateInterfaces.hpp
Normal file
@ -0,0 +1,53 @@
|
||||
// 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<typename...A>
|
||||
class StateEvent;
|
||||
|
||||
template<typename ...A>
|
||||
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<typename...A>
|
||||
struct StateEventListener {
|
||||
uint32_t id;
|
||||
IStateOwner *owner;
|
||||
std::function<void(A...)> listener;
|
||||
std::function<void(StateEventListener<A...>)> unsubWithParams;
|
||||
std::function<void()> unsub;
|
||||
StateEvent<A...> *event;
|
||||
};
|
||||
|
||||
class IStateProperty {
|
||||
public:
|
||||
std::vector<std::function<void()>> _effectListners;
|
||||
std::vector<std::function<std::function<void()>()>> _effectListnersWithTeardown;
|
||||
std::vector<std::function<void()>> _effectTeardowns;
|
||||
};
|
||||
|
||||
class IStateEvent {
|
||||
protected:
|
||||
virtual void _stateOwnerDestroyed(IStateOwner *owner) = 0;
|
||||
friend class StateOwner;
|
||||
};
|
||||
}
|
Reference in New Issue
Block a user