X-Git-Url: https://git.dlugolecki.net.pl/?a=blobdiff_plain;f=src%2Fgene.h;h=781cd3e29d67978dc2b27e965746a1fe53a6f645;hb=5e4a04634f1d31d4c774b44184cf08d3faf4d02a;hp=499ca80643a9f5a428ae167321fa5d2089af67ac;hpb=a590537eb07fb1e7b6c4ad6fe2434f3b21d11e9d;p=genetic.git diff --git a/src/gene.h b/src/gene.h index 499ca80..781cd3e 100644 --- a/src/gene.h +++ b/src/gene.h @@ -3,19 +3,54 @@ namespace genetic { + /** + * Class representing Gene + */ template < typename Type > class Gene { protected: - Type fenotype; + /** + * Value of the Gene + * This for example can be a primitive value such as: int or double, or + * with additional changes complex struct. + */ + Type value; + + template friend class Gene; public: - Gene(Type fenotype) { - this->fenotype = fenotype; + /** + * Default constructor + */ + Gene() {} + + /** + * Class constructor, initializes Gene with default value. + */ + Gene(Type value) { + this->value = value; + } + + /** Copy constructor */ + Gene(const Gene& gene) : value(gene.value) {} + + /** + * Copy operator. + * + * @param gene Gene from which the value should be copied. + * @return Gene instance containing copied value + */ + Gene& operator=(const Gene& gene) { + this->value = gene.value; + return *this; } - Type get() { - return this->fenotype; + /** + * Allows read-only access to Gene value + */ + Type get() const { + return value; } }; } -#endif /* __GENE_H */ \ No newline at end of file +#endif /* __GENE_H */