00001 #include "GLFitness.h" 00002 #include "GLLogicError.h" 00003 00008 template<class TFitness> 00009 GLFitness<TFitness>::GLFitness(const TFitness& value): 00010 GLBaseFitness() 00011 { 00012 setValue(value); 00013 }//Constructor 00014 00019 template<class TFitness> 00020 GLFitness<TFitness>::GLFitness(const GLFitness<TFitness>& source): 00021 GLBaseFitness() 00022 { 00023 m_value = source.m_value; 00024 }//Constructor 00025 00029 template<class TFitness> 00030 bool GLFitness<TFitness>::isEqual(const GLBaseFitness* fitness) const 00031 { 00032 //first check if another fitness can be compared with this one 00033 //in principle 00034 const GLFitness<TFitness>* fit = 00035 dynamic_cast<const GLFitness<TFitness>*>(fitness); 00036 if (fit == NULL) return false; 00037 return m_value == fit->m_value; 00038 }//isEqual 00039 00040 00046 template<class TFitness> 00047 bool GLFitness<TFitness>::isLess(const GLBaseFitness* fitness) const 00048 { 00049 //check, if 2 classes are comparable 00050 const GLFitness<TFitness>* fit = 00051 dynamic_cast<const GLFitness<TFitness>*>(fitness); 00052 if (fit == NULL) 00053 { 00054 char errormsg[1000]; 00055 sprintf(errormsg, "\nGLFitness<TFitness>::isLess\n" 00056 "Attempt to compare with not-compatible class\n"); 00057 throw GLLogicError(errormsg); 00058 } 00059 return m_value < fit->m_value; 00060 }//isLess