ComputationGroup.h
Go to the documentation of this file.
1 // This file is a part of the OpenSurgSim project.
2 // Copyright 2013-2016, SimQuest Solutions Inc.
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 
16 #ifndef SURGSIM_PHYSICS_COMPUTATIONGROUP_H
17 #define SURGSIM_PHYSICS_COMPUTATIONGROUP_H
18 
21 
22 #include <boost/thread.hpp>
23 
24 namespace SurgSim
25 {
26 
27 namespace Physics
28 {
29 
34 {
35 public:
37  explicit ComputationGroup(bool copyState);
38 
41 
43 
44  std::shared_ptr<PhysicsManagerState> doUpdate(const double& dt,
45  const std::shared_ptr<PhysicsManagerState>& state) override;
46 
51  virtual bool endIteration();
52 
55  void addComputation(const std::shared_ptr<Computation>& computation);
56 
58  std::vector<std::shared_ptr<Computation>> getComputations() const;
59 
61  void setComputations(const std::vector<std::shared_ptr<Computation>>& val);
62 
64  size_t getIterations();
65 
66 private:
67  size_t m_iterations;
68 
69  mutable boost::mutex m_computationsMutex;
70 
71  std::vector<std::shared_ptr<Computation>> m_computations;
72 
73 
74 };
75 
76 }
77 }
78 
79 #endif
Computation.h
Macros.h
SurgSim::Physics::ComputationGroup::m_computations
std::vector< std::shared_ptr< Computation > > m_computations
Definition: ComputationGroup.h:71
SurgSim::Physics::ComputationGroup::m_computationsMutex
boost::mutex m_computationsMutex
Definition: ComputationGroup.h:69
SurgSim::Physics::ComputationGroup::m_iterations
size_t m_iterations
Definition: ComputationGroup.h:67
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
SurgSim
Definition: CompoundShapeToGraphics.cpp:29
SurgSim::Physics::ComputationGroup::getIterations
size_t getIterations()
Definition: ComputationGroup.cpp:87
SurgSim::Physics::ComputationGroup::ComputationGroup
ComputationGroup(bool copyState)
Constructor.
Definition: ComputationGroup.cpp:25
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::getComputations
std::vector< std::shared_ptr< Computation > > getComputations() const
Definition: ComputationGroup.cpp:75
SurgSim::Physics::ComputationGroup::~ComputationGroup
~ComputationGroup()
Destructor.
Definition: ComputationGroup.cpp:31
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::SURGSIM_CLASSNAME
SURGSIM_CLASSNAME(SurgSim::Physics::ComputationGroup)
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::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::setComputations
void setComputations(const std::vector< std::shared_ptr< Computation >> &val)
Definition: ComputationGroup.cpp:81