ParamUpdater< SC > Class Template Reference

Implementation of the ParamUpdaterBase interface. More...

#include <param.h>

Inheritance diagram for ParamUpdater< SC >:

Inheritance graph
[legend]
Collaboration diagram for ParamUpdater< SC >:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 ParamUpdater (bool(SC::*updateFuncPtr)(void))
 ParamUpdater (const ParamUpdater< SC > &PU)
virtual ~ParamUpdater ()
virtual void init ()
 Sets the pointer to the SimComponent.
virtual bool update (unsigned int generation)
 Calls the SimComponent's updating function using its pointer.
void setFuncPtr (bool(SC::*updateFuncPtr)(void))
 Sets the pointer to the updating function.
virtual SC * getComponent ()
 Accessor to the SimCimponent.

Private Attributes

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


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's 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.

Definition at line 323 of file param.h.


Constructor & Destructor Documentation

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

Definition at line 330 of file param.h.

00331   {
00332     _myUpdaterFunction = updateFuncPtr;
00333   }

template<class SC>
ParamUpdater< SC >::ParamUpdater ( const ParamUpdater< SC > &  PU  )  [inline]

Definition at line 335 of file param.h.

00336   {
00337     _params.assign(PU._params.begin(), PU._params.end());
00338     _myUpdaterFunction = PU._myUpdaterFunction;
00339     _myComponent = PU._myComponent;
00340   }

template<class SC>
virtual ParamUpdater< SC >::~ParamUpdater (  )  [inline, virtual]

Definition at line 342 of file param.h.

00343   {
00344     for(PIT pit = _params.begin(); pit != _params.end(); pit++)
00345       if((*pit)->getUpdater() == this) (*pit)->setUpdater(0);
00346   }


Member Function Documentation

template<class SC>
virtual SC* ParamUpdater< SC >::getComponent (  )  [inline, virtual]

Accessor to the SimCimponent.

Implements ParamUpdaterBase.

Definition at line 367 of file param.h.

00367 {return _myComponent;}

template<class SC>
virtual void ParamUpdater< SC >::init (  )  [inline, virtual]

Sets the pointer to the SimComponent.

It is deduced from the parameters' owner.

Implements ParamUpdaterBase.

Definition at line 349 of file param.h.

00350   {
00351     _myComponent = dynamic_cast<SC*> ( (*_params.begin())->getOwner() );
00352     
00353     for(PIT pit = ++_params.begin(); pit != _params.end(); pit++)
00354       assert(_myComponent == (*pit)->getOwner());
00355   }

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

Sets the pointer to the updating function.

Definition at line 362 of file param.h.

00363   {
00364     _myUpdaterFunction = updateFuncPtr;
00365   }

template<class SC>
virtual bool ParamUpdater< SC >::update ( unsigned int  generation  )  [inline, virtual]

Calls the SimComponent's updating function using its pointer.

Implements ParamUpdaterBase.

Definition at line 357 of file param.h.

00358   {        
00359     return ((( dynamic_cast<SC*> (_myComponent))->*_myUpdaterFunction) ());
00360   }


Member Data Documentation

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

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.1.2 by  doxygen 1.5.8 -- Nemo is hosted by  SourceForge.net Logo