Nemo  2.3.56
Simulate forward-in-time genetic evolution in a spatially explicit, individual-based stochastic simulator
ParamUpdater< SC > Class Template Reference

Implementation of the ParamUpdaterBase interface. More...

#include <param.h>

+ Inheritance diagram for ParamUpdater< SC >:
+ Collaboration diagram for ParamUpdater< SC >:

Public Member Functions

 ParamUpdater (bool(SC::*updateFuncPtr)(void))
 
 ParamUpdater (const ParamUpdater< SC > &PU)
 
virtual ~ParamUpdater ()
 
virtual void init ()
 Sets the pointer to the SimComponent. More...
 
virtual bool update (unsigned int generation)
 Calls the SimComponent's updating function using its pointer. More...
 
void setFuncPtr (bool(SC::*updateFuncPtr)(void))
 Sets the pointer to the updating function. More...
 
virtual SC * getComponent ()
 Accessor to the SimComponent. More...
 
- Public Member Functions inherited from ParamUpdaterBase
 ParamUpdaterBase ()
 
 ParamUpdaterBase (const ParamUpdaterBase &PU)
 
virtual ~ParamUpdaterBase ()
 
virtual void init ()=0
 
virtual void update ()
 
virtual bool update (unsigned int generation)=0
 Updating procedure. More...
 
virtual SimComponentgetComponent ()=0
 
virtual void addParam (Param *param)
 Adds a parameter to the stack. More...
 
virtual void reset ()
 Clears the parameters stack. More...
 
list< Param * > getParams ()
 Returns the list of parameters. More...
 
- Public Member Functions inherited from Handler
virtual void init ()=0
 Inits state. More...
 
virtual void update ()=0
 Updates the handler state. More...
 
virtual ~Handler ()
 

Private Attributes

bool(SC::* _myUpdaterFunction )(void)
 
SC * _myComponent
 

Additional Inherited Members

- Public Types inherited from ParamUpdaterBase
typedef list< Param * >::iterator PIT
 
- Protected Attributes inherited from ParamUpdaterBase
list< Param * > _params
 List of the parameters affected by this updater. More...
 

Detailed Description

template<class SC>
class ParamUpdater< SC >

Implementation of the ParamUpdaterBase interface.

Stores the pointers to the SimComponent and its updating function. The template argument allows to pass SimComponent class type necessary to call the updating function. The updating procedure is as follow: the parameters are first updated with their generational values (if the generation matches) and the component is then updated using its updating function. The updating process is implemented in the UpdaterServices class. Several parameters may want to use the same updating function and thus this class allows to run that function only once, after updating all the parameters that use it.

Constructor & Destructor Documentation

◆ ParamUpdater() [1/2]

template<class SC >
ParamUpdater< SC >::ParamUpdater ( bool(SC::*)(void)  updateFuncPtr)
inline
370 : _myComponent(0)
371 {
372 _myUpdaterFunction = updateFuncPtr;
373 }
bool(SC::* _myUpdaterFunction)(void)
Definition: param.h:365
SC * _myComponent
Definition: param.h:366

References ParamUpdater< SC >::_myUpdaterFunction.

◆ ParamUpdater() [2/2]

template<class SC >
ParamUpdater< SC >::ParamUpdater ( const ParamUpdater< SC > &  PU)
inline
376 {
377 _params.assign(PU._params.begin(), PU._params.end());
380 }
list< Param * > _params
List of the parameters affected by this updater.
Definition: param.h:319

References ParamUpdater< SC >::_myComponent, ParamUpdater< SC >::_myUpdaterFunction, and ParamUpdaterBase::_params.

◆ ~ParamUpdater()

template<class SC >
virtual ParamUpdater< SC >::~ParamUpdater ( )
inlinevirtual
383 {
384 for(PIT pit = _params.begin(); pit != _params.end(); pit++)
385 if((*pit)->getUpdater() == this) (*pit)->setUpdater(0);
386 }
list< Param * >::iterator PIT
Definition: param.h:323

References ParamUpdaterBase::_params.

Member Function Documentation

◆ getComponent()

template<class SC >
virtual SC * ParamUpdater< SC >::getComponent ( )
inlinevirtual

Accessor to the SimComponent.

Implements ParamUpdaterBase.

407{return _myComponent;}

References ParamUpdater< SC >::_myComponent.

◆ init()

template<class SC >
virtual void ParamUpdater< SC >::init ( )
inlinevirtual

Sets the pointer to the SimComponent.

It is deduced from the parameters' owner.

Implements ParamUpdaterBase.

390 {
391 _myComponent = dynamic_cast<SC*> ( (*_params.begin())->getOwner() );
392
393 for(PIT pit = ++_params.begin(); pit != _params.end(); pit++)
394 assert(_myComponent == (*pit)->getOwner());
395 }

References ParamUpdater< SC >::_myComponent, and ParamUpdaterBase::_params.

◆ setFuncPtr()

template<class SC >
void ParamUpdater< SC >::setFuncPtr ( bool(SC::*)(void)  updateFuncPtr)
inline

Sets the pointer to the updating function.

403 {
404 _myUpdaterFunction = updateFuncPtr;
405 }

References ParamUpdater< SC >::_myUpdaterFunction.

◆ update()

template<class SC >
virtual bool ParamUpdater< SC >::update ( unsigned int  generation)
inlinevirtual

Calls the SimComponent's updating function using its pointer.

Implements ParamUpdaterBase.

398 {
399 return ((( dynamic_cast<SC*> (_myComponent))->*_myUpdaterFunction) ());
400 }

References ParamUpdater< SC >::_myComponent, and ParamUpdater< SC >::_myUpdaterFunction.

Member Data Documentation

◆ _myComponent

◆ _myUpdaterFunction

template<class SC >
bool(SC::* ParamUpdater< SC >::_myUpdaterFunction) (void)
private

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

Generated for Nemo v2.3.56 by  doxygen 1.9.0 -- Nemo is hosted on  Download Nemo

Locations of visitors to this page
Catalogued on GSR