Nemo  2.3.56
Simulate forward-in-time genetic evolution in a spatially explicit, individual-based stochastic simulator
lifecycleevent.h
Go to the documentation of this file.
1
30#ifndef LIFECYCLEEVENT_H
31#define LIFECYCLEEVENT_H
32
33#include <string>
34#include <list>
35#include <map>
36#include "param.h"
37#include "simcomponent.h"
38#include "metapop.h"
39
72class LifeCycleEvent : public virtual SimComponent
73{
74protected:
75
77 std::string _event_name;
78
79
82
83
86
87
90
91
92public:
98 LifeCycleEvent (const char* name, const char* trait_link)
100 {
101// cout << "calling LifeCycleEvent("<<name<<","<<trait_link<<")\n";
102 set_event_name(name);
103 }
104
105
106 virtual ~LifeCycleEvent ( ) { }
107
108
114 virtual void init(Metapop* popPtr)
115 {
116 _popPtr = popPtr;
117 if(!attach_trait(_LCELinkedTraitType)) fatal("bailing out\n");
118 if(!setParameters()) fatal("bailing out\n");
119 }
120
121
122
123 virtual bool attach_trait (string trait)
124 {
125 _LCELinkedTraitType = trait;
126
127 if(_LCELinkedTraitType.size() != 0) {
128
130
131 if(_LCELinkedTraitIndex == -1) {
132 return error("cannot attach trait \"%s\" to life cycle event \"%s\", trait has not been initiated.\n",
133 _LCELinkedTraitType.c_str(), _event_name.c_str());
134 }
135
136 }
137
138 return true;
139 }
140
141 virtual void set_paramset (std::string name, bool required, SimComponent* owner )
142 {
143 SimComponent::set_paramset(name, required, owner);
144 add_parameter(name.c_str(),INT,1,0,0,0,0);
145 }
146
148 virtual void set_event_name (std::string& name)
149 {
150 _event_name = name;
151 set_paramset(name, 0, this);
152 }
153
154 virtual void set_event_name (const char* name)
155 {
156 _event_name = name;
157 set_paramset(name, 0, this);
158 }
159
161 virtual string& get_event_name ( )
162 { return _event_name; }
163
166 virtual int get_rank ( )
167 { return (int)get_parameter_value(_event_name.c_str()); }
168
171 virtual void set_pop_ptr (Metapop* popPtr)
172 {_popPtr = popPtr;}
173
174 virtual Metapop* get_pop_ptr ( )
175 { return _popPtr; }
176
177
178
179
182
184 virtual void execute () = 0;
185
187 virtual LifeCycleEvent* clone () = 0;
188
190 virtual age_t removeAgeClass () = 0;
191
193 virtual age_t addAgeClass () = 0;
194
196 virtual age_t requiredAgeClass () = 0;
197
199
200
201
202};
203
204#endif //LIFECYCLEEVENT_H
205
int getTraitIndex(trait_t type)
Gives the index of trait with type.
Definition: indfactory.cc:128
Base class of the Life Cycle Events, declares the LCE interface.
Definition: lifecycleevent.h:73
virtual age_t requiredAgeClass()=0
Specifies what age-classes are required by the LCE to execute.
virtual ~LifeCycleEvent()
Definition: lifecycleevent.h:106
virtual void execute()=0
Execute the event on the pop.
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.
Definition: lifecycleevent.h:148
virtual bool attach_trait(string trait)
Definition: lifecycleevent.h:123
virtual void set_event_name(const char *name)
Definition: lifecycleevent.h:154
virtual int get_rank()
Accessor to the LCE rank in the life cycle.
Definition: lifecycleevent.h:166
int _LCELinkedTraitIndex
The index in the individual's trait table of the linked trait.
Definition: lifecycleevent.h:89
virtual string & get_event_name()
Accessor to the LCE's name.
Definition: lifecycleevent.h:161
virtual Metapop * get_pop_ptr()
Definition: lifecycleevent.h:174
virtual age_t removeAgeClass()=0
Removes the returned age-class flag(s) from the current Metapop age-class flags.
virtual void init(Metapop *popPtr)
Sets the pointer to the current Metapop and the trait link if applicable.
Definition: lifecycleevent.h:114
virtual void set_paramset(std::string name, bool required, SimComponent *owner)
Definition: lifecycleevent.h:141
std::string _event_name
The param name to be read in the init file.
Definition: lifecycleevent.h:77
LifeCycleEvent(const char *name, const char *trait_link)
Cstor.
Definition: lifecycleevent.h:98
virtual age_t addAgeClass()=0
Adds the returned age-class flag(s) to the current Metapop age-class flags.
virtual LifeCycleEvent * clone()=0
Cloning interface.
virtual void set_pop_ptr(Metapop *popPtr)
Accessors for the population pointer.
Definition: lifecycleevent.h:171
std::string _LCELinkedTraitType
The name of the linked trait.
Definition: lifecycleevent.h:85
Metapop * _popPtr
The ptr to the current Metapop.
Definition: lifecycleevent.h:81
Top class of the metapopulation structure, contains the patches.
Definition: metapop.h:80
Interface to all basic components of a simulation (traits, life cycle events, pop,...
Definition: simcomponent.h:45
virtual double get_parameter_value(std::string name)
Param value getter.
Definition: simcomponent.h:143
virtual void set_paramset(ParamSet *paramset)
Sets the ParamSet member.
Definition: simcomponent.h:86
virtual void add_parameter(Param *param)
Interface to add a parameter to the set.
Definition: simcomponent.h:112
virtual bool setParameters()=0
Default interface needed to initialize the component's variables from its input parameters value.
void fatal(const char *str,...)
Definition: output.cc:96
int error(const char *str,...)
Definition: output.cc:77
unsigned int age_t
Age class flags.
Definition: types.h:46
@ INT
Definition: types.h:78

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