Simbody  3.4 (development)
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.
 Custom ()
 Default constructor creates an empty handle that can be assigned to reference any Motion::Custom object.

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.

See also:
SimTK::Motion::Custom::Implementation, SimTK::Motion

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.

Default constructor creates an empty handle that can be assigned to reference any Motion::Custom object.


Member Function Documentation


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