OpenEnroth 73e68f7
Loading...
Searching...
No Matches
Classes | Public Member Functions | Static Private Member Functions | Private Attributes | List of all members
PlatformComponentStorage Class Reference

#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
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ PlatformComponentStorage()

PlatformComponentStorage::PlatformComponentStorage ( )
default

◆ ~PlatformComponentStorage()

PlatformComponentStorage::~PlatformComponentStorage ( )

Member Function Documentation

◆ clear()

void PlatformComponentStorage::clear ( )

◆ contains()

template<class T >
bool PlatformComponentStorage::contains ( ) const
inline

◆ destructor()

template<class T >
static void PlatformComponentStorage::destructor ( void *  p)
inlinestaticprivate

◆ insert()

template<class T >
T * PlatformComponentStorage::insert ( std::unique_ptr< T >  component,
std::function< void()>  cleanupRoutine 
)
inline

◆ remove()

template<class T >
std::unique_ptr< T > PlatformComponentStorage::remove ( )
inline

◆ require()

template<class T >
T * PlatformComponentStorage::require ( ) const
inline

Member Data Documentation

◆ _dataByType

std::unordered_map<std::type_index, Data> PlatformComponentStorage::_dataByType
private

◆ _nextIndex

int PlatformComponentStorage::_nextIndex = 0
private

The documentation for this class was generated from the following files: