Remove some not used namespace declarations.
[genetic.git] / include / generator / generator.h
1 #ifndef __GENERATOR_GENERATOR_H
2 #define __GENERATOR_GENERATOR_H
3
4 #include <ctime>
5 #include <cstdlib>
6
7 #include "../gene.h"
8 #include "../chromosome.h"
9 #include "../generation.h"
10
11 using namespace std;
12
13 namespace genetic {
14     namespace generator {
15         /**
16          * Generator for generating entire Generation of Chromosomes (individuals)
17          */
18         template < typename _Chromosome >
19         class Generator {
20         public:
21             /**
22              * Type representing Chromosome Gene
23              */
24             typedef typename _Chromosome::GeneType GeneType;
25         protected:
26             /**
27              * Size of the generation to generate
28              */
29             const unsigned int generationSize;
30
31             /**
32              * Size of the chromosome to generate
33              */
34             const unsigned int chromosomeSize;
35
36             /**
37              * Breeding calculations should be done here...
38              *
39              * @return newly breeded Generation
40              */
41             virtual ::genetic::Generation<_Chromosome> do_breed() = 0;
42
43         public:
44             /**
45              * Constructor. Initializes required variables and constants
46              *
47              * @param generationSize Indicates size of the generation
48              * @param chromosomeSize Indicates size of the chromosome
49              */
50             Generator(const unsigned int generationSize, const unsigned int chromosomeSize)
51                 : generationSize(generationSize), chromosomeSize(chromosomeSize) {
52
53                 time_t t;
54                 srand((unsigned)time(&t));
55             }
56
57             /**
58              * Breeds new generation of chromosomes.
59              *
60              * @return ::genetic::Generation Generation of Chromosomes
61              */
62             ::genetic::Generation<_Chromosome> breed() {
63                 return do_breed();
64             }
65         };
66     }
67 }
68
69 #endif /* __GENERATOR_GENERATOR_H */