Nemo  2.3.56
Simulate forward-in-time genetic evolution in a spatially explicit, individual-based stochastic simulator
LCE_FileServicesNotifier Class Reference

Event used to notify all file handlers to update their state through the FileServices::notify() interface. More...

#include <servicenotifiers.h>

+ Inheritance diagram for LCE_FileServicesNotifier:
+ Collaboration diagram for LCE_FileServicesNotifier:

Public Member Functions

 LCE_FileServicesNotifier ()
 
virtual ~LCE_FileServicesNotifier ()
 
virtual void execute ()
 
virtual bool setParameters ()
 
virtual LifeCycleEventclone ()
 
virtual void loadFileServices (FileServices *loader)
 
virtual void loadStatServices (StatServices *loader)
 
virtual bool resetParameterFromSource (std::string param, SimComponent *cmpt)
 
virtual age_t removeAgeClass ()
 
virtual age_t addAgeClass ()
 
virtual age_t requiredAgeClass ()
 
- Public Member Functions inherited from LifeCycleEvent
 LifeCycleEvent (const char *name, const char *trait_link)
 Cstor. More...
 
virtual ~LifeCycleEvent ()
 
virtual void init (Metapop *popPtr)
 Sets the pointer to the current Metapop and the trait link if applicable. More...
 
virtual bool attach_trait (string trait)
 
virtual void set_paramset (std::string name, bool required, SimComponent *owner)
 
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. More...
 
virtual void set_event_name (const char *name)
 
virtual string & get_event_name ()
 Accessor to the LCE's name. More...
 
virtual int get_rank ()
 Accessor to the LCE rank in the life cycle. More...
 
virtual void set_pop_ptr (Metapop *popPtr)
 Accessors for the population pointer. More...
 
virtual Metapopget_pop_ptr ()
 
- Public Member Functions inherited from SimComponent
 SimComponent ()
 
virtual ~SimComponent ()
 
virtual void loadUpdaters (UpdaterServices *loader)
 Loads the parameters and component updater onto the updater manager. More...
 
virtual void set_paramset (ParamSet *paramset)
 Sets the ParamSet member. More...
 
virtual void set_paramsetFromCopy (const ParamSet &PSet)
 Reset the set of parameters from a another set. More...
 
virtual ParamSetget_paramset ()
 ParamSet accessor. More...
 
virtual void add_parameter (Param *param)
 Interface to add a parameter to the set. More...
 
virtual void add_parameter (std::string Name, param_t Type, bool isRequired, bool isBounded, double low_bnd, double up_bnd)
 Interface to add a parameter to the set. More...
 
virtual void add_parameter (std::string Name, param_t Type, bool isRequired, bool isBounded, double low_bnd, double up_bnd, ParamUpdaterBase *updater)
 Interface to add a parameter and its updater to the set. More...
 
virtual Paramget_parameter (std::string name)
 Param getter. More...
 
virtual double get_parameter_value (std::string name)
 Param value getter. More...
 
virtual string get_name ()
 Returnd the name of the ParamSet, i.e. More...
 
virtual bool has_parameter (std::string name)
 Param getter. More...
 

Private Attributes

FileServices_service
 
unsigned int _sample_size
 
age_t _sample_age
 
FileMergerFH_mergeWriter
 

Additional Inherited Members

- Protected Attributes inherited from LifeCycleEvent
std::string _event_name
 The param name to be read in the init file. More...
 
Metapop_popPtr
 The ptr to the current Metapop. More...
 
std::string _LCELinkedTraitType
 The name of the linked trait. More...
 
int _LCELinkedTraitIndex
 The index in the individual's trait table of the linked trait. More...
 
- Protected Attributes inherited from SimComponent
ParamSet_paramSet
 The parameters container. More...
 

Detailed Description

Event used to notify all file handlers to update their state through the FileServices::notify() interface.

Constructor & Destructor Documentation

◆ LCE_FileServicesNotifier()

