CHROMA
Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
Chroma::Handle< T > Class Template Reference

Class for counted reference semantics. More...

#include <handle.h>

Public Member Functions

 Handle (T *p=0)
 Initialize pointer with existing pointer. More...
 
 Handle (const Handle &p)
 Copy pointer (one more owner) More...
 
 ~Handle ()
 Destructor (delete value if this was the last owner) More...
 
Handleoperator= (const Handle &p)
 Assignment (unshare old and share new value) More...
 
template<typename Q >
Handle< Qcast ()
 RGE's addition. A cast function to morph the actual type. More...
 
Toperator* () const
 Access the value to which the pointer refers. More...
 
Toperator-> () const
 

Private Member Functions

void dispose ()
 

Private Attributes

Tptr
 
int * count
 

Friends

template<typename Q >
class Handle
 The cast function requires all Handles<Q> to be friends of Handle<T> More...
 

Detailed Description

template<class T>
class Chroma::Handle< T >

Class for counted reference semantics.

Holds and object, and deletes it when the last Handle to it is destroyed

Definition at line 32 of file handle.h.

Constructor & Destructor Documentation

◆ Handle() [1/2]

template<class T >
Chroma::Handle< T >::Handle ( T p = 0)
inline

Initialize pointer with existing pointer.

Requires that the pointer p is a return value of new

Definition at line 37 of file handle.h.

◆ Handle() [2/2]

template<class T >
Chroma::Handle< T >::Handle ( const Handle< T > &  p)
inline

Copy pointer (one more owner)

Definition at line 40 of file handle.h.

References Octave::count.

◆ ~Handle()

template<class T >
Chroma::Handle< T >::~Handle ( )
inline

Destructor (delete value if this was the last owner)

Definition at line 44 of file handle.h.

Member Function Documentation

◆ cast()

template<class T >
template<typename Q >
Handle<Q> Chroma::Handle< T >::cast ( )
inline

RGE's addition. A cast function to morph the actual type.

Definition at line 61 of file handle.h.

References Octave::count, and q.

Referenced by Chroma::EvenOddPrecCloverExtFieldLinOp::create().

◆ dispose()

template<class T >
void Chroma::Handle< T >::dispose ( )
inlineprivate

Definition at line 85 of file handle.h.

References Octave::count.

◆ operator*()

template<class T >
T& Chroma::Handle< T >::operator* ( ) const
inline

Access the value to which the pointer refers.

Definition at line 81 of file handle.h.

◆ operator->()

template<class T >
T* Chroma::Handle< T >::operator-> ( ) const
inline

Definition at line 82 of file handle.h.

◆ operator=()

template<class T >
Handle& Chroma::Handle< T >::operator= ( const Handle< T > &  p)
inline

Assignment (unshare old and share new value)

Definition at line 47 of file handle.h.

References Octave::count, and Chroma::p.

Friends And Related Function Documentation

◆ Handle

template<class T >
template<typename Q >
friend class Handle
friend

The cast function requires all Handles<Q> to be friends of Handle<T>

Definition at line 78 of file handle.h.

Member Data Documentation

◆ count

template<class T >
int* Chroma::Handle< T >::count
private

Definition at line 96 of file handle.h.

◆ ptr

template<class T >
T* Chroma::Handle< T >::ptr
private

Definition at line 95 of file handle.h.


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