RobWorkProject
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
StopCriteria Class Referenceabstract

StopCriteria is a class for specifying an instant a compution should be aborted. More...

#include <StopCriteria.hpp>

Public Types

typedef rw::common::Ptr< StopCriteriaPtr
 smart pointer type to this class
 

Public Member Functions

bool stop () const
 True is returned when the computation should be stopped.
 
StopCriteria::Ptr instance () const
 A new instance of the property constructed to match the original initial state of the criteria. More...
 
virtual ~StopCriteria ()
 Destructor.
 

Static Public Member Functions

static StopCriteria::Ptr stopAfter (double time)
 Stop the computation after time seconds from now. More...
 
static StopCriteria::Ptr stopNever ()
 Never stop the computation.
 
static StopCriteria::Ptr stopNow ()
 Immediately stop the computation.
 
static StopCriteria::Ptr stopByFlag (bool *stop)
 Stop the computation when stop says so. More...
 
static StopCriteria::Ptr stopByFun (boost::function< bool()> fun)
 Stop the computation when fun says so.
 
static StopCriteria::Ptr stopCnt (int cnt)
 Stop the computation after cnt calls of the stop criteria.
 
static StopCriteria::Ptr stopEither (const std::vector< StopCriteria::Ptr > &criteria)
 Stop if either of criteria says stop.
 
static StopCriteria::Ptr stopEither (const StopCriteria::Ptr &a, const StopCriteria::Ptr &b)
 Stop if either a or b says stop.
 

Protected Member Functions

 StopCriteria ()
 Constructor.
 
virtual bool doStop () const =0
 Subclass implementation of the stop() method.
 
virtual StopCriteria::Ptr doInstance () const =0
 Subclass implementation of the instance() method.
 

Detailed Description

StopCriteria is a class for specifying an instant a compution should be aborted.

The computation determines when to stop by repeatedly polling the StopCriteria::stop() method. Therefore the stop() method should be implemented to have a very short, preferably deterministic running time.

Member Function Documentation

◆ instance()

StopCriteria::Ptr instance ( ) const

A new instance of the property constructed to match the original initial state of the criteria.

This implies, for example, that instance() called for a time criteria creates a new criteria that stops after the same amount of time that was specified for the original stop criteria.

Not all stop criteria returned are required to behave this way. For some types of stop criteria, the instances of the stop criteria will be effectively identical to the stop criteria itself.

◆ stopAfter()

static StopCriteria::Ptr stopAfter ( double  time)
static

Stop the computation after time seconds from now.

RobWork does not link with a thread library, and therefore this function is implemented by polling a timer. This makes the function relatively slow for its purpose.

◆ stopByFlag()

static StopCriteria::Ptr stopByFlag ( bool *  stop)
static

Stop the computation when stop says so.

stop must be non-null.

Ownership of stop is not taken.


The documentation for this class was generated from the following file: