Improve comments and documentation.
[genetic.git] / src / gene.h
1 #ifndef __GENE_H
2 #define __GENE_H
3
4 namespace genetic {
5
6     /**
7      * Class representing Gene
8      */
9     template < typename Type >
10     class Gene {
11     protected:
12         /**
13          * Value of the Gene
14          * This for example can be a primitive value such as: int or double, or
15          * with additional changes complex struct.
16          */
17         Type value;
18     public:
19         /**
20          * Default constructor
21          */
22         Gene() {}
23
24         /**
25          * Class constructor, initializes Gene with default value.
26          */
27         Gene(Type value) {
28             this->value = value;
29         }
30
31         /** Copy constructor */
32         Gene(const Gene& gene) : value(gene.get()) {}
33
34         /**
35          * Copy operator.
36          *
37          * @param gene Gene from which the value should be copied.
38          * @return Gene instance containing copied value
39          */
40         Gene& operator=(const Gene& gene) {
41             this->value = gene.get();
42             return *this;
43         }
44
45         /**
46          * Allows read-only access to Gene value
47          */
48         Type get() const {
49             return value;
50         }
51     };
52 }
53
54 #endif /* __GENE_H */