LifeCycleEvent Class Reference

Base class of the Life Cycle Events, declares the LCE interface. More...

#include <lifecycleevent.h>

Inheritance diagram for LifeCycleEvent:

Inheritance graph
[legend]
Collaboration diagram for LifeCycleEvent:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 LifeCycleEvent (const char *name, const char *trait_link)
 Cstor.
virtual ~LifeCycleEvent ()
virtual void init (Metapop *popPtr)
 Sets the pointer to the current Metapop and the trait link if applicable.
virtual bool attach_trait (string trait)
virtual void set_paramset (std::string name, bool required, SimComponent *owner)
 Sets a new ParamSet and name it.
virtual void set_event_name (std::string &name)
 Set the name of the event (name of the ParamSet) and add the corresponding parameter to the set.
virtual void set_event_name (const char *name)
virtual string & get_event_name ()
 Accessor to the LCE's name.
virtual int get_rank ()
 Accessor to the LCE rank in the life cycle.
virtual void set_pop_ptr (Metapop *popPtr)
 Accessors for the population pointer.
virtual Metapopget_pop_ptr ()
LCE interface
virtual void execute ()=0
 Execute the event on the pop.
virtual LifeCycleEventclone ()=0
 Cloning interface.
virtual age_t removeAgeClass ()=0
 Removes the returned age-class flag(s) from the current Metapop age-class flags.
virtual age_t addAgeClass ()=0
 Adds the returned age-class flag(s) to the current Metapop age-class flags.
virtual age_t requiredAgeClass ()=0
 Specifies what age-classes are required by the LCE to execute.

Protected Attributes

std::string _event_name
 The param name to be read in the init file.
Metapop_popPtr
 The ptr to the current Metapop.
std::string _LCELinkedTraitType
 The name of the linked trait.
int _LCELinkedTraitIndex
 The index in the individual's trait table of the linked trait.


Detailed Description

Base class of the Life Cycle Events, declares the LCE interface.

A Life Cycle Event (LCE) is a population operator that modifies the state of the population at each iteration of the life cycle. It declares the execute() method that is called during the life cycle loop (Metapop::Cycle()). No interface is given to manage the periodicity of the event, the execute() method is called at each iteration. The periodicity check must thus be implemented in the derived class, within the exectute() method.

Each LCE has a link to the current Metapop instance and a link to a particular trait which are set by LifeCycleEvent::init() at simulation initialization time (called by Metapop::setLifeCycle() through Metapop::init() and SimRunner::setup()). The linked trait can be specified in the constructor by its type identifier (a character string literal) or later, at runtime. In the first case, the trait's index will be set by a call to IndFactory::getTraitIndex() at initialization (see LifeCycleEvent::init()). In the later case, the trait to link with must be specified at initialization time and LifeCycleEvent::init() must be overloaded. The linked trait type (or name) can then be specified by the user in the init file and set in the derived class init() method before explicitly calling LifeCycleEvent::init() which will set the linked trait's index (see LCE_Breed_Selection::init() for an example). That index is then used to easily access the given trait through the Individual interface (see Individual::getTrait()).

Each LCE also has a name by which it is called from the user's defined parameter file to specify when in the life cycle that particular event has to be executed. The position in the life cycle is the LCE's rank (i.e. the value given in input to the parameter "name"). As only one rank value is allowed per LCE, it is executed only once in the life cycle, this is a limitation that might be removed in future versions if need be!

The main action of an LCE is often to move individuals between populations, between age-classes or both. The changes done to the population age structure by a particular LCE are tracked through the removeAgeClass() and addAgeClass() interface methods called after each execution of an LCE. The metapopulation age flag is thus updated by these two functions.

Note: Overloading LifeCycleEvent::init(). If more than one trait is used by your LCE, think about overloading the init() function to allow the registration of several trait links within your derived LCE. The init() method will also be overloaded if you add additional parameters to the LCE's ParamSet. In any cases, LifeCycleEvent::init() MUST be called in your init() function to properly set the metapop pointer (unless you copy the code into your function...).

Note: the LCEs must be inited after a call to IndFactory::makePrototype() has been issued so that the trait links can be set!

Definition at line 72 of file lifecycleevent.h.


Constructor & Destructor Documentation

LifeCycleEvent::LifeCycleEvent ( const char *  name,
const char *  trait_link 
) [inline]

Cstor.

