Simbody
Classes | Public Member Functions | Protected Member Functions

SimTK::Motion::Custom Class Reference

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

#include <Motion.h>

Inheritance diagram for SimTK::Motion::Custom:

List of all members.

Classes

class  Implementation
 This is the abstract base class for Custom Motion implementations. More...

Public Member Functions

 Custom (MobilizedBody &mobod, Implementation *implementation)
 Create a Custom motion.
 SimTK_INSERT_DERIVED_HANDLE_DECLARATIONS (Custom, CustomImpl, Motion)

Protected Member Functions

const ImplementationgetImplementation () const
ImplementationupdImplementation ()

Detailed Description

This class can be used to define new motions.

To use it, create a class that extends Motion::Custom::Implementation. You can then create an instance of it and pass it to the Motion::Custom constructor:

 Motion::Custom myMotion(mobod, new MyMotionImplementation());
 

Alternatively, you can create a subclass of Motion::Custom which creates the Implementation itself:

 class MyMotion : public Motion::Custom {
 public:
   MyMotion(MobilizedBody& mobod) 
     : Motion::Custom(mobod, new MyMotionImplementation()) {}
 };
 

This allows a user to simply write

 MyMotion(mobod);
 

and not worry about implementation classes or creating objects on the heap. If you do this, your Motion::Custom handle 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

SimTK::Motion::Custom::Custom ( MobilizedBody mobod,
Implementation implementation 
)

Create a Custom motion.

Parameters:
mobodthe MobilizedBody to which this Motion should be added
implementationthe object which implements the custom Motion. The Motion::Custom takes over ownership of the implementation object, and deletes it when the Motion itself is deleted.

Member Function Documentation

SimTK::Motion::Custom::SimTK_INSERT_DERIVED_HANDLE_DECLARATIONS ( Custom  ,
CustomImpl  ,
Motion   
)
const Implementation& SimTK::Motion::Custom::getImplementation ( ) const [protected]
Implementation& SimTK::Motion::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