Simbody
Classes | Public Member Functions | Protected Member Functions

SimTK::Force::Custom Class Reference

This class can be used to define new forces. More...

#include <Force.h>

Inheritance diagram for SimTK::Force::Custom:

List of all members.

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 ImplementationgetImplementation () const
ImplementationupdImplementation ()

Detailed Description

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.


Constructor & Destructor Documentation

Create a Custom force.

Parameters:
forcesthe subsystem to which this force should be added
implementationthe 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.

Member Function Documentation

SimTK::Force::Custom::SimTK_INSERT_DERIVED_HANDLE_DECLARATIONS ( Custom  ,
CustomImpl  ,
Force   
)
const Implementation& SimTK::Force::Custom::getImplementation ( ) const [protected]
Implementation& SimTK::Force::Custom::updImplementation ( ) [protected]

The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines