Custom Class Reference

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

#include <Force.h>

Inheritance diagram for Custom:
Force PIMPLHandle< Force, ForceImpl, true > VanderWallSphere

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

Custom ( GeneralForceSubsystem forces,
Implementation implementation 
)

Create a Custom force.

Parameters:
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.

Member Function Documentation

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

The documentation for this class was generated from the following file:

Generated on Wed Dec 30 11:05:14 2009 for SimTKcore by  doxygen 1.6.1