SO3Engine
Public Types | Public Member Functions | List of all members
OgreNewt::_DestructorCallback< DerivedClass > Class Template Reference

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)
 

Detailed Description

template<class DerivedClass>
class OgreNewt::_DestructorCallback< DerivedClass >

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.

Member Typedef Documentation

◆ DestructorCallbackFunction

template<class DerivedClass >
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

Warning
the pointer to the destroyed class instance is already invalid (the class is already destroyed!)

Definition at line 101 of file OgreNewt_Prerequisites.h.

Constructor & Destructor Documentation

◆ _DestructorCallback()

template<class DerivedClass >
OgreNewt::_DestructorCallback< DerivedClass >::_DestructorCallback ( )
inline

constructor

Definition at line 104 of file OgreNewt_Prerequisites.h.

◆ ~_DestructorCallback()

template<class DerivedClass >
virtual OgreNewt::_DestructorCallback< DerivedClass >::~_DestructorCallback ( )
inlinevirtual

destructor

Definition at line 107 of file OgreNewt_Prerequisites.h.

Member Function Documentation

◆ removeDestructorCallback()

template<class DerivedClass >
void OgreNewt::_DestructorCallback< DerivedClass >::removeDestructorCallback ( )
inline

remove any destructor callback

Definition at line 114 of file OgreNewt_Prerequisites.h.

◆ setDestructorCallback() [1/2]

template<class DerivedClass >
void OgreNewt::_DestructorCallback< DerivedClass >::setDestructorCallback ( DestructorCallbackFunction  fun)
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.

◆ setDestructorCallback() [2/2]

template<class DerivedClass >
template<class c >
void OgreNewt::_DestructorCallback< DerivedClass >::setDestructorCallback ( std::function< void(c *, DerivedClass *)>  callback,
c *  instancedClassPointer 
)
inline

Definition at line 134 of file OgreNewt_Prerequisites.h.


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