Public Member Functions | Private Attributes | List of all members
SurgSim::Physics::ComputationGroup Class Reference

Implements a mechanism to group and loop computations, the computations will be called in sequence repeatedly until one of the exit criteria is met. More...

#include <SurgSim/Physics/ComputationGroup.h>

Inheritance diagram for SurgSim::Physics::ComputationGroup:
SurgSim::Physics::Computation

Public Member Functions

 ComputationGroup (bool copyState)
 Constructor. More...
 
 ~ComputationGroup ()
 Destructor. More...
 
 SURGSIM_CLASSNAME (SurgSim::Physics::ComputationGroup)
 
std::shared_ptr< PhysicsManagerStatedoUpdate (const double &dt, const std::shared_ptr< PhysicsManagerState > &state) override
 Override this function to implement the computations specific behavior. More...
 
virtual bool endIteration ()
 Override this function to implement a custom criterion to exit this computation, when this returns true the computation will exit and return the last state. More...
 
void addComputation (const std::shared_ptr< Computation > &computation)
 Adds a computation to this group, the computation will be appended at the end. More...
 
std::vector< std::shared_ptr< Computation > > getComputations () const
 
void setComputations (const std::vector< std::shared_ptr< Computation >> &val)
 
size_t getIterations ()
 
- Public Member Functions inherited from SurgSim::Physics::Computation
 Computation (bool doCopyState)
 Constructor. More...
 
virtual ~Computation ()
 Destructor. More...
 
std::shared_ptr< PhysicsManagerStateupdate (double dt, const std::shared_ptr< PhysicsManagerState > &state)
 Public Interface execute this objects computations, dt is the time from the last update call in seconds. More...
 
void setDoCopyState (bool val)
 Sets up whether the computation will copy the state of PhysicsManagerState before executing. More...
 
bool isCopyingState ()
 Query if this object is copying the PhysicsManagerState. More...
 
virtual std::string getClassName () const =0
 The class name for this class. More...
 
Framework::TimergetTimer ()
 Provides access to the update timer. More...
 

Private Attributes

size_t m_iterations
 
boost::mutex m_computationsMutex
 
std::vector< std::shared_ptr< Computation > > m_computations
 

Additional Inherited Members

Detailed Description

Implements a mechanism to group and loop computations, the computations will be called in sequence repeatedly until one of the exit criteria is met.

That is either the endIteration() call, or shouldAbortLoop() in the

See also
PhysicsManagerState return true.

Constructor & Destructor Documentation

◆ ComputationGroup()

SurgSim::Physics::ComputationGroup::ComputationGroup ( bool  copyState)
explicit

Constructor.

◆ ~ComputationGroup()

SurgSim::Physics::ComputationGroup::~ComputationGroup ( )

Destructor.

Member Function Documentation

◆ addComputation()

void SurgSim::Physics::ComputationGroup::addComputation ( const std::shared_ptr< Computation > &  computation)

Adds a computation to this group, the computation will be appended at the end.

Parameters
computationthe computation to be added to this group

◆ doUpdate()

std::shared_ptr< PhysicsManagerState > SurgSim::Physics::ComputationGroup::doUpdate ( const double &  dt,
const std::shared_ptr< PhysicsManagerState > &  state 
)
overridevirtual

Override this function to implement the computations specific behavior.

Implements SurgSim::Physics::Computation.

◆ endIteration()

bool SurgSim::Physics::ComputationGroup::endIteration ( )
virtual

Override this function to implement a custom criterion to exit this computation, when this returns true the computation will exit and return the last state.

Note
the computation can also be stopped by calling setAbortLoop(true) on the physics state by any calculation
Returns
true to stop calculating.

◆ getComputations()

std::vector< std::shared_ptr< Computation > > SurgSim::Physics::ComputationGroup::getComputations ( ) const
Returns
the computations used by this class

◆ getIterations()

size_t SurgSim::Physics::ComputationGroup::getIterations ( )
Returns
the number of iterations that have passed

◆ setComputations()

void SurgSim::Physics::ComputationGroup::setComputations ( const std::vector< std::shared_ptr< Computation >> &  val)
Parameters
valset the computations used by this class

◆ SURGSIM_CLASSNAME()

SurgSim::Physics::ComputationGroup::SURGSIM_CLASSNAME ( SurgSim::Physics::ComputationGroup  )

Member Data Documentation

◆ m_computations

std::vector<std::shared_ptr<Computation> > SurgSim::Physics::ComputationGroup::m_computations
private

◆ m_computationsMutex

boost::mutex SurgSim::Physics::ComputationGroup::m_computationsMutex
mutableprivate

◆ m_iterations

size_t SurgSim::Physics::ComputationGroup::m_iterations
private

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