Rename GenerationLimit to GenerationLimitCondition. Add test for this class.
[genetic.git] / src / gene.h
index 9786587d3d5409cf1ed0ab0a2e7996a495c600de..781cd3e29d67978dc2b27e965746a1fe53a6f645 100644 (file)
@@ -4,26 +4,49 @@
 namespace genetic {
 
     /**
-     * Gene.
+     * 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<typename> 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.get()) {}
+        Gene(const Gene& gene) : value(gene.value) {}
 
-        Gene& operator=(const Gene&){
+        /**
+         * 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;
         }