V-Gears 0
Free Final Fantasy VII engine.
ParticlePool< T > Class Template Reference

A particle pool. More...

#include <ParticlePool.h>

Public Types

typedef std::list< T * > PoolList
 
typedef PoolList::iterator PoolIterator
 

Public Member Functions

 ParticlePool ()
 Constructor. More...
 
virtual ~ParticlePool ()
 Destructor. More...
 
bool IsEmpty ()
 Checks if the pool is empty. More...
 
size_t GetSize ()
 Retrieves the pool size. More...
 
void ResetIterator ()
 Resets the pool iterator. More...
 
T * GetFirst ()
 Retrieves the first particle. More...
 
T * GetNext ()
 Retrieves the next particle in the pool. More...
 
bool End ()
 Checks if the iterator is at the end of the pool. More...
 
void Clear ()
 Removes all particles. More...
 
void AddElement (T *element)
 Adds a particle to the pool. More...
 
T * ReleaseElement ()
 Releases a locked particle. More...
 
void ReleaseAllElements ()
 Releases all locked particles. More...
 
void LockLatestElement ()
 Locks the released particle pointed by the iterator. More...
 
void LockAllElements ()
 Locks all particles. More...
 
std::list< T * > & GetActiveElementsList ()
 Retrieves the list of released particles. More...
 

Protected Attributes

PoolList released_
 List with released particles. More...
 
PoolList locked_
 List with locked particles. More...
 
PoolIterator pool_iterator_
 The pool iterator. More...
 

Detailed Description

template<typename T>
class ParticlePool< T >

A particle pool.

There are actually two pools, one for locked particles and one for released ones. Locked particles can't be used until they are released.

Template Parameters
TThe type of particle.

Member Typedef Documentation

◆ PoolIterator

template<typename T >
typedef PoolList::iterator ParticlePool< T >::PoolIterator

◆ PoolList

template<typename T >
typedef std::list<T*> ParticlePool< T >::PoolList

Constructor & Destructor Documentation

◆ ParticlePool()

template<typename T >
ParticlePool< T >::ParticlePool ( )
inline

Constructor.

◆ ~ParticlePool()

template<typename T >
virtual ParticlePool< T >::~ParticlePool ( )
inlinevirtual

Destructor.

Member Function Documentation

◆ AddElement()

template<typename T >
void ParticlePool< T >::AddElement ( T *  element)
inline

Adds a particle to the pool.

A particle is added in locked state.

Parameters
[in]elementParticle to add to the pool.

◆ Clear()

template<typename T >
void ParticlePool< T >::Clear ( )
inline

Removes all particles.

Removes both locked and released particles.

◆ End()

template<typename T >
bool ParticlePool< T >::End ( )
inline

Checks if the iterator is at the end of the pool.

If it's at the end, {

See also
GetNext} will return null when called. It doesn't consider locked particles, only the released ones.
Returns
True if the iterator is at the end of the pool.

◆ GetActiveElementsList()

template<typename T >
std::list< T * > & ParticlePool< T >::GetActiveElementsList ( )
inline

Retrieves the list of released particles.

Returns
List of released particles.

◆ GetFirst()

template<typename T >
T * ParticlePool< T >::GetFirst ( )
inline

Retrieves the first particle.

Before doing so, it resets the pool iterator. It doesn't consider locked particles, only the released ones.

Returns
A reference to the first particle in the pool. NULL if the pool is empty.

◆ GetNext()

template<typename T >
T * ParticlePool< T >::GetNext ( )
inline

Retrieves the next particle in the pool.

Before doing so, it advances the pool iterator. It doesn't consider locked particles, only the released ones.

Returns
A reference to the next particle in the pool. NULL if the pool is empty or the iterator is at the end of it.

◆ GetSize()

template<typename T >
size_t ParticlePool< T >::GetSize ( )
inline

Retrieves the pool size.

It doesn't consider locked particles, only the released ones.

Returns
The number of particles in the pool.

◆ IsEmpty()

template<typename T >
bool ParticlePool< T >::IsEmpty ( )
inline

Checks if the pool is empty.

It doesn't consider locked particles, only the released ones.

Returns
True if the pool is empty, false if there is at least one particle in the pool.

◆ LockAllElements()

template<typename T >
void ParticlePool< T >::LockAllElements ( )
inline

Locks all particles.

The particles get added at the end of the locked list in the same order they were in the released list. The pool iterator is reseted.

◆ LockLatestElement()

template<typename T >
void ParticlePool< T >::LockLatestElement ( )
inline

Locks the released particle pointed by the iterator.

The particle gets added to the end of the locked particle list.

◆ ReleaseAllElements()

template<typename T >
void ParticlePool< T >::ReleaseAllElements ( )
inline

Releases all locked particles.

It also resets the pool operator.

◆ ReleaseElement()

template<typename T >
T * ParticlePool< T >::ReleaseElement ( )
inline

Releases a locked particle.

The first locked particle will be the one unlocked.

Returns
A pointer to the previously locked and now released particle, or 0 if there were no more locked particles.

◆ ResetIterator()

template<typename T >
void ParticlePool< T >::ResetIterator ( )
inline

Resets the pool iterator.

Member Data Documentation

◆ locked_

template<typename T >
PoolList ParticlePool< T >::locked_
protected

List with locked particles.

They can't be operated upon until released.

◆ pool_iterator_

template<typename T >
PoolIterator ParticlePool< T >::pool_iterator_
protected

The pool iterator.

Determines the current particle to be acted upon. Only works for released particles.

◆ released_

template<typename T >
PoolList ParticlePool< T >::released_
protected

List with released particles.

They can be operated upon.


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