Parameters:
name the name of the LCE as it must appear in the parameter input file
trait_link the name of the linked trait used by this LCE

Definition at line 93 of file lifecycleevent.h.

00094   : _popPtr(0), _LCELinkedTraitType(trait_link), _LCELinkedTraitIndex(-1)
00095   {
00096 //    cout << "calling LifeCycleEvent("<<name<<","<<trait_link<<")\n";
00097     set_event_name(name);
00098   }

Here is the call graph for this function:

virtual LifeCycleEvent::~LifeCycleEvent (  )  [inline, virtual]

Definition at line 100 of file lifecycleevent.h.

00100 { }


Member Function Documentation

virtual age_t LifeCycleEvent::addAgeClass (  )  [pure virtual]

virtual bool LifeCycleEvent::attach_trait ( string  trait  )  [inline, virtual]

Definition at line 113 of file lifecycleevent.h.

Referenced by init(), and LCE_Selection_base::setParameters().

00114   {
00115     _LCELinkedTraitType = trait;
00116     
00117     if(_LCELinkedTraitType.size() != 0) {
00118       _LCELinkedTraitIndex = _popPtr->getTraitIndex(_LCELinkedTraitType.c_str());
00119       if(_LCELinkedTraitIndex == -1) {
00120         error("cannot attach trait \"%s\" to life cycle event \"%s\", trait has not been initiated.\n",
00121               _LCELinkedTraitType.c_str(), _event_name.c_str());
00122         return false;
00123       }
00124     }
00125     return true;
00126   }

virtual LifeCycleEvent* LifeCycleEvent::clone (  )  [pure virtual]

virtual void LifeCycleEvent::execute (  )  [pure virtual]

virtual string& LifeCycleEvent::get_event_name (  )  [inline, virtual]

Accessor to the LCE's name.

Definition at line 150 of file lifecycleevent.h.

00151   { return _event_name; }

virtual Metapop* LifeCycleEvent::get_pop_ptr (  )  [inline, virtual]

Definition at line 163 of file lifecycleevent.h.

Referenced by LCE_FileServicesNotifier::execute(), and LCE_ParamUpdaterNotifier::execute().

00164   { return _popPtr; }

virtual int LifeCycleEvent::get_rank (  )  [inline, virtual]

Accessor to the LCE rank in the life cycle.

Definition at line 155 of file lifecycleevent.h.

Referenced by LCE_StatServiceNotifier::setParameters(), and BinaryDataSaver::setParameters().

00156   { return (int)get_parameter_value(_event_name.c_str()); }

virtual void LifeCycleEvent::init ( Metapop popPtr  )  [inline, virtual]

Sets the pointer to the current Metapop and the trait link if applicable.

DEV: Don't forget to explicitly call this function (LifeCycleEvent::init()) when you overload it!

Parameters:
popPtr the pointer to the current instance of Metapop

Definition at line 106 of file lifecycleevent.h.

Referenced by SimRunner::init_components().

00107   { 
00108     _popPtr = popPtr;
00109     if(!attach_trait(_LCELinkedTraitType)) fatal("bailing out\n");
00110     if(!setParameters()) fatal("bailing out\n");
00111   }

Here is the call graph for this function:

virtual age_t LifeCycleEvent::removeAgeClass (  )  [pure virtual]

virtual age_t LifeCycleEvent::requiredAgeClass (  )  [pure virtual]

virtual void LifeCycleEvent::set_event_name ( const char *  name  )  [inline, virtual]

Definition at line 142 of file lifecycleevent.h.

00143   {
00144     _event_name = name;
00145     set_paramset(name, 0, this); 
00146 //    add_parameter(name,INT,1,0,0,0);
00147   }

virtual void LifeCycleEvent::set_event_name ( std::string &  name  )  [inline, virtual]

Set the name of the event (name of the ParamSet) and add the corresponding parameter to the set.

Definition at line 135 of file lifecycleevent.h.

Referenced by LifeCycleEvent().

00136   {
00137     _event_name = name;
00138     set_paramset(name, 0, this);
00139 //    add_parameter(name.c_str(),INT,1,0,0,0);
00140   }

virtual void LifeCycleEvent::set_paramset ( std::string  name,
bool  required,
SimComponent owner 
) [inline, virtual]

Sets a new ParamSet and name it.

Parameters:
name the name of the parameters container
required tag whether the component is required to run a simulation
owner a reference to the owner of the ParamSet (should be this).

