OpenEnroth 73e68f7
|
#include <PlatformComponentStorage.h>
Classes | |
struct | Data |
Public Member Functions | |
PlatformComponentStorage () | |
~PlatformComponentStorage () | |
template<class T > | |
T * | insert (std::unique_ptr< T > component, std::function< void()> cleanupRoutine) |
template<class T > | |
std::unique_ptr< T > | remove () |
template<class T > | |
bool | contains () const |
template<class T > | |
T * | require () const |
void | clear () |
Static Private Member Functions | |
template<class T > | |
static void | destructor (void *p) |
Private Attributes | |
std::unordered_map< std::type_index, Data > | _dataByType |
int | _nextIndex = 0 |
Type-erased storage for components.
Note that the storage takes ownership of the inserted components, and they are removed & destroyed only when the storage itself is destroyed.
While this class offers remove
method, its usage is discouraged. The reason is that even though the storage itself doesn't care about insertion order, the enclosing PlatformApplication
maintains proxy and event filter chains, for which insertion order matters. So inserting & removing components on the fly will likely result in hard to debug problems with components ending up in the wrong place.
|
default |
PlatformComponentStorage::~PlatformComponentStorage | ( | ) |
void PlatformComponentStorage::clear | ( | ) |
|
inline |
|
inlinestaticprivate |
|
inline |
|
inline |
|
inline |
|
private |
|
private |