Open CASCADE Technology 6.6.0
Data Structures | Public Member Functions | Static Public Member Functions
NCollection_Handle< T > Class Template Reference

Purpose: This template class is used to define Handle adaptor for allocated dynamically objects of arbitrary type. More...

#include <NCollection_Handle.hxx>

Inheritance diagram for NCollection_Handle< T >:
Inheritance graph
[legend]

Data Structures

class  Ptr
 Internal adaptor class wrapping actual type and enhancing it by reference counter inherited from Standard_Transient.

Public Member Functions

 NCollection_Handle ()
 Default constructor; creates null handle.
 NCollection_Handle (T *theObject)
 Constructor of handle from pointer on newly allocated object.
T * operator-> ()
 Cast handle to contained type.
const T * operator-> () const
 Cast handle to contained type.
T & operator* ()
 Cast handle to contained type.
const T & operator* () const
 Cast handle to contained type.

Static Public Member Functions

static NCollection_Handle< T > DownCast (const Handle< Standard_Transient > &theOther)
 Downcast arbitrary Handle to the argument type if contained object is Handle for this type; returns null otherwise.

Detailed Description

template<class T>
class NCollection_Handle< T >

The advantage is that this handle will automatically destroy the object when last referred Handle is destroyed (i.e. it is a typical smart pointer), and that it can be handled as Handle(Standard_Transient) in OCCT components.

Use it as follows:

NCollection_Handle<T> aPtr = new T (...);

aPtr->Method(...);

Handle(Standard_Transient) aBase = aPtr; if ( aBase->IsKind(STANDARD_TYPE(NCollection_Handle)) ) { NCollection_Handle<T> aPtr2 = NCollection_Handle<T>::DownCast (aBase); if ( ! aPtr2.IsNull() ) aPtr2->Method2(); }


Constructor & Destructor Documentation

template<class T>
NCollection_Handle< T >::NCollection_Handle ( ) [inline]
template<class T>
NCollection_Handle< T >::NCollection_Handle ( T *  theObject) [inline]

Member Function Documentation

template<class T>
static NCollection_Handle<T> NCollection_Handle< T >::DownCast ( const Handle< Standard_Transient > &  theOther) [inline, static]
template<class T>
const T& NCollection_Handle< T >::operator* ( ) const [inline]
template<class T>
T& NCollection_Handle< T >::operator* ( ) [inline]
template<class T>
T* NCollection_Handle< T >::operator-> ( ) [inline]
template<class T>
const T* NCollection_Handle< T >::operator-> ( ) const [inline]

The documentation for this class was generated from the following file:
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines