ECF 1.5
TermMaxTimeOp.cpp
1#include "ECF_base.h"
2#include "TermMaxTimeOp.h"
3
4
6{
7 uint *value = new uint(0);
8 state->getRegistry()->registerEntry("term.maxtime", (voidP) value, ECF::UINT,
9 "max number of seconds to run (default: none)");
10}
11
12
13bool TermMaxTimeOp::initialize(StateP state)
14{
15 if(!state->getRegistry()->isModified("term.maxtime"))
16 return false;
17
18 voidP sptr = state->getRegistry()->getEntry("term.maxtime");
19 maxTime_ = *((uint*) sptr.get());
20
21 return true;
22}
23
24
25bool TermMaxTimeOp::operate(StateP state)
26{
27 if(state->getElapsedTime() > maxTime_) {
28 state->setTerminateCond();
29 ECF_LOG(state, 1, "Termination: designated time elapsed. (" + uint2str(maxTime_) + " seconds)");
30 }
31
32 return true;
33}
bool operate(StateP)
perform the designated operation
void registerParameters(StateP)
Register parameters with the Registry. Called before Operator::initialize.
bool initialize(StateP)
Perform initialization. Called before Operator::operate. By default, if the return value is false,...