Nemo  2.4.1
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 update ()
 
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 ~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
379  : _myComponent(0)
380  {
381  _myUpdaterFunction = updateFuncPtr;
382  }
bool(SC::* _myUpdaterFunction)(void)
Definition: param.h:374
SC * _myComponent
Definition: param.h:375

◆ ParamUpdater() [2/2]

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

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

◆ ~ParamUpdater()

template<class SC >
virtual ParamUpdater< SC >::~ParamUpdater ( )
inlinevirtual
392  {
393  for(PIT pit = _params.begin(); pit != _params.end(); pit++)
394  if((*pit)->getUpdater() == this) (*pit)->setUpdater(0);
395  }
list< Param * >::iterator PIT
Definition: param.h:332

Member Function Documentation

◆ getComponent()

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

Accessor to the SimComponent.

Implements ParamUpdaterBase.

416 {return _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.

399  {
400  _myComponent = dynamic_cast<SC*> ( (*_params.begin())->getOwner() );
401 
402  for(PIT pit = ++_params.begin(); pit != _params.end(); pit++)
403  assert(_myComponent == (*pit)->getOwner());
404  }

◆ setFuncPtr()

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

Sets the pointer to the updating function.

412  {
413  _myUpdaterFunction = updateFuncPtr;
414  }

◆ update()

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

Calls the SimComponent's updating function using its pointer.

Implements ParamUpdaterBase.

407  {
408  return ((( dynamic_cast<SC*> (_myComponent))->*_myUpdaterFunction) ());
409  }

Member Data Documentation

◆ _myComponent

template<class SC >
SC* ParamUpdater< SC >::_myComponent
private

◆ _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.4.1 by  doxygen 1.9.1

Catalogued on GSR