#include <statservices.h>


Public Types | |
| typedef std::list < StatHandlerBase * > ::const_iterator | stat_it |
Public Member Functions | |
| StatServices () | |
| virtual | ~StatServices () |
| virtual bool | init () |
| Inits internals. | |
| Metapop * | get_pop_ptr () |
| void | set_pop_ptr (Metapop *pop) |
| void | set (std::string &str, unsigned int occ) |
| unsigned int | getOccurrence () |
| void | setOcccurrence (unsigned int value) |
| std::string & | getStatArg () |
| void | printStatHeaders (std::ofstream &FH, unsigned int order) |
| void | printStatValue (std::ofstream &FH, unsigned int i, unsigned int j) |
| Prints the stat values to the '.txt' output file. | |
| void | printStatAverage (std::ofstream &FH, unsigned int i) |
| void | setStatAverage () |
| std::list< StatRecBase * > | getAllStats () |
| stat_it | getFirst () |
| stat_it | getLast () |
| unsigned int | getStatRecIndex (unsigned int i) |
| virtual void | notify () |
| Notifies all observers to update their state. | |
| virtual void | load (SimComponent *sc) |
| tell the SimComponent to load its stat handlers | |
| virtual void | attach (StatHandlerBase *SH) |
| attach the StatHandler to the current list (_children) of the StatServices | |
| virtual void | reset () |
| clear the list of StatHandler | |
Private Attributes | |
| Metapop * | _popPtr |
| std::list< StatHandlerBase * > | _children |
| std::string | _statArg |
| unsigned int | _occurrence |
Definition at line 44 of file statservices.h.
| typedef std::list< StatHandlerBase* >::const_iterator StatServices::stat_it |
Definition at line 58 of file statservices.h.
| StatServices::StatServices | ( | ) | [inline] |
| virtual StatServices::~StatServices | ( | ) | [inline, virtual] |
| void StatServices::attach | ( | StatHandlerBase * | SH | ) | [virtual] |
attach the StatHandler to the current list (_children) of the StatServices
| SH | the StatHandler |
Definition at line 99 of file statservices.cc.
Referenced by TProtoWolbachia::loadStatServices(), TProtoNeutralGenes::loadStatServices(), TProtoDeletMutations_bitstring::loadStatServices(), LCE_StatServiceNotifier::loadStatServices(), Metapop::loadStatServices(), and LCE_Selection_base::loadStatServices().
00100 { 00101 Service::attach(SH); 00102 _children.push_back(SH); 00103 SH->set_service(this); 00104 }
| Metapop* StatServices::get_pop_ptr | ( | ) | [inline] |
Definition at line 66 of file statservices.h.
Referenced by StatHandlerBase::get_pop_ptr().
00066 {return _popPtr;}
| list< StatRecBase * > StatServices::getAllStats | ( | ) |
Definition at line 202 of file statservices.cc.
Referenced by SimRunner::get_allRegisteredStats().
00203 { 00204 list< StatHandlerBase* >::iterator HIT = _children.begin(); 00205 00206 list<StatRecBase*> allStats, stats; 00207 00208 while(HIT != _children.end()) { 00209 stats = (*HIT)->getStats(); 00210 allStats.insert(allStats.end(), stats.begin(), stats.end()); 00211 HIT++; 00212 } 00213 00214 return allStats; 00215 }
| stat_it StatServices::getFirst | ( | ) | [inline] |
| stat_it StatServices::getLast | ( | ) | [inline] |
| unsigned int StatServices::getOccurrence | ( | ) | [inline] |
Definition at line 72 of file statservices.h.
Referenced by LCE_StatServiceNotifier::execute(), LCE_StatFH::FHwrite(), StatHandlerBase::getOccurrence(), and LCE_StatFH::PrintStat_byGen().
00072 {return _occurrence;}
| std::string& StatServices::getStatArg | ( | ) | [inline] |
| unsigned int StatServices::getStatRecIndex | ( | unsigned int | i | ) |
Definition at line 189 of file statservices.cc.
Referenced by LCE_StatFH::FHwrite(), and LCE_StatFH::PrintStat_byGen().
00190 { 00191 list< StatHandlerBase* >::iterator el; 00192 unsigned int index = 0; 00193 //find the first statHandler that has registered statRecorders and has computed some stats: 00194 for(el = _children.begin(); el != _children.end(); el++) 00195 if((index = (*el)->getStatRecIndex(i)) != 0) break; 00196 00197 return index; 00198 }
| bool StatServices::init | ( | ) | [virtual] |
Inits internals.
Implements Service.
Definition at line 44 of file statservices.cc.
Referenced by SimRunner::init_components().
00045 { 00046 list< StatHandlerBase* >::iterator HIT; 00047 00048 HIT = _children.begin(); 00049 00050 //first init the stat handlers -> will define the dims of the stat tables 00051 while(HIT != _children.end()) { 00052 (*HIT)->init(); 00053 HIT++; 00054 } 00055 00056 istringstream stats(_statArg); 00057 std::string arg; 00058 std::list<std::string> args; 00059 00060 //extract the stat options from the string read in the init file 00061 while(stats>>arg) args.push_back(arg); 00062 00063 std::list<std::string>::iterator token = args.begin(); 00064 00065 bool is_set = false; 00066 00067 while(token != args.end()) { 00068 00069 HIT = _children.begin(); 00070 00071 is_set = false; 00072 00073 while(HIT != _children.end() && !is_set) { 00074 is_set |= (*HIT)->setStatRecorders( (*token) ); 00075 HIT++; 00076 } 00077 00078 if(!is_set) { 00079 error("the string \"%s\" is not a valid stat option\n",(*token).c_str()); 00080 return false; 00081 } 00082 00083 token++; 00084 } 00085 00086 00087 return true; 00088 }
| void StatServices::load | ( | SimComponent * | sc | ) | [virtual] |
tell the SimComponent to load its stat handlers
| sc | the SimComponent |
Implements Service.
Definition at line 92 of file statservices.cc.
Referenced by SimRunner::register_component().
00093 { 00094 sc->loadStatServices(this); 00095 }
| void StatServices::notify | ( | ) | [virtual] |
Notifies all observers to update their state.
Reimplemented from Service.
Definition at line 108 of file statservices.cc.
Referenced by LCE_StatServiceNotifier::execute().
00109 { 00110 #ifdef _DEBUG_ 00111 message("StatServices::notify (%i): ",( !(SIMenv::MainSim->getCurrentGeneration() % _occurrence) 00112 || SIMenv::MainSim->getCurrentGeneration() == 1 )); 00113 fflush(stdout); 00114 #endif 00115 //we automatically save first and last generations 00116 if( !(SIMenv::MainSim->getCurrentGeneration() % _occurrence) || SIMenv::MainSim->getCurrentGeneration() == 1 ) 00117 Service::notify(); 00118 #ifdef _DEBUG_ 00119 message("\n"); 00120 #endif 00121 }
| void StatServices::printStatAverage | ( | std::ofstream & | FH, | |
| unsigned int | i | |||
| ) |
Definition at line 165 of file statservices.cc.
Referenced by LCE_StatFH::PrintStat_byGen().
00166 { 00167 list< StatHandlerBase* >::iterator HIT = _children.begin(); 00168 00169 while(HIT != _children.end()) { 00170 (*HIT)->print_average(FH,i); 00171 HIT++; 00172 } 00173 }
| void StatServices::printStatHeaders | ( | std::ofstream & | FH, | |
| unsigned int | order | |||
| ) |
Definition at line 141 of file statservices.cc.
Referenced by LCE_StatFH::FHwrite(), and LCE_StatFH::PrintStat_byGen().
00142 { 00143 list< StatHandlerBase* >::iterator HIT = _children.begin(); 00144 00145 while(HIT != _children.end()) { 00146 (*HIT)->print_headers(FH,order); 00147 HIT++; 00148 } 00149 }
| void StatServices::printStatValue | ( | std::ofstream & | FH, | |
| unsigned int | i, | |||
| unsigned int | j | |||
| ) |
Prints the stat values to the '.txt' output file.
| FH | the file output stream | |
| i | the generation index in the stat tables (row) | |
| j | the replicate indes in the stat tables (column) |
Definition at line 153 of file statservices.cc.
Referenced by LCE_StatFH::FHwrite().
00154 { 00155 list< StatHandlerBase* >::iterator HIT = _children.begin(); 00156 00157 while(HIT != _children.end()) { 00158 (*HIT)->print_value(FH,i,j); 00159 HIT++; 00160 } 00161 }
| void StatServices::reset | ( | ) | [virtual] |
clear the list of StatHandler
Reimplemented from Service.
Definition at line 125 of file statservices.cc.
Referenced by SimRunner::reset_services().
00126 { 00127 Service::reset(); 00128 00129 list< StatHandlerBase* >::iterator HIT = _children.begin(); 00130 00131 while(HIT != _children.end()) { 00132 (*HIT)->reset(); 00133 HIT++; 00134 } 00135 00136 _children.clear(); 00137 }
| void StatServices::set | ( | std::string & | str, | |
| unsigned int | occ | |||
| ) | [inline] |
Definition at line 70 of file statservices.h.
Referenced by LCE_StatServiceNotifier::loadStatServices().
00070 {_statArg = str; _occurrence = occ;}
| void StatServices::set_pop_ptr | ( | Metapop * | pop | ) | [inline] |
Definition at line 68 of file statservices.h.
Referenced by SimRunner::init_components().
00068 {_popPtr=pop;}
| void StatServices::setOcccurrence | ( | unsigned int | value | ) | [inline] |
| void StatServices::setStatAverage | ( | ) |
Definition at line 177 of file statservices.cc.
Referenced by LCE_StatFH::PrintStat_byGen().
00178 { 00179 list< StatHandlerBase* >::iterator HIT = _children.begin(); 00180 00181 while(HIT != _children.end()) { 00182 (*HIT)->setAverage(); 00183 HIT++; 00184 } 00185 }
std::list< StatHandlerBase* > StatServices::_children [private] |
Definition at line 50 of file statservices.h.
Referenced by attach(), getAllStats(), getFirst(), getLast(), getStatRecIndex(), init(), printStatAverage(), printStatHeaders(), printStatValue(), reset(), and setStatAverage().
unsigned int StatServices::_occurrence [private] |
Definition at line 54 of file statservices.h.
Referenced by getOccurrence(), notify(), set(), and setOcccurrence().
Metapop* StatServices::_popPtr [private] |
std::string StatServices::_statArg [private] |
1.5.8 -- Nemo is hosted by