|
Nemo
2.2.0
|
The Service class used to manage the StatHandler objects. More...
#include <statservices.h>
Inheritance diagram for StatServices:
Collaboration diagram for StatServices: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 |
The Service class used to manage the StatHandler objects.
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] |
Definition at line 60 of file statservices.h.
: _popPtr(0), _occurrence(0) { }
| virtual StatServices::~StatServices | ( | ) | [inline, virtual] |
Definition at line 62 of file statservices.h.
{ }
| 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.
References _children, and StatHandlerBase::set_service().
Referenced by TProtoWolbachia::loadStatServices(), LCE_StatServiceNotifier::loadStatServices(), TProtoNeutralGenes::loadStatServices(), TProtoDeletMutations_bitstring::loadStatServices(), Metapop::loadStatServices(), and LCE_Selection_base::loadStatServices().
{
Service::attach(SH);
_children.push_back(SH);
SH->set_service(this);
}
| Metapop* StatServices::get_pop_ptr | ( | ) | [inline] |
Definition at line 66 of file statservices.h.
References _popPtr.
Referenced by StatHandlerBase::get_pop_ptr().
{return _popPtr;}
| list< StatRecBase * > StatServices::getAllStats | ( | ) |
Definition at line 202 of file statservices.cc.
References _children.
Referenced by SimRunner::get_allRegisteredStats().
| stat_it StatServices::getFirst | ( | ) | [inline] |
| stat_it StatServices::getLast | ( | ) | [inline] |
| unsigned int StatServices::getOccurrence | ( | ) | [inline] |
Definition at line 72 of file statservices.h.
References _occurrence.
Referenced by LCE_StatServiceNotifier::execute(), LCE_StatFH::FHwrite(), StatHandlerBase::getOccurrence(), and LCE_StatFH::PrintStat_byGen().
{return _occurrence;}
| std::string& StatServices::getStatArg | ( | ) | [inline] |
| unsigned int StatServices::getStatRecIndex | ( | unsigned int | i | ) |
Definition at line 189 of file statservices.cc.
References _children.
Referenced by LCE_StatFH::FHwrite(), and LCE_StatFH::PrintStat_byGen().
| bool StatServices::init | ( | ) | [virtual] |
Inits internals.
Implements Service.
Definition at line 44 of file statservices.cc.
References _children, _statArg, and error().
Referenced by SimRunner::init_components().
{
list< StatHandlerBase* >::iterator HIT;
HIT = _children.begin();
//first init the stat handlers -> will define the dims of the stat tables
while(HIT != _children.end()) {
(*HIT)->init();
HIT++;
}
istringstream stats(_statArg);
std::string arg;
std::list<std::string> args;
//extract the stat options from the string read in the init file
while(stats>>arg) args.push_back(arg);
std::list<std::string>::iterator token = args.begin();
bool is_set = false;
while(token != args.end()) {
HIT = _children.begin();
is_set = false;
while(HIT != _children.end() && !is_set) {
is_set |= (*HIT)->setStatRecorders( (*token) );
HIT++;
}
if(!is_set) {
error("the string \"%s\" is not a valid stat option\n",(*token).c_str());
return false;
}
token++;
}
return true;
}
| 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.
References SimComponent::loadStatServices().
Referenced by SimRunner::register_component().
{
sc->loadStatServices(this);
}
| void StatServices::notify | ( | ) | [virtual] |
Notifies all observers to update their state.
Reimplemented from Service.
Definition at line 108 of file statservices.cc.
References _occurrence, SIMenv::MainSim, and message().
Referenced by LCE_StatServiceNotifier::execute().
{
#ifdef _DEBUG_
message("StatServices::notify (%i): ",( !(SIMenv::MainSim->getCurrentGeneration() % _occurrence)
|| SIMenv::MainSim->getCurrentGeneration() == 1 ));
fflush(stdout);
#endif
//we automatically save first and last generations
if( !(SIMenv::MainSim->getCurrentGeneration() % _occurrence) || SIMenv::MainSim->getCurrentGeneration() == 1 )
Service::notify();
#ifdef _DEBUG_
message("\n");
#endif
}
| void StatServices::printStatAverage | ( | std::ofstream & | FH, |
| unsigned int | i | ||
| ) |
Definition at line 165 of file statservices.cc.
References _children.
Referenced by LCE_StatFH::PrintStat_byGen().
| void StatServices::printStatHeaders | ( | std::ofstream & | FH, |
| unsigned int | order | ||
| ) |
Definition at line 141 of file statservices.cc.
References _children.
Referenced by LCE_StatFH::FHwrite(), and LCE_StatFH::PrintStat_byGen().
| 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.
References _children.
Referenced by LCE_StatFH::FHwrite().
| void StatServices::reset | ( | ) | [virtual] |
clear the list of StatHandler
Reimplemented from Service.
Definition at line 125 of file statservices.cc.
References _children.
Referenced by SimRunner::reset_services().
{
Service::reset();
list< StatHandlerBase* >::iterator HIT = _children.begin();
while(HIT != _children.end()) {
(*HIT)->reset();
HIT++;
}
_children.clear();
}
| void StatServices::set | ( | std::string & | str, |
| unsigned int | occ | ||
| ) | [inline] |
Definition at line 70 of file statservices.h.
References _occurrence, and _statArg.
Referenced by LCE_StatServiceNotifier::loadStatServices().
{_statArg = str; _occurrence = occ;}
| void StatServices::set_pop_ptr | ( | Metapop * | pop | ) | [inline] |
Definition at line 68 of file statservices.h.
References _popPtr.
Referenced by SimRunner::init_components().
{_popPtr=pop;}
| void StatServices::setOcccurrence | ( | unsigned int | value | ) | [inline] |
| void StatServices::setStatAverage | ( | ) |
Definition at line 177 of file statservices.cc.
References _children.
Referenced by LCE_StatFH::PrintStat_byGen().
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] |
Definition at line 48 of file statservices.h.
Referenced by get_pop_ptr(), and set_pop_ptr().
std::string StatServices::_statArg [private] |
Definition at line 52 of file statservices.h.
Referenced by getStatArg(), init(), and set().
1.7.5.1 -- Nemo is hosted by