LCE_FileServicesNotifier::LCE_FileServicesNotifier ( )
62 : LifeCycleEvent("save_files",""),
64{
65
66 add_parameter("files_sample_size", INT, false, false, 0, 0);
67 add_parameter("files_sample_age", INT, false, false, 0, 0);
68 add_parameter("files_merge_output_genotype", STR, false, false, 0, 0);
69 add_parameter("files_merge_output_format", STR, false, false, 0, 0);
70 add_parameter("files_merge_output_logtime", INT, false, false, 0, 0);
71 add_parameter("files_merge_output_dir", STR, false, false, 0, 0);
72
73}
FileMergerFH * _mergeWriter
Definition: servicenotifiers.h:79
age_t _sample_age
Definition: servicenotifiers.h:77
FileServices * _service
Definition: servicenotifiers.h:75
unsigned int _sample_size
Definition: servicenotifiers.h:76
Base class of the Life Cycle Events, declares the LCE interface.
Definition: lifecycleevent.h:73
virtual void add_parameter(Param *param)
Interface to add a parameter to the set.
Definition: simcomponent.h:112
@ STR
Definition: types.h:78
@ INT
Definition: types.h:78

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

Referenced by clone().

+ Here is the caller graph for this function:

◆ ~LCE_FileServicesNotifier()

LCE_FileServicesNotifier::~LCE_FileServicesNotifier ( )
virtual
76{
77 if(_mergeWriter) delete _mergeWriter;
78}

References _mergeWriter.

Member Function Documentation

◆ addAgeClass()

virtual age_t LCE_FileServicesNotifier::addAgeClass ( )
inlinevirtual

Implements LifeCycleEvent.

95{return 0;}

◆ clone()

virtual LifeCycleEvent * LCE_FileServicesNotifier::clone ( )
inlinevirtual

Implements LifeCycleEvent.

88{return new LCE_FileServicesNotifier();}
LCE_FileServicesNotifier()
Definition: servicenotifiers.cc:62

References LCE_FileServicesNotifier().

◆ execute()

void LCE_FileServicesNotifier::execute ( )
virtual

Implements LifeCycleEvent.

155{
156#ifdef _DEBUG_
157 message("LCE_FileServicesNotifier::execute (gen: %i rpl: %i)\n",
158 this->get_pop_ptr()->getCurrentGeneration(),
159 this->get_pop_ptr()->getCurrentReplicate());
160#endif
161
162 _service->notify();
163}
virtual void notify()
Definition: fileservices.cc:188
virtual Metapop * get_pop_ptr()
Definition: lifecycleevent.h:174
void message(const char *message,...)
Definition: output.cc:40

References _service, LifeCycleEvent::get_pop_ptr(), message(), and FileServices::notify().

◆ loadFileServices()

void LCE_FileServicesNotifier::loadFileServices ( FileServices loader)
virtual

Implements SimComponent.

104{
105 _service = loader;
106
107 if( _sample_size > 0 )
109
110 if(get_parameter("files_merge_output_genotype")->isSet()) {
111
112 // create FH for merged output
113 if( _mergeWriter) delete _mergeWriter;
114 _mergeWriter = new FileMergerFH(this);
115
116 vector< string > traits = get_parameter("files_merge_output_genotype")->getMultiArgs();
117
118 int index;
119
120 for(unsigned int i = 0; i < traits.size(); i++) {
121
122 if( _popPtr->getTraitIndex(traits[i].c_str()) < 0) {
123
124 fatal("FileMerger::cannot find trait \"%s\" among successfully initialized traits.\n", traits[i].c_str());
125
126 }
127 }
128
129 _mergeWriter->setTraits(traits);
130
131 Param* param = get_parameter("files_merge_output_logtime");
132
133 if(!param->isSet()) fatal("parameter \"files_merge_output_logtime\" is missing\n");
134
135 if(param->isMatrix()) {
136
137 TMatrix temp;
138
139 param->getMatrix(&temp);
140
141 _mergeWriter->set_multi(true, true, 1, &temp, get_parameter("selection_output_dir")->getArg());
142 // rpl_per, gen_per, rpl_occ, gen_occ, rank, path, self-ref
143 } else
144 _mergeWriter->set(true, param->isSet(), 1, (param->isSet() ? (int)param->getValue() : 0),
145 0, get_parameter("files_merge_output_dir")->getArg(), this);
146
147 loader->attach(_mergeWriter);
148 }
149
150}
virtual void set(bool rpl_per, bool gen_per, int rpl_occ, int gen_occ, int rank, string path, LCE *event)
Definition: filehandler.h:265
virtual void set_multi(bool rpl_per, bool gen_per, int rpl_occ, TMatrix *Occ, string path)
Definition: filehandler.h:197
Definition: servicenotifiers.h:101
void setTraits(vector< trait_t > &traits)
Definition: servicenotifiers.cc:165
void set_sampling_params(unsigned int size, age_t age)
Set the population sampling params.
Definition: fileservices.h:117
virtual void attach(Handler *FH)
Attaches the FileHandler to the current list (_writers) of the FileServices.
Definition: fileservices.cc:60
int getTraitIndex(trait_t type)
Gives the index of trait with type.
Definition: indfactory.cc:128
Metapop * _popPtr
The ptr to the current Metapop.
Definition: lifecycleevent.h:81
This structure stores one parameter, its definition and its string argument.
Definition: param.h:54
double getValue()
Returns the argument value according to its type.
Definition: param.cc:347
bool isMatrix()
Checks if the argument is of matrix type.
Definition: param.h:172
void getMatrix(TMatrix *mat)
Sets the matrix from the argument string if the parameter is set and of matrix type.
Definition: param.cc:357
vector< string > getMultiArgs()
Definition: param.cc:122
bool isSet()
Definition: param.h:140
virtual Param * get_parameter(std::string name)
Param getter.
Definition: simcomponent.h:139
A class to handle matrix in params, coerces matrix into a vector of same total size.
Definition: tmatrix.h:49
void fatal(const char *str,...)
Definition: output.cc:96

