Improve comments and documentation.
[genetic.git] / src / 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 using namespace std;
10
11 namespace genetic {
12     /**
13      * Class representing Generation of given Chromosomes.
14      */
15     template < typename _Chromosome >
16     class Generation {
17     protected:
18         /**
19          * Chromosomes in the given Generation
20          */
21         vector<_Chromosome> chromosomes;
22
23     public:
24         /**
25          * Default constructor
26          */
27         Generation() {}
28
29         /**
30          * Class constructor. Initializes generation with the given chromosomes
31          *
32          * @param chromosomes vector containing Chromosomes to use in Generation
33          */
34         Generation(vector<_Chromosome> chromosomes) {
35             this->chromosomes = chromosomes;
36         }
37
38         /** Copy constructor */
39         Generation(const Generation& generation)
40             : chromosomes(generation.get()) {
41         }
42
43         /**
44          * Allows read-only access to Generation Chromosomes
45          */
46         vector<_Chromosome> get() const {
47             return this->chromosomes;
48         }
49
50         /**
51          * Copy operator.
52          *
53          * @param generation Generation from which the Chromosomes should be copied.
54          * @return Generation instance containing copied Chromosomes
55          */
56         Generation& operator=(const Generation& generation){
57             this->chromosomes = generation.get();
58             return *this;
59         }
60     };
61 }
62
63 #endif /* __GENERATION_H */