Loader< T > Class Template Reference

This class provides methods for loading an object from a library and destroying it. More...

#include <Loader.h>

List of all members.


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
Author:
Thomas Weberndorfer

Member Function Documentation

template<typename T>
typedef T* Loader< T >::_create_w ( XMLNode  )  [private]

template<typename T>
typedef void Loader< T >::_destroy_w ( T *   )  [private]

template<typename T>
static T* Loader< T >::createObject ( XMLNode xml  )  [inline, static]

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.

template<typename T>
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

template<typename T>
_destroy_w* Loader< T >::clean [private]

template<typename T>
void* Loader< T >::lib [private]


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

Generated on Wed Oct 20 16:11:58 2010 for inVRs by doxygen 1.5.8