Nemo  2.2.0
Public Member Functions | Protected Attributes
LifeCycleEvent Class Reference

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

#include <lifecycleevent.h>

+ Inheritance diagram for LifeCycleEvent:
+ Collaboration diagram for LifeCycleEvent:

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:
namethe name of the LCE as it must appear in the parameter input file
trait_linkthe name of the linked trait used by this LCE

Definition at line 93 of file lifecycleevent.h.

References set_event_name().

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

+ Here is the call graph for this function:

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

Definition at line 100 of file lifecycleevent.h.

{ }

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.

References _event_name, _LCELinkedTraitIndex, _LCELinkedTraitType, _popPtr, error(), and IndFactory::getTraitIndex().

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

  {
    _LCELinkedTraitType = trait;
    
    if(_LCELinkedTraitType.size() != 0) {
      _LCELinkedTraitIndex = _popPtr->getTraitIndex(_LCELinkedTraitType.c_str());
      if(_LCELinkedTraitIndex == -1) {
        error("cannot attach trait \"%s\" to life cycle event \"%s\", trait has not been initiated.\n",
              _LCELinkedTraitType.c_str(), _event_name.c_str());
        return false;
      }
    }
    return true;
  }
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.

References _event_name.

  { return _event_name; }
virtual Metapop* LifeCycleEvent::get_pop_ptr ( ) [inline, virtual]

Definition at line 163 of file lifecycleevent.h.

References _popPtr.

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

  { 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.

References _event_name, and SimComponent::get_parameter_value().

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

  { 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:
popPtrthe pointer to the current instance of Metapop

Definition at line 106 of file lifecycleevent.h.

References _LCELinkedTraitType, _popPtr, attach_trait(), fatal(), and SimComponent::setParameters().

Referenced by SimRunner::init_components().

  { 
    _popPtr = popPtr;
    if(!attach_trait(_LCELinkedTraitType)) fatal("bailing out\n");
    if(!setParameters()) fatal("bailing out\n");
  }

+ 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 ( 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.

References _event_name, and set_paramset().

Referenced by LifeCycleEvent().

  {
    _event_name = name;
    set_paramset(name, 0, this);
//    add_parameter(name.c_str(),INT,1,0,0,0);
  }
virtual void LifeCycleEvent::set_event_name ( const char *  name) [inline, virtual]

Definition at line 142 of file lifecycleevent.h.

References _event_name, and set_paramset().

  {
    _event_name = name;
    set_paramset(name, 0, this); 
//    add_parameter(name,INT,1,0,0,0);
  }
virtual void LifeCycleEvent::set_paramset ( std::string  name,
bool  required,
SimComponent owner 
) [inline, virtual]

Sets a new ParamSet and name it.

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

Reimplemented from SimComponent.

Definition at line 128 of file lifecycleevent.h.

References SimComponent::add_parameter(), and INT.

Referenced by set_event_name().

  {
    SimComponent::set_paramset(name, required, owner);
    add_parameter(name.c_str(),INT,1,0,0,0,0);
  }
virtual void LifeCycleEvent::set_pop_ptr ( Metapop popPtr) [inline, virtual]

Accessors for the population pointer.

Parameters:
popPtrThe pointer to the current Metapop

Definition at line 160 of file lifecycleevent.h.

References _popPtr.

  {_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_Selection_base::doViabilitySelection(), LCE_Disperse_EvolDisp::evoldisp(), LCE_ParamUpdaterNotifier::execute(), BinaryDataSaver::execute(), LCE_Breed_Disperse::execute(), LCE_Disperse_ConstDisp::execute(), LCE_Breed_Selection::execute(), LCE_Disperse_EvolDisp::execute(), LCE_Breed_Selection_Disperse::execute(), LCE_Selection_base::execute(), LCE_Resize::execute(), LCE_Breed::execute(), LCE_Breed_Wolbachia::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_Resize::removeDesignatedPatch(), LCE_Disperse_base::reset_counters(), set_pop_ptr(), LCE_Disperse_base::setParameters(), LCE_Disperse_EvolDisp::setParameters(), LCE_Selection_base::setParameters(), LCE_Disperse_base::setPropaguleTargets(), LCE_Selection_base::setSelectionMatrix(), LCE_Selection_base::setSpatialMatrix(), BinaryDataSaver::storeData(), LCE_Disperse_base::swapPostDisp(), LCE_Resize::updateParameters(), LCE_Resize::updatePatchCapacities(), LCE_Breed_Wolbachia::wolbachia_model_1(), and LCE_Breed_Wolbachia::wolbachia_model_2().


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

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