Reimplemented from SimComponent.

Definition at line 128 of file lifecycleevent.h.

Referenced by set_event_name().

00129   {
00130     SimComponent::set_paramset(name, required, owner);
00131     add_parameter(name.c_str(),INT,1,0,0,0,0);
00132   }

virtual void LifeCycleEvent::set_pop_ptr ( Metapop popPtr  )  [inline, virtual]

Accessors for the population pointer.

Parameters:
popPtr The pointer to the current Metapop

Definition at line 160 of file lifecycleevent.h.

00161   {_popPtr = popPtr;}


Member Data Documentation

std::string LifeCycleEvent::_event_name [protected]

The param name to be read in the init file.

Definition at line 76 of file lifecycleevent.h.

Referenced by attach_trait(), get_event_name(), get_rank(), and set_event_name().

std::string LifeCycleEvent::_LCELinkedTraitType [protected]

The name of the linked trait.

Definition at line 80 of file lifecycleevent.h.

Referenced by attach_trait(), and init().

The ptr to the current Metapop.

Definition at line 78 of file lifecycleevent.h.

Referenced by attach_trait(), LCE_Breed_base::breed(), LCE_Breed_base::breed_cloning(), LCE_Breed_Selection_Disperse::breed_selection_disperse(), LCE_Resize::buildNewPatchArrayNoBackup(), LCE_Resize::buildNewPatchArrayWithBackup(), LCE_Disperse_base::checkBackwardDispersalMatrix(), LCE_Disperse_base::checkForwardDispersalMatrix(), LCE_Breed_Disperse::do_breed_disperse(), LCE_Patch_Extinction::do_flush(), LCE_Selection_base::doViabilitySelection(), LCE_Disperse_EvolDisp::evoldisp(), LCE_ParamUpdaterNotifier::execute(), LCE_Selection_base::execute(), LCE_Resize::execute(), LCE_Cross::execute(), LCE_Patch_Extinction::execute(), LCE_Regulation::execute(), LCE_Aging::execute(), LCE_Disperse_EvolDisp::execute(), LCE_Disperse_ConstDisp::execute(), LCE_Breed_Selection::execute(), LCE_Breed_Selection_Disperse::execute(), LCE_Breed_Disperse::execute(), LCE_Breed_Wolbachia::execute(), LCE_Breed::execute(), BinaryDataSaver::execute(), LCE_Resize::fillPatchNoBackup(), LCE_Resize::fillPatchWithBackup(), LCE_Resize::fillPop(), BinaryDataSaver::finish(), LCE_Disperse_EvolDisp::fixdisp(), LCE_Breed_Disperse::get_parent(), get_pop_ptr(), LCE_Selection_base::getMeanFitness(), LCE_Selection_base::getMeanPatchFitness(), LCE_Breed_Wolbachia::hasInfectedFemale(), init(), LCE_Breed_Wolbachia::inoculate_wolbachia(), LCE_Breed_Selection::makeOffspringWithSelection(), LCE_Breed_Disperse::mate_full_selfing(), LCE_Breed_Disperse::mate_random(), LCE_Breed_Disperse::mate_random_hermaphrodite(), LCE_Breed_Disperse::mate_selfing(), LCE_Disperse_ConstDisp::Migrate(), LCE_Disperse_ConstDisp::MigratePatch(), LCE_Disperse_ConstDisp::MigratePatch_AbsorbingBorder(), LCE_Resize::regulate(), LCE_Resize::regulateAgeClassNoBackup(), LCE_Regulation::regulatePatch(), LCE_Resize::removeDesignatedPatch(), LCE_Disperse_base::reset_counters(), LCE_Patch_Extinction::set_matrix_param(), set_pop_ptr(), LCE_Selection_base::setParameters(), LCE_Disperse_EvolDisp::setParameters(), LCE_Disperse_base::setParameters(), LCE_Disperse_base::setPropaguleTargets(), LCE_Selection_base::setSelectionMatrix(), LCE_Selection_base::setSpatialMatrix(), BinaryDataSaver::storeData(), LCE_Disperse_base::swapPostDisp(), LCE_Resize::updateParameters(), and LCE_Resize::updatePatchCapacities().


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

Generated for Nemo v2.1.2 by  doxygen 1.5.8 -- Nemo is hosted by  SourceForge.net Logo