Nemo  2.4.2
Simulate forward-in-time genetic evolution in a spatially explicit, individual-based stochastic simulator
indfactory.h
Go to the documentation of this file.
1 
27 #ifndef FACTORY_H
28 #define FACTORY_H
29 
30 #include <map>
31 #include <deque>
32 #include "individual.h"
33 #include "types.h"
34 #include "ttrait.h"
35 
41 class IndFactory {
42 protected:
44  std::map< trait_t, TraitPrototype* > _protoTraits;
46  std::map< trait_t, int > _TraitsIndex;
47 
50 
52  std::deque<Individual*> RecyclingPOOL;
53 
54 public:
55 
56  IndFactory ( ) { };
57  virtual ~IndFactory ( );
58 
60  void recycle(Individual* ind)
61  { if(ind == NULL) error("IndFactory::recycle:ind is NULL!!\n"); else RecyclingPOOL.push_back(ind); }
62 
65  { for(unsigned int i=0; i < RecyclingPOOL.size(); ++i) delete RecyclingPOOL[i]; RecyclingPOOL.clear(); }
66 
71  void makePrototype (map< trait_t,TraitPrototype* > TTlist);
72 
74  void clearPrototype ( );
75 
78 
84 
95  Individual* makeNewIndividual (Individual* newind, Individual* mother, Individual* father, sex_t sex, unsigned short homepatch);
96 
106  Individual* decorateNewIndividual (Individual* newind, Individual* mother, Individual* father, sex_t sex, unsigned short homepatch);
107 
118  Individual* makeNewIndividual (Individual* mother, Individual* father, sex_t sex, unsigned short homepatch);
119 
127  Individual* makeOffsprg (Individual* mother, Individual* father, sex_t sex, unsigned short homepatch);
128 
131 
136 
138  std::map< trait_t,TraitPrototype* >& getTraitPrototypes ( ) {return _protoTraits;}
139 
142  int getTraitIndex (trait_t type);
143 
144 };
145 
146 #endif
147 
Factory of Individual, stores the individual prototype and the trait prototypes, manages the individu...
Definition: indfactory.h:41
Individual * makeNewIndividual(Individual *newind, Individual *mother, Individual *father, sex_t sex, unsigned short homepatch)
Creates an individual from existing pointer with new ID.
Definition: indfactory.cc:150
void recycle(Individual *ind)
Put an individual in the recycling pool.
Definition: indfactory.h:60
virtual ~IndFactory()
Definition: indfactory.cc:34
std::deque< Individual * > RecyclingPOOL
Garbage collector for unused Individual's.
Definition: indfactory.h:52
Individual * makeOffsprg(Individual *mother, Individual *father, sex_t sex, unsigned short homepatch)
Completely creates an individual with inheritance and mutations on all traits.
Definition: indfactory.cc:232
Individual * decorateNewIndividual(Individual *newind, Individual *mother, Individual *father, sex_t sex, unsigned short homepatch)
Sets the internals of a new individual with pointers to parents, sex and home ID set.
Definition: indfactory.cc:178
std::map< trait_t, int > _TraitsIndex
Table containing the index of each trait.
Definition: indfactory.h:46
Individual * getNewIndividual()
Creates a blank individual which has to be "decorated" later.
Definition: indfactory.h:83
void makePrototype(map< trait_t, TraitPrototype * > TTlist)
Creates the individuals prototype from the selected trait prototypes.
Definition: indfactory.cc:48
std::map< trait_t, TraitPrototype * > _protoTraits
Map of the trait prototypes.
Definition: indfactory.h:44
void purgeRecyclingPOOL()
Empty the recycling pool.
Definition: indfactory.h:64
int getTraitIndex(trait_t type)
Gives the index of trait with type.
Definition: indfactory.cc:126
void clearPrototype()
Reset the trait prototypes, mostly done to unregister the genetic maps.
Definition: indfactory.cc:101
std::map< trait_t, TraitPrototype * > & getTraitPrototypes()
Accessor to the list of TraitPrototype's.
Definition: indfactory.h:138
IndFactory()
Definition: indfactory.h:56
Individual * getPrototypeClone()
Return an uninitialized copy of the individual prototype.
Definition: indfactory.h:77
Individual * getIndividualProtoype()
Individual prototype accessor.
Definition: indfactory.h:130
TraitPrototype * getTraitPrototype(trait_t type)
Accessor to a TraitPrototype.
Definition: indfactory.cc:138
Individual _protoIndividual
The individuals prototype used to create any new individual in a simulation.
Definition: indfactory.h:49
This class contains traits along with other individual information (sex, pedigree,...
Definition: individual.h:47
Individual * clone()
Cloning procedure, clones all the traits present in the individual.
Definition: individual.cc:148
TTrait setter.
Definition: ttrait.h:129
int error(const char *str,...)
Definition: output.cc:77
Nemo2.
Nemo2.
std::string trait_t
Trait types.
Definition: types.h:61
sex_t
Sex types, males are always 0 and females 1!!
Definition: types.h:34
@ MAL
Definition: types.h:35

Generated for Nemo v2.4.2 by  doxygen 1.9.1

Catalogued on GSR