Simbody
|
This class can be used to define new motions. More...
#include <Motion.h>
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 Implementation & | getImplementation () const |
Implementation & | updImplementation () |
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.
SimTK::Motion::Custom::Custom | ( | MobilizedBody & | mobod, |
Implementation * | implementation | ||
) |
Create a Custom motion.
mobod | the MobilizedBody to which this Motion should be added |
implementation | the 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. |
const Implementation& SimTK::Motion::Custom::getImplementation | ( | ) | const [protected] |
Implementation& SimTK::Motion::Custom::updImplementation | ( | ) | [protected] |