SOFA API  3ea83cbd
Open source framework for multi-physics simuation
sofa::core::objectmodel::AspectPool Class Reference

#include <AspectPool.h>

Detailed Description

This class is responsible for managing the pool of available aspects numbers. It is safe to use this class from several thread.

Public Member Functions

 AspectPool ()
 
 ~AspectPool ()
 
void setReleaseCallback (const std::function< void(int)> &callback)
 
AspectRef allocate ()
 
AspectRef getAspect (int id)
 
int nbAspects () const
 
int getAspectCounter (int id) const
 

Protected Member Functions

void release (int id)
 

Friends

class Aspect
 

Constructor details

◆ AspectPool()

sofa::core::objectmodel::AspectPool::AspectPool ( )

Constructor: creates a new aspect pool.

◆ ~AspectPool()

sofa::core::objectmodel::AspectPool::~AspectPool ( )

Destructor.

Function details

◆ allocate()

AspectRef sofa::core::objectmodel::AspectPool::allocate ( )

Request a new aspect. The returned object should stay alive as long as the aspect is in use. It it possible to duplicate the AspectRef if several threads/algorithm use the same aspect. If no aspect remains available, null pointer is returned.

◆ getAspect()

AspectRef sofa::core::objectmodel::AspectPool::getAspect ( int  id)

◆ getAspectCounter()

int sofa::core::objectmodel::AspectPool::getAspectCounter ( int  id) const
inline

◆ nbAspects()

int sofa::core::objectmodel::AspectPool::nbAspects ( ) const
inline

◆ release()

void sofa::core::objectmodel::AspectPool::release ( int  id)
protected

Release the aspect having the specified number. It makes the number immediately available to satisfy subsequent AspectPool::allocate requests.

◆ setReleaseCallback()

void sofa::core::objectmodel::AspectPool::setReleaseCallback ( const std::function< void(int)> &  callback)

Related details

◆ Aspect

friend class Aspect
friend