Emergency 20 Dokumentation  4.2.0
em5::ComponentsRandomEnumerator< T > Class Template Reference

Helper class for iterating over a list of component instances of a specific type, in a random order. More...

#include <ComponentsRandomEnumerator.h>

Inheritance diagram for em5::ComponentsRandomEnumerator< T >:
em5::RandomEnumerator< T >

Public Member Functions

 ComponentsRandomEnumerator (uint32 maxTries=std::numeric_limits< uint32 >::max())
 Constructor that will use all of main map's components to chose from. More...
 
 ComponentsRandomEnumerator (const std::vector< T * > &inputToCopy, uint32 maxTries=std::numeric_limits< uint32 >::max())
 Constructor to pass a vector of components, which will be copied. More...
 
 ComponentsRandomEnumerator (std::vector< T * > &inputToCopy, uint32 maxTries=std::numeric_limits< uint32 >::max())
 
 ComponentsRandomEnumerator (constructionpolicy::Policy policy, std::vector< T * > &inputToSwapWith, uint32 maxTries=std::numeric_limits< uint32 >::max())
 Constructor to pass a vector of components, with the option to swap contents. More...
 
qsf::EntitygetNextEntity ()
 Randomly choose a component that was not chosen already, and return its entity. More...
 
- Public Member Functions inherited from em5::RandomEnumerator< T >
 RandomEnumerator (const std::vector< T * > &inputToCopy, uint32 maxTries=std::numeric_limits< uint32 >::max())
 Constructor to pass a vector of elements, which will be copied. More...
 
 RandomEnumerator (constructionpolicy::Policy policy, std::vector< T * > &inputToSwapWith, uint32 maxTries=std::numeric_limits< uint32 >::max())
 Constructor to pass a vector of elements, with the option to swap contents. More...
 
 RandomEnumerator (std::vector< T * > &inputToCopy, uint32 maxTries=std::numeric_limits< uint32 >::max())
 
bool empty () const
 Check if all elements were read out already. More...
 
T * getNext ()
 Randomly choose an element that was not returned before. More...
 

Additional Inherited Members

- Protected Member Functions inherited from em5::RandomEnumerator< T >
 RandomEnumerator (uint32 maxTries=std::numeric_limits< uint32 >::max())
 
- Protected Attributes inherited from em5::RandomEnumerator< T >
std::vector< T * > mElements
 
uint32 mTriesLeft
 

Detailed Description

template<typename T>
class em5::ComponentsRandomEnumerator< T >

Helper class for iterating over a list of component instances of a specific type, in a random order.

Remarks
No component will be returned twice. Can be used to iterate either over all instances in the main map, or a custom list of components.

Constructor & Destructor Documentation

template<typename T >
em5::ComponentsRandomEnumerator< T >::ComponentsRandomEnumerator ( uint32  maxTries = std::numeric_limits<uint32>::max())
inlineexplicit

Constructor that will use all of main map's components to chose from.

template<typename T >
em5::ComponentsRandomEnumerator< T >::ComponentsRandomEnumerator ( const std::vector< T * > &  inputToCopy,
uint32  maxTries = std::numeric_limits<uint32>::max() 
)
inlineexplicit

Constructor to pass a vector of components, which will be copied.

template<typename T >
em5::ComponentsRandomEnumerator< T >::ComponentsRandomEnumerator ( std::vector< T * > &  inputToCopy,
uint32  maxTries = std::numeric_limits<uint32>::max() 
)
inlineexplicit
template<typename T >
em5::ComponentsRandomEnumerator< T >::ComponentsRandomEnumerator ( constructionpolicy::Policy  policy,
std::vector< T * > &  inputToSwapWith,
uint32  maxTries = std::numeric_limits<uint32>::max() 
)
inline

Constructor to pass a vector of components, with the option to swap contents.

Member Function Documentation

template<typename T >
qsf::Entity* em5::ComponentsRandomEnumerator< T >::getNextEntity ( )
inline

Randomly choose a component that was not chosen already, and return its entity.

Returns
Pointer to another entity, which gets randomly chosen from the list; or a null pointer in case we already had all components

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