Nemo  2.3.46
indfactory.h
Go to the documentation of this file.
1 
29 #ifndef FACTORY_H
30 #define FACTORY_H
31 
32 #include <map>
33 #include <deque>
34 #include "individual.h"
35 #include "types.h"
36 #include "ttrait.h"
37 
43 class IndFactory {
44 protected:
46  std::map< trait_t, TraitPrototype* > _protoTraits;
48  std::map< trait_t, int > _TraitsIndex;
49 
52 
54  std::deque<Individual*> RecyclingPOOL;
55 
56 public:
57 
58  IndFactory ( ) { };
59  virtual ~IndFactory ( );
60 
62  void recycle(Individual* ind)
63  { if(ind == NULL) error("IndFactory::recycle:ind is NULL!!\n"); else RecyclingPOOL.push_back(ind); }
64 
67  { for(unsigned int i=0; i < RecyclingPOOL.size(); ++i) delete RecyclingPOOL[i]; RecyclingPOOL.clear(); }
68 
73  void makePrototype (map< trait_t,TraitPrototype* > TTlist);
74 
76  void clearPrototype ( );
77 
79  Individual* getPrototypeClone ( ) {return _protoIndividual.clone();}
80 
86 
97  Individual* makeNewIndividual (Individual* mother, Individual* father, sex_t sex, unsigned short homepatch);
98 
106  Individual* makeOffsprg (Individual* mother, Individual* father, sex_t sex, unsigned short homepatch);
107 
110 
115 
117  std::map< trait_t,TraitPrototype* >& getTraitPrototypes ( ) {return _protoTraits;}
118 
121  int getTraitIndex (trait_t type);
122 
123 };
124 
125 #endif
126 
void recycle(Individual *ind)
Put an individual in the recycling pool.
Definition: indfactory.h:62
TraitPrototype * getTraitPrototype(trait_t type)
Accessor to a TraitPrototype.
Definition: indfactory.cc:140
std::string trait_t
Trait types.
Definition: types.h:63
IndFactory()
Definition: indfactory.h:58
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:184
void makePrototype(map< trait_t, TraitPrototype * > TTlist)
Creates the individuals prototype from the selected trait prototypes.
Definition: indfactory.cc:50
Individual * makeNewIndividual(Individual *mother, Individual *father, sex_t sex, unsigned short homepatch)
Creates an individual with pointers to parents, sex and home ID set but no genetic data...
Definition: indfactory.cc:152
std::map< trait_t, TraitPrototype * > _protoTraits
Map of the trait prototypes.
Definition: indfactory.h:46
Individual * getIndividualProtoype()
Individual prototype accessor.
Definition: indfactory.h:109
Individual * getNewIndividual()
Creates a blank individual which has to be "decorated" later.
Definition: indfactory.h:85
void clearPrototype()
Reset the trait prototypes, mostly done to unregister the genetic maps.
Definition: indfactory.cc:103
int error(const char *str,...)
Definition: output.cc:73
std::map< trait_t, TraitPrototype * > & getTraitPrototypes()
Accessor to the list of TraitPrototype's.
Definition: indfactory.h:117
sex_t
Sex types, males are always 0 and females 1!!
Definition: types.h:36
int getTraitIndex(trait_t type)
Gives the index of trait with type.
Definition: indfactory.cc:128
void purgeRecyclingPOOL()
Empty the recycling pool.
Definition: indfactory.h:66
TTrait setter.
Definition: ttrait.h:125
Definition: types.h:37
std::deque< Individual * > RecyclingPOOL
Garbage collector for unused Individual's.
Definition: indfactory.h:54
Factory of Individual, stores the individual prototype and the trait prototypes, manages the individu...
Definition: indfactory.h:43
Individual * getPrototypeClone()
Return an uninitialized copy of the individual prototype.
Definition: indfactory.h:79
Individual _protoIndividual
The individuals prototype used to create any new individual in a simulation.
Definition: indfactory.h:51
This class contains traits along with other individual information (sex, pedigree, etc. ).
Definition: individual.h:49
std::map< trait_t, int > _TraitsIndex
Table containing the index of each trait.
Definition: indfactory.h:48
virtual ~IndFactory()
Definition: indfactory.cc:36
Individual * clone()
Cloning procedure, clones all the traits present in the individual.
Definition: individual.cc:149

Generated for Nemo v2.3.0 by  doxygen 1.8.8 --
Catalogued on GSR