#include <stathandler.h>


Public Member Functions | |
| StatHandlerBase () | |
| virtual | ~StatHandlerBase () |
| virtual void | reset () |
| Empties the _stats list and calls clear() (defined in the derived class). | |
Accessors | |
| Metapop * | get_pop_ptr () |
| void | set_service (StatServices *srv) |
| StatServices * | get_service () |
| unsigned int | getOccurrence () |
| unsigned int | getNbRecorders () |
| unsigned int | get_nrows () |
| unsigned int | get_ncols () |
| std::list< StatRecBase * > & | getStats () |
| virtual void | add (StatRecBase *rec) |
Stat recorder interface | |
| unsigned int | getStatRecIndex (unsigned int i) |
| void | setAverage () |
| void | print_headers (std::ofstream &FH, unsigned int order) |
| void | print_value (std::ofstream &FH, unsigned int i, unsigned int j) |
| void | print_average (std::ofstream &FH, unsigned int i) |
Handler implementation | |
| virtual void | init () |
| Inits state. | |
| virtual void | update () |
| Updates the handler state. | |
StatHandler interface declaration | |
| virtual void | execute ()=0 |
| virtual bool | setStatRecorders (std::string &token)=0 |
| virtual void | clear ()=0 |
Protected Attributes | |
| Metapop * | _pop |
| Link to the current population, set through the link to the StatService. | |
Private Types | |
| typedef std::list< StatRecBase * > ::iterator | STAT_IT |
Private Attributes | |
| std::list< StatRecBase * > | _stats |
| Link to the StatRecorder list elements in the StatHandler derived class. | |
| unsigned int | _nrows |
| Structure of the stats table in the stat recorders. | |
| unsigned int | _ncols |
| StatServices * | _service |
| Link to the StatService. | |
| unsigned int | _GenerationOccurrence |
| Occurence of the stats recording as set by the user (see parameter "stat_log_time"). | |
| unsigned int | _current_replicate |
| Replicate state of this Handler. | |
| unsigned int | _current_generation |
| Generation state of this Handler. | |
| age_t | _current_age |
| Age state of this Handler. | |
This class stores the Handler state and the list of links to the StatRecBase. This list is duplicated in the StatHandler as a list of the StatRecorder templates. It allows the StatService to access the stat recorders without knowledge of the actual StatHandler and StatRecorder template type.
Definition at line 47 of file stathandler.h.
typedef std::list< StatRecBase* >::iterator StatHandlerBase::STAT_IT [private] |
Definition at line 65 of file stathandler.h.
| StatHandlerBase::StatHandlerBase | ( | ) | [inline] |
Definition at line 73 of file stathandler.h.
00074 : _nrows(0), _ncols(0), _service(0), _GenerationOccurrence(0), _current_replicate(0), 00075 _current_generation(0), _current_age(0) 00076 { }
| virtual StatHandlerBase::~StatHandlerBase | ( | ) | [inline, virtual] |
| virtual void StatHandlerBase::add | ( | StatRecBase * | rec | ) | [inline, virtual] |
| virtual void StatHandlerBase::clear | ( | ) | [pure virtual] |
| virtual void StatHandlerBase::execute | ( | ) | [pure virtual] |
| unsigned int StatHandlerBase::get_ncols | ( | ) | [inline] |
Definition at line 93 of file stathandler.h.
Referenced by StatHandler< TTDeletMutBitstrSH >::add().
00093 {return _ncols;}
| unsigned int StatHandlerBase::get_nrows | ( | ) | [inline] |
Definition at line 91 of file stathandler.h.
Referenced by StatHandler< TTDeletMutBitstrSH >::add().
00091 {return _nrows;}
| Metapop* StatHandlerBase::get_pop_ptr | ( | ) | [inline] |
Definition at line 81 of file stathandler.h.
Referenced by init().
00081 {return _service->get_pop_ptr();}
| StatServices* StatHandlerBase::get_service | ( | ) | [inline] |
| unsigned int StatHandlerBase::getNbRecorders | ( | ) | [inline] |
| unsigned int StatHandlerBase::getOccurrence | ( | ) | [inline] |
Definition at line 87 of file stathandler.h.
Referenced by StatHandler< SH >::execute(), and init().
00087 {return _service->getOccurrence();}
| unsigned int StatHandlerBase::getStatRecIndex | ( | unsigned int | i | ) |
Definition at line 90 of file stathandlerbase.cc.
00091 { 00092 STAT_IT el = _stats.begin(); 00093 unsigned int index = 0; 00094 00095 if(el != _stats.end()) { 00096 if(i > (*el)->getIndexSize()) 00097 error("StatHandlerBase::getStatRecIndex: index vector overflow !!\n"); 00098 //find the first statRecorder that has computed some stats 00099 for(; el != _stats.end(); el++) 00100 if((index = (*el)->getIndex(i)) != 0) break; 00101 } 00102 00103 return index; 00104 }
| std::list<StatRecBase*>& StatHandlerBase::getStats | ( | ) | [inline] |
| void StatHandlerBase::init | ( | ) | [virtual] |
Inits state.
Implements Handler.
Reimplemented in LCE_StatSH, TTDispersalSH, and TTNeutralGenesSH.
Definition at line 39 of file stathandlerbase.cc.
00040 { 00041 _pop = get_pop_ptr(); 00042 00043 unsigned int gen = SIMenv::MainSim->getGenerations(), log = getOccurrence(); 00044 00045 if(gen == 0) fatal("cannot initialize stat recorders, generation nbr is null\n"); 00046 00047 _nrows = ( log > gen || log == 0 ? 2 : gen/log); 00048 00049 if(log != 1) _nrows++; //automatically save first generation 00050 00051 if(SIMenv::MainSim->getReplicates() == 0) fatal("cannot initialize stat recorders, replicate nbr is null\n"); 00052 _ncols = SIMenv::MainSim->getReplicates(); 00053 }
| void StatHandlerBase::print_average | ( | std::ofstream & | FH, | |
| unsigned int | i | |||
| ) |
Definition at line 154 of file stathandlerbase.cc.
00155 { 00156 STAT_IT IT = _stats.begin(); 00157 00158 while(IT != _stats.end()) { 00159 FH<<"\t"; 00160 FH.width(12); 00161 00162 if((*IT)->getOrdering() == FLAT) 00163 FH<<(*IT)->getAverage(i); 00164 else if((*IT)->getOrdering() == GEN) 00165 FH<<(*IT)->getVal(i); 00166 IT++; 00167 } 00168 }
| void StatHandlerBase::print_headers | ( | std::ofstream & | FH, | |
| unsigned int | order | |||
| ) |
Definition at line 121 of file stathandlerbase.cc.
00122 { 00123 STAT_IT IT = _stats.begin(); 00124 00125 while(IT != _stats.end()) { 00126 if( (*IT)->getOrdering() & order) { 00127 FH<<"\t"; 00128 FH.width(12); 00129 FH<<(*IT)->getName(); 00130 } 00131 IT++; 00132 00133 } 00134 }
| void StatHandlerBase::print_value | ( | std::ofstream & | FH, | |
| unsigned int | i, | |||
| unsigned int | j | |||
| ) |
| void StatHandlerBase::reset | ( | ) | [virtual] |
Empties the _stats list and calls clear() (defined in the derived class).
Definition at line 72 of file stathandlerbase.cc.
00073 { 00074 STAT_IT IT = _stats.begin(); 00075 00076 while(IT != _stats.end()) { 00077 delete (*IT); 00078 IT++; 00079 } 00080 00081 _stats.clear(); 00082 00083 _nrows = _ncols = 0; 00084 00085 clear(); 00086 }
| void StatHandlerBase::set_service | ( | StatServices * | srv | ) | [inline] |
Definition at line 83 of file stathandler.h.
Referenced by StatServices::attach().
00083 {_service = srv;}
| void StatHandlerBase::setAverage | ( | ) |
| virtual bool StatHandlerBase::setStatRecorders | ( | std::string & | token | ) | [pure virtual] |
Implemented in MPStatHandler, LCE_StatSH, TTDeletMutBitstrSH, TTDispersalSH, and TTNeutralGenesSH.
| void StatHandlerBase::update | ( | ) | [virtual] |
Updates the handler state.
Implements Handler.
Definition at line 57 of file stathandlerbase.cc.
00058 { 00059 _current_replicate = _pop->getCurrentReplicate(); 00060 00061 _current_generation = _pop->getCurrentGeneration(); 00062 00063 _current_age = _pop->getCurrentAge(); 00064 00065 //if( !(_current_generation % _GenerationOccurrence) ) 00066 00067 execute(); 00068 }
age_t StatHandlerBase::_current_age [private] |
unsigned int StatHandlerBase::_current_generation [private] |
Generation state of this Handler.
Definition at line 61 of file stathandler.h.
Referenced by update().
unsigned int StatHandlerBase::_current_replicate [private] |
Replicate state of this Handler.
Definition at line 59 of file stathandler.h.
Referenced by update().
unsigned int StatHandlerBase::_GenerationOccurrence [private] |
Occurence of the stats recording as set by the user (see parameter "stat_log_time").
Definition at line 57 of file stathandler.h.
unsigned int StatHandlerBase::_ncols [private] |
unsigned int StatHandlerBase::_nrows [private] |
Structure of the stats table in the stat recorders.
Definition at line 53 of file stathandler.h.
Referenced by get_nrows(), init(), and reset().
Metapop* StatHandlerBase::_pop [protected] |
Link to the current population, set through the link to the StatService.
Definition at line 69 of file stathandler.h.
Referenced by TTNeutralGenesSH::allocateTables(), StatHandler< SH >::execute(), LCE_StatSH::get_isAlive(), TTWolbachiaSH::getMeanFemaleInfection_perPatch(), TTWolbachiaSH::getMeanMaleInfection_perPatch(), TTWolbachiaSH::getMeanOffsprgFemaleInfection_perPatch(), TTWolbachiaSH::getMeanOffsprgInfection(), TTWolbachiaSH::getMeanOffsprgMaleInfection_perPatch(), LCE_SelectionSH::getPatchFitness(), TTDispersalSH::init(), init(), TTNeutralGenesSH::setCoaMatrixRecorders(), TTNeutralGenesSH::setFstMatrixRecorders(), TTWolbachiaSH::setInfectionStats(), TTNeutralGenesSH::setNeiGeneticDistanceRecorders(), LCE_SelectionSH::setStatRecorders(), and update().
StatServices* StatHandlerBase::_service [private] |
Link to the StatService.
Definition at line 55 of file stathandler.h.
Referenced by get_pop_ptr(), get_service(), getOccurrence(), and set_service().
std::list<StatRecBase*> StatHandlerBase::_stats [private] |
Link to the StatRecorder list elements in the StatHandler derived class.
Definition at line 51 of file stathandler.h.
Referenced by add(), getNbRecorders(), getStatRecIndex(), getStats(), print_average(), print_headers(), print_value(), reset(), and setAverage().
1.5.8 -- Nemo is hosted by