Computation.h
Go to the documentation of this file.
// This file is a part of the OpenSurgSim project.
// Copyright 2013, 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_COMPUTATION_H
#define SURGSIM_PHYSICS_COMPUTATION_H
#include <vector>
#include <memory>
#include "SurgSim/Framework/Timer.h"
namespace SurgSim
{
namespace Physics
{
class PhysicsManagerState;
class Computation
{
public:
explicit Computation(bool doCopyState);
virtual ~Computation();
std::shared_ptr<PhysicsManagerState> update(double dt, const std::shared_ptr<PhysicsManagerState>& state);
void setDoCopyState(bool val);
bool isCopyingState();
virtual std::string getClassName() const = 0;
Framework::Timer& getTimer();
protected:
virtual std::shared_ptr<PhysicsManagerState> doUpdate(
const double& dt,
const std::shared_ptr<PhysicsManagerState>& state) = 0;
private:
bool m_copyState;
std::shared_ptr<PhysicsManagerState> preparePhysicsState(const std::shared_ptr<PhysicsManagerState>& state);
Framework::Timer m_timer;
};
}; // Physics
}; // SurgSim
#endif // SURGSIM_PHYSICS_COMPUTATION_H
SurgSim
Definition: CompoundShapeToGraphics.cpp:29
SurgSim::Physics::Computation::~Computation
virtual ~Computation()
Destructor.
Definition: Computation.cpp:31
SurgSim::Physics::Computation::update
std::shared_ptr< PhysicsManagerState > update(double dt, const std::shared_ptr< PhysicsManagerState > &state)
Public Interface execute this objects computations, dt is the time from the last update call in secon...
Definition: Computation.cpp:36
SurgSim::Physics::Computation::getTimer
Framework::Timer & getTimer()
Provides access to the update timer.
Definition: Computation.cpp:54
SurgSim::Physics::Computation::m_timer
Framework::Timer m_timer
The update timer.
Definition: Computation.h:82
Timer.h
SurgSim::Physics::Computation::setDoCopyState
void setDoCopyState(bool val)
Sets up whether the computation will copy the state of PhysicsManagerState before executing...
Definition: Computation.cpp:44
SurgSim::Framework::Timer
Timer class, measures execution times.
Definition: Timer.h:30
SurgSim::Physics::Computation::doUpdate
virtual std::shared_ptr< PhysicsManagerState > doUpdate(const double &dt, const std::shared_ptr< PhysicsManagerState > &state)=0
Override this function to implement the computations specific behavior.
SurgSim::Physics::Computation::preparePhysicsState
std::shared_ptr< PhysicsManagerState > preparePhysicsState(const std::shared_ptr< PhysicsManagerState > &state)
Copy the PhysicsManagerState object when isCopyingState() is true.
Definition: Computation.cpp:59
SurgSim::Physics::Computation
Encapsulates a calculation over a selection of objects, needs to be subclassed to be used...
Definition: Computation.h:32
SurgSim::Physics::Computation::m_copyState
bool m_copyState
Definition: Computation.h:76
SurgSim::Physics::Computation::getClassName
virtual std::string getClassName() const =0
The class name for this class.
SurgSim::Physics::Computation::Computation
Computation(bool doCopyState)
Constructor.
Definition: Computation.cpp:26
SurgSim::Physics::Computation::isCopyingState
bool isCopyingState()
Query if this object is copying the PhysicsManagerState.
Definition: Computation.cpp:49