Version: 6.3.1
Public Member Functions | Static Public Member Functions | Private Types | Private Member Functions | Private Attributes

GEOM.GenericObjPtr< TInterface > Class Template Reference

A smart pointer for the SALOME GenericObj interface. More...

#include <GEOM_GenericObjPtr.h>

Public Member Functions

 GenericObjPtr ()
 Initialize pointer to nil generic object reference.
 GenericObjPtr (TInterfacePtr theObject)
 Initialize pointer to the given generic object reference.
 GenericObjPtr (const GenericObjPtr &thePointer)
 Initialize pointer with a new reference to the same object referenced by given pointer.
 ~GenericObjPtr ()
 Destroy pointer and remove the reference to the object.
GenericObjPtroperator= (TInterfacePtr theObject)
 Assign object to reference and remove reference to an old object.
GenericObjPtroperator= (const GenericObjPtr &thePointer)
 Assign object to reference and remove reference to an old object.
bool operator== (TInterfacePtr theObject)
 Check equivalence.
bool operator== (const GenericObjPtr &thePointer)
 Check equivalence.
bool operator!= (TInterfacePtr theObject)
 Check difference.
bool operator!= (const GenericObjPtr &thePointer)
 Check difference.
TInterfacePtr operator-> () const
 Provides normal pointer target member access using operator ->.
 operator bool () const
 Check validity of the pointer.
void take (TInterfacePtr theObject)
 Initialize pointer to the given generic object reference and take ownership on it.
TInterfacePtr get () const
 Get the contained object.
TInterfacePtr copy () const
 Make the copy of the contained object and return it (caller becomes owner of the CORBA reference).
bool isNull () const
 Check if pointer is null.
void nullify ()
 Nullify pointer.
template<>
dn46 SALOME series6x631 GEOM
Mandriva2010 GEOM_SRC src
GEOMBase GEOM_GenericObjPtr
cxx bool 
isSame (GEOM::GEOM_Object_ptr theLeft, GEOM::GEOM_Object_ptr theRight)
template<>
bool GEOMBASE_EXPORT isSame (GEOM::GEOM_Object_ptr theLeft, GEOM::GEOM_Object_ptr theRight)

Static Public Member Functions

static bool isSame (TInterfacePtr theLeft, TInterfacePtr theRight)

Private Types

typedef TInterface::_var_type TInterfaceVar
typedef TInterface::_ptr_type TInterfacePtr

Private Member Functions

void Register ()
 Increment counter for the object.
void UnRegister ()
 Decrement counter for the object.

Private Attributes

TInterfaceVar myObject

Detailed Description

template<typename TInterface>
class GEOM::GenericObjPtr< TInterface >

This class can be used in conjunction with the references to the CORBA objects which interfaces are inherited from the SALOME.GenericObj CORBA interface.

The smart pointer class automatically invokes Register() / UnRegister() functions of th interface in order to prevent memory leaks and other such problems caused by improper usage of the CORBA references.

Smart pointers can be easily copied, stored within class as data members, passed to the functions requiring native CORBA reference as parameters, etc.

Usage:

Examples:

    typedef GEOM::GenericObjPtr<MyInterface> MyIPtr;
    void MyInterface_ptr foo();
    void MyInterface_ptr bar( MyInterface_ptr p );

    MyIPtr v1;                       // create empty (nil) pointer
    MyIPtr v2 = foo();               // get some CORBA reference and store it within the smart pointer
    v1 = v2;                         // copy smart pointer (reference counter is incremented)
    v2 = bar( v1.get() );            // pass smart pointer to the function
    MyInterface_var var = v2.copy(); // initialize _var variable with the smart pointer contents
    v1.take( foo() );                // take ownership on the newly created object

Member Typedef Documentation

template<typename TInterface >
typedef TInterface::_var_type GEOM.GenericObjPtr< TInterface >.TInterfaceVar [private]
template<typename TInterface >
typedef TInterface::_ptr_type GEOM.GenericObjPtr< TInterface >.TInterfacePtr [private]

Constructor & Destructor Documentation

template<typename TInterface >
GEOM.GenericObjPtr< TInterface >.GenericObjPtr ( )
template<typename TInterface >
GEOM.GenericObjPtr< TInterface >.GenericObjPtr ( TInterfacePtr  theObject)
template<typename TInterface >
GEOM.GenericObjPtr< TInterface >.GenericObjPtr ( const GenericObjPtr< TInterface > &  thePointer)
template<typename TInterface >
GEOM.GenericObjPtr< TInterface >.~GenericObjPtr ( )

Member Function Documentation

template<typename TInterface >
void GEOM.GenericObjPtr< TInterface >.Register ( ) [private]
template<typename TInterface >
void GEOM.GenericObjPtr< TInterface >.UnRegister ( ) [private]
template<typename TInterface >
GenericObjPtr& GEOM.GenericObjPtr< TInterface >.operator= ( TInterfacePtr  theObject)
template<typename TInterface >
GenericObjPtr& GEOM.GenericObjPtr< TInterface >.operator= ( const GenericObjPtr< TInterface > &  thePointer)
template<typename TInterface >
static bool GEOM.GenericObjPtr< TInterface >.isSame ( TInterfacePtr  theLeft,
TInterfacePtr  theRight 
) [static]
template<typename TInterface >
bool GEOM.GenericObjPtr< TInterface >.operator== ( TInterfacePtr  theObject)
template<typename TInterface >
bool GEOM.GenericObjPtr< TInterface >.operator== ( const GenericObjPtr< TInterface > &  thePointer)
template<typename TInterface >
bool GEOM.GenericObjPtr< TInterface >.operator!= ( TInterfacePtr  theObject)
template<typename TInterface >
bool GEOM.GenericObjPtr< TInterface >.operator!= ( const GenericObjPtr< TInterface > &  thePointer)
template<typename TInterface >
TInterfacePtr GEOM.GenericObjPtr< TInterface >.operator-> ( ) const
template<typename TInterface >
GEOM.GenericObjPtr< TInterface >.operator bool ( ) const
template<typename TInterface >
void GEOM.GenericObjPtr< TInterface >.take ( TInterfacePtr  theObject)
template<typename TInterface >
TInterfacePtr GEOM.GenericObjPtr< TInterface >.get ( ) const
template<typename TInterface >
TInterfacePtr GEOM.GenericObjPtr< TInterface >.copy ( ) const
template<typename TInterface >
bool GEOM.GenericObjPtr< TInterface >.isNull ( ) const
template<typename TInterface >
void GEOM.GenericObjPtr< TInterface >.nullify ( )
template<>
dn46 SALOME series6x631 GEOM Mandriva2010 GEOM_SRC src GEOMBase GEOM_GenericObjPtr cxx bool GEOM::GenericObjPtr< GEOM::GEOM_Object >::isSame ( GEOM::GEOM_Object_ptr  theLeft,
GEOM::GEOM_Object_ptr  theRight 
)
template<>
bool GEOMBASE_EXPORT GEOM::GenericObjPtr< GEOM::GEOM_Object >::isSame ( GEOM::GEOM_Object_ptr  theLeft,
GEOM::GEOM_Object_ptr  theRight 
)

Field Documentation

template<typename TInterface >
TInterfaceVar GEOM.GenericObjPtr< TInterface >.myObject [private]
Copyright © 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
Copyright © 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS