Back to index

salome-kernel  6.5.0
Public Member Functions | Private Attributes
DESTRUCTOR_OF< TYPE > Class Template Reference

The DESTRUCTOR_OF class allows the user to program - at any moment - the destruction of an object at the end of the process. More...

#include <BasicsGenericDestructor.hxx>

List of all members.

Public Member Functions

 DESTRUCTOR_OF (TYPE &anObject)
 Programs the destruction at the end of the process, of the object anObject.
virtual void operator() (void)
 Performs the destruction of the object.
virtual ~DESTRUCTOR_OF ()

Private Attributes

TYPE * _objectPtr

Detailed Description

template<class TYPE>
class DESTRUCTOR_OF< TYPE >

The DESTRUCTOR_OF class allows the user to program - at any moment - the destruction of an object at the end of the process.

Example: the POINT ptrPoint will be destroyed at the end of the process (atexit).

POINT *ptrPoint = new POINT ;

DESTRUCTOR_OF<POINT> *ptrDestruct = new DESTRUCTOR_OF<POINT>(*ptrPoint);

Note that neither ptrPoint, nor ptrDestruct should be destroyed by the user.

The destruction object must be created dynamically because it suscribes itself in the list of destruction to be performed at the end of the process.

Definition at line 135 of file BasicsGenericDestructor.hxx.


Constructor & Destructor Documentation

template<class TYPE>
DESTRUCTOR_OF< TYPE >::DESTRUCTOR_OF ( TYPE &  anObject) [inline]

Programs the destruction at the end of the process, of the object anObject.

This method records in _objectPtr the address of an object to be destroyed at the end of the process

Definition at line 143 of file BasicsGenericDestructor.hxx.

                               :
    _objectPtr(&anObject)
  {
    DEVTRACE(" DESTRUCTOR_OF " << typeid(anObject).name() 
             << " " << _objectPtr << " " << this );
    PROTECTED_DELETE::addObj(_objectPtr);
    assert(GENERIC_DESTRUCTOR::Add(*this) >= 0);
  }
template<class TYPE>
virtual DESTRUCTOR_OF< TYPE >::~DESTRUCTOR_OF ( ) [inline, virtual]

Definition at line 167 of file BasicsGenericDestructor.hxx.

  {
    DEVTRACE("~DESTRUCTOR_OF() " << this);
    assert(!_objectPtr);
  }

Member Function Documentation

template<class TYPE>
virtual void DESTRUCTOR_OF< TYPE >::operator() ( void  ) [inline, virtual]

Performs the destruction of the object.

This method really destroys the object pointed by _objectPtr. It should be called at the end of the process (i.e. at exit).

Definition at line 157 of file BasicsGenericDestructor.hxx.

  {
    if (_objectPtr)
      {
        DEVTRACE("DESTRUCTOR_OF<>::operator() " << _objectPtr);
        if (_objectPtr) PROTECTED_DELETE::deleteInstance(_objectPtr);
        _objectPtr = NULL;
      }
  }

Member Data Documentation

template<class TYPE>
TYPE* DESTRUCTOR_OF< TYPE >::_objectPtr [private]

Definition at line 174 of file BasicsGenericDestructor.hxx.


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