References _mergeWriter, LifeCycleEvent::_popPtr, _sample_age, _sample_size, _service, FileServices::attach(), fatal(), SimComponent::get_parameter(), Param::getMatrix(), Param::getMultiArgs(), IndFactory::getTraitIndex(), Param::getValue(), Param::isMatrix(), Param::isSet(), EventFileHandler< LCE >::set(), FileHandler::set_multi(), FileServices::set_sampling_params(), and FileMergerFH::setTraits().

◆ loadStatServices()

virtual void LCE_FileServicesNotifier::loadStatServices ( StatServices loader)
inlinevirtual

Implements SimComponent.

92{}

◆ removeAgeClass()

virtual age_t LCE_FileServicesNotifier::removeAgeClass ( )
inlinevirtual

Implements LifeCycleEvent.

94{return 0;}

◆ requiredAgeClass()

virtual age_t LCE_FileServicesNotifier::requiredAgeClass ( )
inlinevirtual

Implements LifeCycleEvent.

96{return 0;}

◆ resetParameterFromSource()

virtual bool LCE_FileServicesNotifier::resetParameterFromSource ( std::string  param,
SimComponent cmpt 
)
inlinevirtual

Implements SimComponent.

93{return false;}

◆ setParameters()

bool LCE_FileServicesNotifier::setParameters ( )
virtual

Implements SimComponent.

83{
84 _sample_size = 0;
85
86 if( get_parameter("files_sample_size")->isSet() )
87 _sample_size = get_parameter_value("files_sample_size");
88
89 _sample_age = 0;
90
91 if(get_parameter("files_sample_age")->isSet())
92 _sample_age = static_cast<age_t> (get_parameter_value("files_sample_age"));
93
94 if(get_parameter("files_merge_output_genotype")->isSet()){
95
96 //read trait types, get genetic map
97 }
98 return true;
99}
virtual double get_parameter_value(std::string name)
Param value getter.
Definition: simcomponent.h:143
unsigned int age_t
Age class flags.
Definition: types.h:46

References _sample_age, _sample_size, SimComponent::get_parameter(), SimComponent::get_parameter_value(), and Param::isSet().

Member Data Documentation

◆ _mergeWriter

FileMergerFH* LCE_FileServicesNotifier::_mergeWriter
private

◆ _sample_age

age_t LCE_FileServicesNotifier::_sample_age
private

Referenced by loadFileServices(), and setParameters().

◆ _sample_size

unsigned int LCE_FileServicesNotifier::_sample_size
private

Referenced by loadFileServices(), and setParameters().

◆ _service

FileServices* LCE_FileServicesNotifier::_service
private

Referenced by execute(), and loadFileServices().


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

Generated for Nemo v2.3.56 by  doxygen 1.9.0 -- Nemo is hosted on  Download Nemo

Locations of visitors to this page
Catalogued on GSR