Nemo
2.3.56
Simulate forward-in-time genetic evolution in a spatially explicit, individual-based stochastic simulator
|
To output information about your newly implemented trait or LCE, you will have to add stat and/or file handlers to the trait prototype.
The StatHandler interface has two specialized classes; the TraitStatHandler and the EventStatHandler template classes. Each implements the StatHandler interface and declares a link to either the TraitPrototype or LCE using it. For the Trait version, the TraitStatHandler also stores the trait's index. These can be accessed within each class by the TraitStatHandler::_SHLinkedTrait, TraitStatHandler::_SHLinkedTraitIndex and EventStatHandler::_SHLinkedEvent members. These member variables are set during construction.
The same is true for the FileHandler interface and its two derivatives: the TraitFileHandler and EventFileHandler template classes. They also declare the links to the trait prototype and LCE like this: TraitFileHandler::_FHLinkedTrait, TraitFileHandler::_FHLinkedTraitIndex and EventFileHandler::_FHLinkedEvent.
The only thing the implementer has to do then is to define the StatHandlerBase::setStatRecorders() and FileHandler::FHwrite() virtual functions and define the file extension in the FileHandler constructor (see below).
The handlers must then be attach to their respective service handler (i.e. StatServices or FileServices) to be called at runtime and actually do their job. This is done through the SimComponent interface of the TraitPrototype or LifeCycleEvent interfaces. The stat handlers are loaded into the stat service handler by the SimComponent::loadStatServices() function. The file handlers will be loaded by a call to SimComponent::loadFileServices(). This is done during the initialization process of the simulation, after having initialized the Trait Prototypes or LCEs (i.e. after those components parameters have been set). It is thus the responsibility of these two types of components to take care of the allocation and loading of the various handlers.
Here is an example of an implementation of a TraitStatHandler:
In mytrait.h, you will have to add:
Modifications and additions to mytrait.cpp:
The process of adding a Trait/EventFileHandler is quite similar. It is also added in the trait prototype and declares one pure abstract method, the FHWrite() method used to write the file as specified by your implementation. The difference with the TraitStatHandler is that it takes only one template argument, the trait prototype type and the FileHandler constructor require the file extension as argument in addition to the pointer to the trait prototype.
Here is a simple example of an implementation of a TraitFileHandler:
Within the MyTraitFH class, the population (and its members) is also accessed through the FileHandler::_pop base-class member and the trait's parameters are accessed through the TraitFileHandler::_FHLinkedTrait pointer. The trait value (or phenotype) of an individual is also accessed through the TraitFileHandler::_FHLinkedTraitIndex value as in the TraitStatHandler class.
The procedure to declare the LCE-linked versions of these handlers is exactly the same, the only difference is that there is only one member variable, the _FH/_SHLinkedEvent pointer to the LCE.