Loader< T > Class Template Reference
This class provides methods for loading an object from a library and destroying it. More...
#include <Loader.h>
Static Public Member Functions | |
| static void | deleteObject (T *obj) |
| static T * | createObject (XMLNode *xml) |
Private Member Functions | |
| typedef T * | _create_w (XMLNode *) |
| typedef void | _destroy_w (T *) |
Private Attributes | |
| _destroy_w * | clean |
| void * | lib |
Detailed Description
template<typename T>
class Loader< T >
This class provides methods for loading an object from a library and destroying it.
Creating objects directly out of a library is not possible. So two factory-methods are used:
- One for creating a new object, which simply calls the constructor.
- One for destructing an object. Each object stores a pointer to this factory-method, because only this method can destroy the object without crashes.
This kind of object, which has been loaded from a library, has been named "loaded-object".
It is improtant to declare a virtual destructor in each class, which uses this class as superclass. Without this virtual destructor, the programm may crash during deletion of a loaded-object.
- Date:
- 3rd of May 2007
Member Function Documentation
| typedef void Loader< T >::_destroy_w | ( | T * | ) | [private] |
This method creates and returns a loaded-object out of a library. The library-filename and the classname must be defined in the XML-Node, which is wrapped in the XMLNode -object. The used library must be of type "shared object", must provide the two factory-methods and of course the class.
- Parameters:
-
xml Pass an XMLNode -object focusing on the correct XML-node.
- Returns:
- This method returns an instance of a loaded-object or NULL in case of an error.
| static void Loader< T >::deleteObject | ( | T * | obj | ) | [inline, static] |
This method is used to destroy a loaded-object. Do not delete an loaded-object with delete!
- Parameters:
-
obj This pointer must point to the loaded-object, which should be deleted.
Member Data Documentation
The documentation for this class was generated from the following file:
- tools/libraries/3DMenu/core/Loader.h
Generated on Wed Oct 20 16:11:58 2010 for inVRs by
1.5.8