opensurgsim
ComputationGroup.h
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 
19 #include "SurgSim/Physics/Computation.h"
20 #include "SurgSim/Framework/Macros.h"
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 
42  SURGSIM_CLASSNAME(SurgSim::Physics::ComputationGroup);
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
Wraps glewInit() to separate the glew opengl definitions from the osg opengl definitions only imgui n...
Definition: AddRandomSphereBehavior.cpp:36
Implements a mechanism to group and loop computations, the computations will be called in sequence re...
Definition: ComputationGroup.h:33
void setComputations(const std::vector< std::shared_ptr< Computation >> &val)
Definition: ComputationGroup.cpp:81
size_t getIterations()
Definition: ComputationGroup.cpp:87
virtual bool endIteration()
Override this function to implement a custom criterion to exit this computation, when this returns tr...
Definition: ComputationGroup.cpp:70
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
ComputationGroup(bool copyState)
Constructor.
Definition: ComputationGroup.cpp:25
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
Encapsulates a calculation over a selection of objects, needs to be subclassed to be used...
Definition: Computation.h:32
~ComputationGroup()
Destructor.
Definition: ComputationGroup.cpp:31
std::vector< std::shared_ptr< Computation > > getComputations() const
Definition: ComputationGroup.cpp:75