X-Git-Url: https://git.dlugolecki.net.pl/?a=blobdiff_plain;f=include%2Fgene.h;fp=include%2Fgene.h;h=781cd3e29d67978dc2b27e965746a1fe53a6f645;hb=2a8fc81203107eb3495a50fb2666803fda3e0517;hp=0000000000000000000000000000000000000000;hpb=169219566d08e4940d25b66ecdb68e80b90c090d;p=genetic.git diff --git a/include/gene.h b/include/gene.h new file mode 100644 index 0000000..781cd3e --- /dev/null +++ b/include/gene.h @@ -0,0 +1,56 @@ +#ifndef __GENE_H +#define __GENE_H + +namespace genetic { + + /** + * Class representing Gene + */ + template < typename Type > + class Gene { + protected: + /** + * 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: + /** + * 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; + } + + /** + * Allows read-only access to Gene value + */ + Type get() const { + return value; + } + }; +} + +#endif /* __GENE_H */