Simbody
|
This class can be used to define new forces. More...
#include <Force.h>
Classes | |
class | Implementation |
Public Member Functions | |
Custom (GeneralForceSubsystem &forces, Implementation *implementation) | |
Create a Custom force. | |
SimTK_INSERT_DERIVED_HANDLE_DECLARATIONS (Custom, CustomImpl, Force) | |
Protected Member Functions | |
const Implementation & | getImplementation () const |
Implementation & | updImplementation () |
This class can be used to define new forces.
To use it, create a class that extends Force::Custom::Implementation. You can then create an instance of it and pass it to the Force::Custom constructor:
Force::Custom myForce(forces, new MyForceImplementation());
Alternatively, you can create a subclass of Force::Custom which creates the Implementation itself:
class MyForce : public Force::Custom { public: MyForce(GeneralForceSubsystem& forces) : Force::Custom(forces, new MyForceImplementation()) { } }
This allows a user to simply write
MyForce(forces);
and not worry about implementation classes or creating objects on the heap. If you do this, your Force::Custom subclass must not have any data members or virtual methods. If it does, it will not work correctly. Instead, store all data in the Implementation subclass.
SimTK::Force::Custom::Custom | ( | GeneralForceSubsystem & | forces, |
Implementation * | implementation | ||
) |
Create a Custom force.
forces | the subsystem to which this force should be added |
implementation | the object which implements the custom force. The Force::Custom takes over ownership of the implementation object, and deletes it when the Force itself is deleted. |
const Implementation& SimTK::Force::Custom::getImplementation | ( | ) | const [protected] |
Implementation& SimTK::Force::Custom::updImplementation | ( | ) | [protected] |