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

A class to compute and store the summary statistics associated with a SimComponent. More...

#include <stathandler.h>

+ Inheritance diagram for StatHandler< SH >:
+ Collaboration diagram for StatHandler< SH >:

Public Member Functions

 StatHandler ()
 
virtual ~StatHandler ()
 
virtual void clear ()
 Empties the _recorders list, they are destroyed in StatHandlerBase::reset(). More...
 
virtual StatRecorder< SH > * add (std::string Title, std::string Name, age_t AGE, unsigned int ARG1, unsigned int ARG2, double(SH::*getStatNoArg)(void), double(SH::*getStatOneArg)(unsigned int), double(SH::*getStatTwoArg)(unsigned int, unsigned int), void(SH::*setStat)(void))
 Adds a StatRecorder to the list, it is also added to the StatHandlerBase::_stats list. More...
 
- Public Member Functions inherited from StatHandlerBase
 StatHandlerBase ()
 
virtual ~StatHandlerBase ()
 
virtual void reset ()
 Empties the _stats list and calls clear() (defined in the derived class). More...
 
Metapopget_pop_ptr ()
 
void set_service (StatServices *srv)
 
StatServicesget_service ()
 
unsigned int getOccurrence ()
 
unsigned int getNumOccurrences ()
 
unsigned int getCurrentOccurrence ()
 
unsigned int getNbRecorders ()
 
std::list< StatRecBase * > & getStats ()
 
virtual void add (StatRecBase *rec)
 
virtual void init ()
 
virtual void update ()
 This function is left empty as the StatServices calls StatRecorder::setVal directly. More...
 
virtual bool setStatRecorders (std::string &token)=0
 
- Public Member Functions inherited from Handler
virtual void init ()=0
 Inits state. More...
 
virtual void update ()=0
 Updates the handler state. More...
 
virtual ~Handler ()
 

Protected Types

typedef std::list< StatRecorder< SH > * >::iterator REC_IT
 

Protected Attributes

std::list< StatRecorder< SH > * > _recorders
 The list of stat recorders. More...
 
- Protected Attributes inherited from StatHandlerBase
Metapop_pop
 Link to the current population, set through the link to the StatService. More...
 

Detailed Description

template<class SH>
class StatHandler< SH >

A class to compute and store the summary statistics associated with a SimComponent.

The template type must be the type of the class that declares the methods linked into the StatRecorder elements.

Member Typedef Documentation

◆ REC_IT

template<class SH >
typedef std::list<StatRecorder<SH>*>::iterator StatHandler< SH >::REC_IT
protected

Constructor & Destructor Documentation

◆ StatHandler()

template<class SH >
StatHandler< SH >::StatHandler ( )
inline
120{ }

◆ ~StatHandler()

template<class SH >
virtual StatHandler< SH >::~StatHandler ( )
inlinevirtual
122{ }

Member Function Documentation

◆ add()

template<class SH >
virtual StatRecorder< SH > * StatHandler< SH >::add ( std::string  Title,
std::string  Name,
age_t  AGE,
unsigned int  ARG1,
unsigned int  ARG2,
double(SH::*)(void)  getStatNoArg,
double(SH::*)(unsigned int getStatOneArg,
double(SH::*)(unsigned int, unsigned int getStatTwoArg,
void(SH::*)(void)  setStat 
)
inlinevirtual

Adds a StatRecorder to the list, it is also added to the StatHandlerBase::_stats list.

Two types of function variables are passed to this function. The "getter" and "setter". A "getter" returns a double value that will be stored in the StatRecorder structure. It may or may not take an argument. Only one getter should be passed to the stat recorder. The setter is used to set variables in the SH class which are then read by the getter. A setter and a getter may be given together but a setter alone will issue an error at runtime as no getter is present in the stat recorder.

Parameters
Titlethe stat title (as shown in the R frontend fro eg.)
Namethe stat name (headers in the stat output file)
AGEthe age class for which the stat will be recorded
ARG1the first argument to pass to the SH function
ARG2the second argument to pass to the SH function
getStatNoArgfunction ptr to a SH getter that takes no argument
getStatOneArgfunction ptr to a SH getter with a single integer argument
getStatTwoArgfunction ptr to a SH getter with two integer arguments
setStatfunction ptr to a SH setter
147 {
148 StatRecorder<SH>* new_rec = new StatRecorder<SH>();
149
150 new_rec->set(Title, Name, AGE, ARG1, ARG2,
151 getStatNoArg, getStatOneArg, getStatTwoArg, setStat);
152
153 new_rec->setHandler(dynamic_cast<SH*> (this));
154
155 _recorders.push_back(new_rec);
156
157 StatHandlerBase::add(new_rec);
158
159 return new_rec;
160 }
virtual void add(StatRecBase *rec)
Definition: stathandler.h:87
std::list< StatRecorder< SH > * > _recorders
The list of stat recorders.
Definition: stathandler.h:114
Stores the pointers to the StatHandler's stat functions.
Definition: statrecorder.h:93
void setHandler(S *theHandler)
Sets the pointer to the StatHandler that owns this recorder.
Definition: statrecorder.h:129
void set(std::string T, std::string N, age_t AGE, unsigned int ARG1, unsigned int ARG2, double(S::*getNoArg)(void), double(S::*getOneArg)(unsigned int), double(S::*getTwoArg)(unsigned int, unsigned int), void(S::*setStat)(void))
Sets the recorder attributes.
Definition: statrecorder.h:145

References StatHandler< SH >::_recorders, StatHandlerBase::add(), StatRecorder< S >::set(), and StatRecorder< S >::setHandler().

Referenced by TTQuantiSH::addAvgPerPatch(), TTQuantiSH::addCovarPerPatch(), TTQuantiSH::addEigen(), TTQuantiSH::addEigenPerPatch(), TTQuantiSH::addEigenValues(), TTQuantiSH::addEigenValuesPerPatch(), TTQuantiSH::addEigenVect1(), TTQuantiSH::addEigenVect1PerPatch(), LCE_SelectionSH::addMeanPerPatch(), TTQuantiSH::addQuanti(), TTQuantiSH::addSkewPerPatch(), TTBDMI_SH::addStats(), LCE_SelectionSH::addVarPerPatch(), TTQuantiSH::addVarPerPatch(), TTNeutralGenesSH::setCoaMatrixRecorders(), TTNeutralGenesSH::setDxyRecorders(), TTNeutralGenesSH::setFreqRecorders(), TTNeutralGenesSH::setFstat2Recorders(), TTNeutralGenesSH::setFstatRecorders(), TTNeutralGenesSH::setFstatWCRecorders(), TTNeutralGenesSH::setFstMatrixRecorders(), TTNeutralGenesSH::setNeiGeneticDistanceRecorders(), TTDeletMutBitstrSH::setStatRecorders(), TTNeutralGenesSH::setStatRecorders(), LCE_SelectionSH::setStatRecorders(), TTWolbachiaSH::setStatRecorders(), TTDeletMutBitstrSH::setStatsForDeletMutations(), and TTDeletMutBitstrSH::setViabStats().

◆ clear()

template<class SH >
virtual void StatHandler< SH >::clear ( )
inlinevirtual

Empties the _recorders list, they are destroyed in StatHandlerBase::reset().

Implements StatHandlerBase.

125{_recorders.clear();}

References StatHandler< SH >::_recorders.

Member Data Documentation

◆ _recorders

template<class SH >
std::list<StatRecorder<SH>*> StatHandler< SH >::_recorders
protected

The list of stat recorders.

Referenced by StatHandler< SH >::add(), and StatHandler< SH >::clear().


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