Nemo  2.2.0
Public Member Functions | Private Attributes
LCE_StatServiceNotifier Class Reference

Initiates the StatServices' parameters (log time) when registering, calls StatServices::notify() when executing. More...

#include <servicenotifiers.h>

+ Inheritance diagram for LCE_StatServiceNotifier:
+ Collaboration diagram for LCE_StatServiceNotifier:

List of all members.

Public Member Functions

 LCE_StatServiceNotifier ()
virtual ~LCE_StatServiceNotifier ()
virtual bool setParameters ()
 Default interface needed to initialize the component's variables from its input parameters value.
virtual void execute ()
 Execute the event on the pop.
virtual LCE_StatServiceNotifierclone ()
 Cloning interface.
virtual void loadFileServices (FileServices *loader)
 Loads the component's FileHandler onto the FileServices.
virtual void loadStatServices (StatServices *loader)
 Loads the component's StatHandler onto the StatServices.
virtual age_t removeAgeClass ()
 Removes the returned age-class flag(s) from the current Metapop age-class flags.
virtual age_t addAgeClass ()
 Adds the returned age-class flag(s) to the current Metapop age-class flags.
virtual age_t requiredAgeClass ()
 Specifies what age-classes are required by the LCE to execute.

Private Attributes

StatServices_service
unsigned int _occurrence
string _arg
string _dir
LCE_StatFH _fileHandler
LCE_StatSH _statHandler

Detailed Description

Initiates the StatServices' parameters (log time) when registering, calls StatServices::notify() when executing.

Registers the file handler used to save the stats to the '.txt' and '_bygen.txt' files.

Definition at line 147 of file servicenotifiers.h.


Constructor & Destructor Documentation

LCE_StatServiceNotifier::LCE_StatServiceNotifier ( )

Definition at line 79 of file servicenotifiers.cc.

References SimComponent::add_parameter(), INT, and STR.

Referenced by clone().

: LifeCycleEvent("save_stats",""), _service(0)
{
  add_parameter("stat",STR,true,false,0,0);
  add_parameter("stat_log_time",INT,true,false,0,0);
  add_parameter("stat_dir",STR,false,false,0,0);
}
virtual LCE_StatServiceNotifier::~LCE_StatServiceNotifier ( ) [inline, virtual]

Definition at line 163 of file servicenotifiers.h.

{ }

Member Function Documentation

virtual age_t LCE_StatServiceNotifier::addAgeClass ( ) [inline, virtual]

Adds the returned age-class flag(s) to the current Metapop age-class flags.

Implements LifeCycleEvent.

Definition at line 174 of file servicenotifiers.h.

{return 0;}
virtual LCE_StatServiceNotifier* LCE_StatServiceNotifier::clone ( ) [inline, virtual]

Cloning interface.

Implements LifeCycleEvent.

Definition at line 168 of file servicenotifiers.h.

References LCE_StatServiceNotifier().

{return new LCE_StatServiceNotifier();}
void LCE_StatServiceNotifier::execute ( ) [virtual]

Execute the event on the pop.

Implements LifeCycleEvent.

Definition at line 120 of file servicenotifiers.cc.

References _service, StatServices::getOccurrence(), message(), and StatServices::notify().

{
#ifdef _DEBUG_
  message("LCE_StatServiceNotifier::execute (occurrence %i)\n",_service->getOccurrence());
#endif
  _service->notify();
}
virtual void LCE_StatServiceNotifier::loadFileServices ( FileServices loader) [inline, virtual]

Loads the component's FileHandler onto the FileServices.

Parameters:
loaderthe file service

Implements SimComponent.

Definition at line 171 of file servicenotifiers.h.

References _fileHandler, and FileServices::attach().

{loader->attach(&_fileHandler);}
void LCE_StatServiceNotifier::loadStatServices ( StatServices loader) [virtual]

Loads the component's StatHandler onto the StatServices.

Parameters:
loaderthe stat service

Implements SimComponent.

Definition at line 107 of file servicenotifiers.cc.

References _arg, _fileHandler, _occurrence, _service, _statHandler, StatServices::attach(), error(), SimComponent::get_paramset(), StatServices::set(), and LCE_StatFH::set_statService().

{
  _service = loader;
  _fileHandler.set_statService(loader);
  if(!get_paramset()->isSet())
    error("LCE_StatServiceNotifier::loadStatServices:stat params are not set!\n");

  _service->set(_arg, _occurrence);
  loader->attach(&_statHandler);
}
virtual age_t LCE_StatServiceNotifier::removeAgeClass ( ) [inline, virtual]

Removes the returned age-class flag(s) from the current Metapop age-class flags.

Implements LifeCycleEvent.

Definition at line 173 of file servicenotifiers.h.

{return 0;}
virtual age_t LCE_StatServiceNotifier::requiredAgeClass ( ) [inline, virtual]

Specifies what age-classes are required by the LCE to execute.

Implements LifeCycleEvent.

Definition at line 175 of file servicenotifiers.h.

{return 0;}
bool LCE_StatServiceNotifier::setParameters ( ) [virtual]

Default interface needed to initialize the component's variables from its input parameters value.

Formerly called 'init'.

Implements SimComponent.

Definition at line 89 of file servicenotifiers.cc.

References _arg, _dir, _fileHandler, _occurrence, SimComponent::_paramSet, LifeCycleEvent::get_rank(), ParamSet::getArg(), SIMenv::getGenerations(), ParamSet::getValue(), and FileHandler::set().

{  
  _arg = _paramSet->getArg("stat");
  _occurrence = (unsigned int)_paramSet->getValue("stat_log_time");
  
  if(_occurrence > SIMenv::getGenerations()) _occurrence = SIMenv::getGenerations();
  
  _dir = _paramSet->getArg("stat_dir");
  
  _fileHandler.set(true, false, 1,
                   SIMenv::getGenerations(),
                   this->get_rank(),
                   _dir);
  return true;
}

Member Data Documentation

Definition at line 154 of file servicenotifiers.h.

Referenced by loadStatServices(), and setParameters().

Definition at line 154 of file servicenotifiers.h.

Referenced by setParameters().

Definition at line 156 of file servicenotifiers.h.

Referenced by loadFileServices(), loadStatServices(), and setParameters().

unsigned int LCE_StatServiceNotifier::_occurrence [private]

Definition at line 152 of file servicenotifiers.h.

Referenced by loadStatServices(), and setParameters().

Definition at line 150 of file servicenotifiers.h.

Referenced by execute(), and loadStatServices().

Definition at line 157 of file servicenotifiers.h.

Referenced by loadStatServices().


The documentation for this class was generated from the following files:

Generated for Nemo v2.2.0 by  doxygen 1.7.5.1 -- Nemo is hosted by  SourceForge.net Logo