Open CASCADE Technology  7.0.0
Public Types | Public Member Functions | Static Public Member Functions | Friends
opencascade::handle< T > Class Template Reference

Intrusive smart pointer for use with Standard_Transient class and its descendants. More...

#include <Standard_Transient.hxx>

Public Types

typedef T element_type
 STL-compliant typedef of contained type. More...
 

Public Member Functions

 handle ()
 Empty constructor. More...
 
 handle (const T *thePtr)
 Constructor from pointer to new object. More...
 
 handle (const handle &theHandle)
 Copy constructor. More...
 
 handle (handle &&theHandle)
 Move constructor. More...
 
 ~handle ()
 Destructor. More...
 
void Nullify ()
 Nullify the handle. More...
 
bool IsNull () const
 Check for being null. More...
 
void reset (T *thePtr)
 Reset by new pointer. More...
 
handleoperator= (const handle &theHandle)
 Assignment operator. More...
 
handleoperator= (const T *thePtr)
 Assignment to pointer. More...
 
handleoperator= (handle &&theHandle)
 Move operator. More...
 
const T * get () const
 STL-like cast to pointer to referred object. More...
 
T * get ()
 STL-like cast to pointer to referred object. More...
 
T * operator-> () const
 Member access operator (note non-const) More...
 
T & operator* ()
 Dereferencing operator. More...
 
const T & operator* () const
 Const dereferencing operator. More...
 
template<class T2 >
bool operator== (const handle< T2 > &theHandle) const
 Check for equality. More...
 
template<class T2 >
bool operator== (const T2 *thePtr) const
 Check for equality. More...
 
template<class T2 >
bool operator!= (const handle< T2 > &theHandle) const
 Check for inequality. More...
 
template<class T2 >
bool operator!= (const T2 *thePtr) const
 Check for inequality. More...
 
template<class T2 >
bool operator< (const handle< T2 > &theHandle) const
 Compare operator for possible use in std::map<> etc. More...
 
template<class T2 >
 Standard_DEPRECATED ("down-casting from object of the same or unrelated type is meaningless") static handle DownCast(const handle< T2 > &theObject
 For compatibility, define down casting operator from non-base type, as deprecated. More...
 

Static Public Member Functions

template<class T2 >
static std::enable_if< is_base_but_not_same< T2, T >::value, handle >::type DownCast (const handle< T2 > &theObject)
 Down casting operator from handle to base type. More...
 
template<class T2 >
static std::enable_if< is_base_but_not_same< T2, T >::value, handle >::type DownCast (const T2 *thePtr)
 Down casting operator from pointer to base type. More...
 

Friends

template<class T2 >
bool operator== (const T2 *left, const handle &right)
 Check for equality. More...
 
template<class T2 >
bool operator!= (const T2 *left, const handle &right)
 Check for inequality. More...
 

Detailed Description

template<class T>
class opencascade::handle< T >

Intrusive smart pointer for use with Standard_Transient class and its descendants.

This class is similar to boost::intrusive_ptr<>, with additional feature historically supported by Handles in OCCT: it has type conversion to const reference to handle to the base types, which allows it to be passed by reference in functions accepting reference to handle to base class.

These casts (potentially unsafe) can be disabled by defining macro OCCT_HANDLE_NOCAST; if it is defined, generalized copy constructor and assignment operators are defined allowing to initialize handle of base type from handle to derived type.

Member Typedef Documentation

template<class T >
typedef T opencascade::handle< T >::element_type

STL-compliant typedef of contained type.

Constructor & Destructor Documentation

template<class T >
opencascade::handle< T >::handle ( )
inline

Empty constructor.

template<class T >
opencascade::handle< T >::handle ( const T *  thePtr)
inline

Constructor from pointer to new object.

template<class T >
opencascade::handle< T >::handle ( const handle< T > &  theHandle)
inline

Copy constructor.

template<class T >
opencascade::handle< T >::handle ( handle< T > &&  theHandle)
inline

Move constructor.

template<class T >
opencascade::handle< T >::~handle ( )
inline

Destructor.

Member Function Documentation

template<class T >
template<class T2 >
static std::enable_if<is_base_but_not_same<T2, T>::value, handle>::type opencascade::handle< T >::DownCast ( const handle< T2 > &  theObject)
inlinestatic

Down casting operator from handle to base type.

template<class T >
template<class T2 >
static std::enable_if<is_base_but_not_same<T2, T>::value, handle>::type opencascade::handle< T >::DownCast ( const T2 *  thePtr)
inlinestatic

Down casting operator from pointer to base type.

template<class T >
const T* opencascade::handle< T >::get ( ) const
inline

STL-like cast to pointer to referred object.

template<class T >
T* opencascade::handle< T >::get ( )
inline

STL-like cast to pointer to referred object.

template<class T >
bool opencascade::handle< T >::IsNull ( ) const
inline

Check for being null.

template<class T >
void opencascade::handle< T >::Nullify ( )
inline

Nullify the handle.

template<class T >
template<class T2 >
bool opencascade::handle< T >::operator!= ( const handle< T2 > &  theHandle) const
inline

Check for inequality.

template<class T >
template<class T2 >
bool opencascade::handle< T >::operator!= ( const T2 *  thePtr) const
inline

Check for inequality.

template<class T >
T& opencascade::handle< T >::operator* ( )
inline

Dereferencing operator.

template<class T >
const T& opencascade::handle< T >::operator* ( ) const
inline

Const dereferencing operator.

template<class T >
T* opencascade::handle< T >::operator-> ( ) const
inline

Member access operator (note non-const)

template<class T >
template<class T2 >
bool opencascade::handle< T >::operator< ( const handle< T2 > &  theHandle) const
inline

Compare operator for possible use in std::map<> etc.

template<class T >
handle& opencascade::handle< T >::operator= ( const handle< T > &  theHandle)
inline

Assignment operator.

template<class T >
handle& opencascade::handle< T >::operator= ( const T *  thePtr)
inline

Assignment to pointer.

template<class T >
handle& opencascade::handle< T >::operator= ( handle< T > &&  theHandle)
inline

Move operator.

template<class T >
template<class T2 >
bool opencascade::handle< T >::operator== ( const handle< T2 > &  theHandle) const
inline

Check for equality.

template<class T >
template<class T2 >
bool opencascade::handle< T >::operator== ( const T2 *  thePtr) const
inline

Check for equality.

template<class T >
void opencascade::handle< T >::reset ( T *  thePtr)
inline

Reset by new pointer.

template<class T >
template<class T2 >
opencascade::handle< T >::Standard_DEPRECATED ( "down-casting from object of the same or unrelated type is meaningless"  ) const

For compatibility, define down casting operator from non-base type, as deprecated.

Friends And Related Function Documentation

template<class T >
template<class T2 >
bool operator!= ( const T2 *  left,
const handle< T > &  right 
)
friend

Check for inequality.

template<class T >
template<class T2 >
bool operator== ( const T2 *  left,
const handle< T > &  right 
)
friend

Check for equality.


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