ComputationGroup.h
Go to the documentation of this file.
// This file is a part of the OpenSurgSim project.
// Copyright 2013-2016, SimQuest Solutions Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef SURGSIM_PHYSICS_COMPUTATIONGROUP_H
#define SURGSIM_PHYSICS_COMPUTATIONGROUP_H
#include "SurgSim/Physics/Computation.h"
#include "SurgSim/Framework/Macros.h"
#include <boost/thread.hpp>
namespace SurgSim
{
namespace Physics
{
class ComputationGroup : public Computation
{
public:
explicit ComputationGroup(bool copyState);
~ComputationGroup();
SURGSIM_CLASSNAME(SurgSim::Physics::ComputationGroup);
std::shared_ptr<PhysicsManagerState> doUpdate(const double& dt,
const std::shared_ptr<PhysicsManagerState>& state) override;
virtual bool endIteration();
void addComputation(const std::shared_ptr<Computation>& computation);
std::vector<std::shared_ptr<Computation>> getComputations() const;
void setComputations(const std::vector<std::shared_ptr<Computation>>& val);
size_t getIterations();
private:
size_t m_iterations;
mutable boost::mutex m_computationsMutex;
std::vector<std::shared_ptr<Computation>> m_computations;
};
}
}
#endif
SurgSim
Definition: CompoundShapeToGraphics.cpp:29
SurgSim::Physics::ComputationGroup
Implements a mechanism to group and loop computations, the computations will be called in sequence re...
Definition: ComputationGroup.h:33
SurgSim::Physics::ComputationGroup::setComputations
void setComputations(const std::vector< std::shared_ptr< Computation >> &val)
Definition: ComputationGroup.cpp:81
SurgSim::Physics::ComputationGroup::getIterations
size_t getIterations()
Definition: ComputationGroup.cpp:87
SurgSim::Physics::ComputationGroup::endIteration
virtual bool endIteration()
Override this function to implement a custom criterion to exit this computation, when this returns tr...
Definition: ComputationGroup.cpp:70
SurgSim::Physics::ComputationGroup::addComputation
void addComputation(const std::shared_ptr< Computation > &computation)
Adds a computation to this group, the computation will be appended at the end.
Definition: ComputationGroup.cpp:64
SurgSim::Physics::ComputationGroup::SURGSIM_CLASSNAME
SURGSIM_CLASSNAME(SurgSim::Physics::ComputationGroup)
SurgSim::Physics::ComputationGroup::m_iterations
size_t m_iterations
Definition: ComputationGroup.h:67
SurgSim::Physics::ComputationGroup::ComputationGroup
ComputationGroup(bool copyState)
Constructor.
Definition: ComputationGroup.cpp:25
SurgSim::Physics::ComputationGroup::doUpdate
std::shared_ptr< PhysicsManagerState > doUpdate(const double &dt, const std::shared_ptr< PhysicsManagerState > &state) override
Override this function to implement the computations specific behavior.
Definition: ComputationGroup.cpp:36
Macros.h
SurgSim::Physics::ComputationGroup::m_computationsMutex
boost::mutex m_computationsMutex
Definition: ComputationGroup.h:69
SurgSim::Physics::Computation
Encapsulates a calculation over a selection of objects, needs to be subclassed to be used...
Definition: Computation.h:32
SurgSim::Physics::ComputationGroup::m_computations
std::vector< std::shared_ptr< Computation > > m_computations
Definition: ComputationGroup.h:71
SurgSim::Physics::ComputationGroup::~ComputationGroup
~ComputationGroup()
Destructor.
Definition: ComputationGroup.cpp:31
Computation.h
SurgSim::Physics::ComputationGroup::getComputations
std::vector< std::shared_ptr< Computation > > getComputations() const
Definition: ComputationGroup.cpp:75