Back to index

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

Purpose More...

#include <Utils_DESTRUCTEUR_GENERIQUE.hxx>

Inheritance diagram for DESTRUCTEUR_DE_< TYPE >:
Inheritance graph
[legend]
Collaboration diagram for DESTRUCTEUR_DE_< TYPE >:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 DESTRUCTEUR_DE_ (TYPE &objet)
virtual void operator() (void)
virtual ~DESTRUCTEUR_DE_ ()

Private Attributes

TYPE * _PtrObjet

Detailed Description

template<class TYPE>
class DESTRUCTEUR_DE_< TYPE >

Purpose

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

Usage

 In this example the POINT_ ptrPoint will be destroyed at the end of the process (atexit).

 POINT_ *ptrPoint = new POINT_ ;<BR>
 DESTRUCTEUR_DE_<POINT_> *ptrDestruction = new DESTRUCTEUR_DE_<POINT_>( *ptrPoint ) ;

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

Design description

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

Definition at line 96 of file Utils_DESTRUCTEUR_GENERIQUE.hxx.


Constructor & Destructor Documentation

template<class TYPE >
DESTRUCTEUR_DE_< TYPE >::DESTRUCTEUR_DE_ ( TYPE &  objet) [inline]

Definition at line 103 of file Utils_DESTRUCTEUR_GENERIQUE.hxx.

                              :
    _PtrObjet( &objet )
  {
    assert(DESTRUCTEUR_GENERIQUE_::Ajout( *this ) >= 0) ;
  }
template<class TYPE >
virtual DESTRUCTEUR_DE_< TYPE >::~DESTRUCTEUR_DE_ ( ) [inline, virtual]

Definition at line 134 of file Utils_DESTRUCTEUR_GENERIQUE.hxx.

                            {
    assert(!_PtrObjet) ;
  }

Member Function Documentation

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

Definition at line 113 of file Utils_DESTRUCTEUR_GENERIQUE.hxx.

                               {
    typedef PortableServer::ServantBase TServant;
    if(_PtrObjet){
      if(dynamic_cast<TServant*>(_PtrObjet)){
       // std::cerr << "WARNING: automatic destruction for servant is no more used. It's too late in exit. Use explicit call" << std::endl;
  /*
      if(TServant* aServant = dynamic_cast<TServant*>(_PtrObjet)){
        PortableServer::POA_var aPOA = aServant->_default_POA();
        PortableServer::ObjectId_var anObjectId = aPOA->servant_to_id(aServant);
        aPOA->deactivate_object(anObjectId.in());
        aServant->_remove_ref();
  */
      }else{
        //cerr << "DESTRUCTEUR_GENERIQUE_::operator() deleting _PtrObjet" << endl;
        TYPE* aPtr = static_cast<TYPE*>(_PtrObjet);
        delete aPtr;
      }
      _PtrObjet = NULL ;
    }
  } 

Member Data Documentation

template<class TYPE >
TYPE* DESTRUCTEUR_DE_< TYPE >::_PtrObjet [private]

Definition at line 139 of file Utils_DESTRUCTEUR_GENERIQUE.hxx.


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