diff --git a/eo/src/eoCombinedContinue.h b/eo/src/eoCombinedContinue.h index 157ca3fa..aff47ce5 100644 --- a/eo/src/eoCombinedContinue.h +++ b/eo/src/eoCombinedContinue.h @@ -28,31 +28,52 @@ #include /** -Fitness continuation: - + Combined continuators - logical AND: Continues until one of the embedded continuators says halt! + +20/11/00 MS: Changed the 2-continuator construct to a vector > + to be consistent with other Combined constructs + and allow to easily handle more than 2 continuators */ + template< class EOT> class eoCombinedContinue: public eoContinue { public: - /// Define Fitness - typedef typename EOT::Fitness FitnessType; + /// Define Fitness + typedef typename EOT::Fitness FitnessType; - /// Ctor - eoCombinedContinue( eoContinue& _arg1, eoContinue& _arg2) - : eoContinue (), arg1(_arg1), arg2(_arg2) {}; + /// Ctor + eoCombinedContinue( eoContinue& _cont) + : eoContinue () + { + continuators.push_back(&_cont); + } - /** Returns false when one of the embedded continuators say so (logical and) - */ - virtual bool operator() ( const eoPop& _pop ) - { - return arg1(_pop) && arg2(_pop); - } + /// Ctor - for historical reasons ... should disspear some day + eoCombinedContinue( eoContinue& _cont1, eoContinue& _cont2) + : eoContinue () + { + continuators.push_back(&_cont1); + continuators.push_back(&_cont2); + } + + void add(eoContinue & _cont) + { + continuators.push_back(&_cont); + } + + /** Returns false when one of the embedded continuators say so (logical and) + */ + virtual bool operator() ( const eoPop& _pop ) + { + for (unsigned i = 0; i < continuators.size(); ++i) + if ( !(*continuators[i])(_pop) ) return false; + return true; + } private: - eoContinue& arg1; - eoContinue& arg2; + std::vector*> continuators; }; #endif