diff options
Diffstat (limited to 'src/population.h')
-rw-r--r-- | src/population.h | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/population.h b/src/population.h index 0fdad32..c2d1bec 100644 --- a/src/population.h +++ b/src/population.h | |||
@@ -1,13 +1,49 @@ | |||
1 | #ifndef GENETIC_POPULATION_H | 1 | #ifndef GENETIC_POPULATION_H |
2 | #define GENETIC_POPULATION_H | 2 | #define GENETIC_POPULATION_H |
3 | 3 | ||
4 | #include <bu/string.h> | ||
5 | #include <bu/hash.h> | ||
6 | #include <bu/mutex.h> | ||
7 | |||
8 | #include "genetic/config.h" | ||
9 | |||
4 | namespace Genetic | 10 | namespace Genetic |
5 | { | 11 | { |
12 | class Phenotype; | ||
13 | |||
6 | class Population | 14 | class Population |
7 | { | 15 | { |
8 | public: | 16 | public: |
9 | Population(); | 17 | Population(); |
10 | virtual ~Population(); | 18 | virtual ~Population(); |
19 | |||
20 | typedef Bu::Hash<PhenotypeId, Phenotype *> PhenotypeHash; | ||
21 | typedef PhenotypeHash::iterator iterator; | ||
22 | typedef PhenotypeHash::const_iterator const_iterator; | ||
23 | |||
24 | iterator begin() { return hPhenotype.begin(); } | ||
25 | const_iterator begin() const { return hPhenotype.begin(); } | ||
26 | int getSize() const { return hPhenotype.getSize(); } | ||
27 | |||
28 | PhenotypeId addPhenotype( Phenotype *pNew ); | ||
29 | Phenotype *getPhenotype( PhenotypeId id ) | ||
30 | { return hPhenotype.get( id ); } | ||
31 | bool hasProperty( PhenotypeId id, const Bu::String &sKey ) const; | ||
32 | Bu::Variant getProperty( PhenotypeId id, const Bu::String &sKey ) const; | ||
33 | void setProperty( PhenotypeId id, const Bu::String &sKey, | ||
34 | Bu::Variant vValue ); | ||
35 | void delPhenotype( PhenotypeId id ); | ||
36 | Phenotype *takePhenotype( PhenotypeId id ); | ||
37 | void clear(); | ||
38 | |||
39 | PhenotypeId timestep(); | ||
40 | PhenotypeId time() const; | ||
41 | |||
42 | private: | ||
43 | PhenotypeId uNextId; | ||
44 | PhenotypeId uTime; | ||
45 | PhenotypeHash hPhenotype; | ||
46 | mutable Bu::Mutex mGeneral; | ||
11 | }; | 47 | }; |
12 | }; | 48 | }; |
13 | 49 | ||