Changed Maarten's 2-continuator construct into a vector of pointer,

as in all other Combined constructs in EO.
Kept the construtor with 2 eoCOntinue for backward compatibility.
Added of course the add method!
This commit is contained in:
evomarc 2000-11-24 17:26:22 +00:00
commit 3ec57ed93f

View file

@ -28,31 +28,52 @@
#include <eoContinue.h>
/**
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<eoContinue<EOT> >
to be consistent with other Combined constructs
and allow to easily handle more than 2 continuators
*/
template< class EOT>
class eoCombinedContinue: public eoContinue<EOT> {
public:
/// Define Fitness
typedef typename EOT::Fitness FitnessType;
/// Define Fitness
typedef typename EOT::Fitness FitnessType;
/// Ctor
eoCombinedContinue( eoContinue<EOT>& _arg1, eoContinue<EOT>& _arg2)
: eoContinue<EOT> (), arg1(_arg1), arg2(_arg2) {};
/// Ctor
eoCombinedContinue( eoContinue<EOT>& _cont)
: eoContinue<EOT> ()
{
continuators.push_back(&_cont);
}
/** Returns false when one of the embedded continuators say so (logical and)
*/
virtual bool operator() ( const eoPop<EOT>& _pop )
{
return arg1(_pop) && arg2(_pop);
}
/// Ctor - for historical reasons ... should disspear some day
eoCombinedContinue( eoContinue<EOT>& _cont1, eoContinue<EOT>& _cont2)
: eoContinue<EOT> ()
{
continuators.push_back(&_cont1);
continuators.push_back(&_cont2);
}
void add(eoContinue<EOT> & _cont)
{
continuators.push_back(&_cont);
}
/** Returns false when one of the embedded continuators say so (logical and)
*/
virtual bool operator() ( const eoPop<EOT>& _pop )
{
for (unsigned i = 0; i < continuators.size(); ++i)
if ( !(*continuators[i])(_pop) ) return false;
return true;
}
private:
eoContinue<EOT>& arg1;
eoContinue<EOT>& arg2;
std::vector<eoContinue<EOT>*> continuators;
};
#endif