Remove some not used namespace declarations.
[genetic.git] / include / generation.h
1 #ifndef __GENERATION_H
2 #define __GENERATION_H
3
4 #include <vector>
5
6 #include "gene.h"
7 #include "chromosome.h"
8
9 namespace genetic {
10     /**
11      * Class representing Generation of given Chromosomes.
12      */
13     template < typename _Chromosome >
14     class Generation {
15     protected:
16         /**
17          * Chromosomes in the given Generation
18          */
19         std::vector<_Chromosome> chromosomes;
20
21         template<typename> friend class Generation;
22     public:
23         /**
24          * Default constructor
25          */
26         Generation() {}
27
28         /**
29          * Class constructor. Initializes generation with the given chromosomes
30          *
31          * @param chromosomes vector containing Chromosomes to use in Generation
32          */
33         Generation(const std::vector<_Chromosome>& chromosomes) {
34             this->chromosomes = chromosomes;
35         }
36
37         /** Copy constructor */
38         Generation(const Generation& generation)
39             : chromosomes(generation.chromosomes) {
40         }
41
42         /**
43          * Copy operator.
44          *
45          * @param generation Generation from which the Chromosomes should be copied.
46          * @return Generation instance containing copied Chromosomes
47          */
48         Generation& operator=(const Generation& generation){
49             this->chromosomes = generation.chromosomes;
50             return *this;
51         }
52
53         /**
54          * Returns number of Chromosomes in current Generation
55          *
56          * @return number of Chromosomes in current Generation
57          */
58         unsigned int size() const {
59             return this->chromosomes.size();
60         }
61
62         /**
63          * Returns i-th Chromosome in the current Generation
64          *
65          * @return i-th Chromosome in the current Generation
66          */
67         _Chromosome& operator[](const unsigned int i) {
68             return this->chromosomes[i];
69         }
70     };
71 }
72
73 #endif /* __GENERATION_H */