00001 #include "ECF_base.h"
00002 #include "TermMaxEvalOp.h"
00003
00004
00005 void TermMaxEvalOp::registerParameters(StateP state)
00006 {
00007 int *eval = new int(0);
00008 state->getRegistry()->registerEntry("term.eval", (voidP) eval, ECF::UINT);
00009 }
00010
00011
00012 bool TermMaxEvalOp::initialize(StateP state)
00013 {
00014 voidP sptr = state->getRegistry()->getEntry("term.eval");
00015 nEvaluations_ = *((uint*) sptr.get());
00016
00017 if(state->getRegistry()->isModified("term.eval"))
00018 return true;
00019
00020 return false;
00021 }
00022
00023
00024 bool TermMaxEvalOp::operate(StateP state)
00025 {
00026 if(state->getContext()->getEvaluations() >= nEvaluations_) {
00027 state->setTerminateCond();
00028 ECF_LOG(state, 1, "Termination: max evaluations reached (" + uint2str(nEvaluations_) + ")");
00029 }
00030
00031 return true;
00032 }