SO3Engine
|
helper class: OgreNewt-classes can derive from this class to implement a destructor-callback More...
#include <OgreNewt_Prerequisites.h>
Public Types | |
typedef std::function< void(DerivedClass *)> | DestructorCallbackFunction |
destructor callback | |
Public Member Functions | |
_DestructorCallback () | |
constructor | |
virtual | ~_DestructorCallback () |
destructor | |
void | removeDestructorCallback () |
remove any destructor callback | |
void | setDestructorCallback (DestructorCallbackFunction fun) |
set the destructor callback | |
template<class c > | |
void | setDestructorCallback (std::function< void(c *, DerivedClass *)> callback, c *instancedClassPointer) |
helper class: OgreNewt-classes can derive from this class to implement a destructor-callback
Consider the following example: You delete a body thats part of joint, so newton deletes the joint, then you could still have a pointer to that joint. Using this pointer will fail, thats why you need a way to get to know, when an object gets deleted...
Definition at line 93 of file OgreNewt_Prerequisites.h.
typedef std::function<void(DerivedClass*)> OgreNewt::_DestructorCallback< DerivedClass >::DestructorCallbackFunction |
destructor callback
This function is called, when the object is destroyed. It's only argument is a pointer to the instance currently destroyed
Definition at line 101 of file OgreNewt_Prerequisites.h.
|
inline |
constructor
Definition at line 104 of file OgreNewt_Prerequisites.h.
|
inlinevirtual |
destructor
Definition at line 107 of file OgreNewt_Prerequisites.h.
|
inline |
remove any destructor callback
Definition at line 114 of file OgreNewt_Prerequisites.h.
|
inline |
set the destructor callback
This specifies a custom callback that's called when this class is destroyed. If you are using a standard non-member function, or a static member function, you can simply pass a pointer to the function here.. like this: setDestructorCallback( &myCallbackFunction );
If you want to bind to a class member, you also need to pass a pointer to the class itself, using the std::bind system, like so: setDestructorCallback( std::bind( &MyClass::myCallback, (MyClass*)classInstance, std::placeholders::_1 ) ); (from outside the class) or: setDestructorCallback( std::bind( &MyClass::myCallback, this, std::placeholders::_1 ) ); (from inside the class).
You can also use: setDestructorCallback<>( &MyClass::myCallback, (MyClass*)classInstance ); (from outside the class) or: setDestructorCallback<>( &MyClass::myCallback, this ); (from inside the class). Note: Notice the "<>" after the function name.
Definition at line 133 of file OgreNewt_Prerequisites.h.
|
inline |
Definition at line 134 of file OgreNewt_Prerequisites.h.