Open CASCADE Technology Reference Manual 8.0.0
Loading...
Searching...
No Matches
Public Types | 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]

Public Types

typedefelement_type
 
- Public Types inherited from opencascade::handle< Standard_Transient >
typedef Standard_Transient element_type
 STL-compliant typedef of contained type.
 

Public Member Functions

 NCollection_Handle ()=default
 Default constructor; creates null handle.
 
 NCollection_Handle (T *theObject)
 Constructor of handle from pointer on newly allocated object.
 
T * get () noexcept
 Cast handle to contained type.
 
const T * get () const noexcept
 Cast handle to contained type.
 
T * operator-> () noexcept
 Cast handle to contained type.
 
const T * operator-> () const noexcept
 Cast handle to contained type.
 
T & operator* () noexcept
 Cast handle to contained type.
 
const T & operator* () const noexcept
 Cast handle to contained type.
 
- Public Member Functions inherited from opencascade::handle< Standard_Transient >
 handle ()
 Empty constructor.
 
 handle (const Standard_Transient *thePtr)
 Constructor from pointer to new object.
 
 handle (const handle &theHandle)
 Copy constructor.
 
 handle (handle &&theHandle) noexcept
 Move constructor.
 
 ~handle ()
 Destructor.
 
void Nullify ()
 Nullify the handle.
 
bool IsNull () const
 Check for being null.
 
void reset (Standard_Transient *thePtr)
 Reset by new pointer.
 
handleoperator= (const handle &theHandle)
 Assignment operator.
 
handleoperator= (const Standard_Transient *thePtr)
 Assignment to pointer.
 
handleoperator= (handle &&theHandle) noexcept
 Move operator.
 
Standard_Transientget () const
 STL-like cast to pointer to referred object (note non-const).
 
Standard_Transientoperator-> () const
 Member access operator (note non-const)
 
Standard_Transientoperator* () const
 Dereferencing operator (note non-const)
 
bool operator== (const handle< T2 > &theHandle) const
 Check for equality.
 
bool operator== (const T2 *thePtr) const
 Check for equality.
 
bool operator!= (const handle< T2 > &theHandle) const
 Check for inequality.
 
bool operator!= (const T2 *thePtr) const
 Check for inequality.
 
bool operator< (const handle< T2 > &theHandle) const
 Compare operator for possible use in std::map<> etc.
 
 operator Standard_Transient *handle::* () const
 Conversion to bool-compatible type for use in conditional expressions.
 
 operator const handle< T2 > & () const
 Upcast to const reference to base type. NB: this implementation will cause ambiguity errors on calls to overloaded functions accepting handles to different types, since compatibility is checked in the cast code rather than ensured by SFINAE (possible with C++11)
 
use variable of exact type operator handle< T2 > & ()
 Upcast to non-const reference to base type. NB: this cast can be dangerous, but required for legacy code; see #26377.
 

Static Public Member Functions

static NCollection_Handle< T > DownCast (const opencascade::handle< Standard_Transient > &theOther) noexcept
 Downcast arbitrary Handle to the argument type if contained object is Handle for this type; returns null otherwise.
 
- Static Public Member Functions inherited from opencascade::handle< Standard_Transient >
static opencascade::std::enable_if< is_base_but_not_same< T2, Standard_Transient >::value, handle >::type DownCast (const handle< T2 > &theObject)
 Down casting operator from handle to base type.
 
static opencascade::std::enable_if< is_base_but_not_same< T2, Standard_Transient >::value, handle >::type DownCast (const T2 *thePtr)
 Down casting operator from pointer to base type.
 
static handle DownCast (const handle< T2 > &theObject, typename opencascade::std::enable_if<!is_base_but_not_same< T2, Standard_Transient >::value, void * >::type=0)
 For compatibility, define down casting operator from non-base type, as deprecated.
 
static handle DownCast (const T2 *thePtr, typename opencascade::std::enable_if<!is_base_but_not_same< T2, Standard_Transient >::value, void * >::type=0)
 For compatibility, define down casting operator from non-base type, as deprecated.
 

Detailed Description

template<class T>
class NCollection_Handle< T >

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

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 occ::handle<Standard_Transient> in OCCT components.

Member Typedef Documentation

◆ element_type

template<class T >
typedef T NCollection_Handle< T >::element_type

Constructor & Destructor Documentation

◆ NCollection_Handle() [1/2]

template<class T >
NCollection_Handle< T >::NCollection_Handle ( )
default

Default constructor; creates null handle.

◆ NCollection_Handle() [2/2]

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

Constructor of handle from pointer on newly allocated object.

Member Function Documentation

◆ DownCast()

template<class T >
static NCollection_Handle< T > NCollection_Handle< T >::DownCast ( const opencascade::handle< Standard_Transient > & theOther)
inlinestaticnoexcept

Downcast arbitrary Handle to the argument type if contained object is Handle for this type; returns null otherwise.

◆ get() [1/2]

template<class T >
const T * NCollection_Handle< T >::get ( ) const
inlinenoexcept

Cast handle to contained type.

◆ get() [2/2]

template<class T >
T * NCollection_Handle< T >::get ( )
inlinenoexcept

Cast handle to contained type.

◆ operator*() [1/2]

template<class T >
const T & NCollection_Handle< T >::operator* ( ) const
inlinenoexcept

Cast handle to contained type.

◆ operator*() [2/2]

template<class T >
T & NCollection_Handle< T >::operator* ( )
inlinenoexcept

Cast handle to contained type.

◆ operator->() [1/2]

template<class T >
const T * NCollection_Handle< T >::operator-> ( ) const
inlinenoexcept

Cast handle to contained type.

◆ operator->() [2/2]

template<class T >
T * NCollection_Handle< T >::operator-> ( )
inlinenoexcept

Cast handle to contained type.


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