The C++ framework for developing highly scalable, high performance servers on Windows platforms.

TReferenceCountedSmartPointer Class Template Reference
[TemplatesSmart Pointer]

Inheritance diagram for TReferenceCountedSmartPointer:
Collaboration diagram for TReferenceCountedSmartPointer:

List of all members.


Detailed Description

template<class T>
class JetByteTools::Core::TReferenceCountedSmartPointer< T >

A template smart pointer class that manages objects that support AddRef() and Release() style reference counting.

Public Types

enum  ConstructionOwnershipSemantics { TakeOwnershipOfExistingReference, CreateNewReference }

Public Member Functions

 TReferenceCountedSmartPointer ()
 Construct an empty smart pointer.
 TReferenceCountedSmartPointer (T *ref, ConstructionOwnershipSemantics semantics=TakeOwnershipOfExistingReference)
 Construct a smart pointer that takes ownership of the supplied object according to the supplied ownership semantics.
 TReferenceCountedSmartPointer (T &ref, ConstructionOwnershipSemantics semantics=TakeOwnershipOfExistingReference)
 Construct a smart pointer that takes ownership of the supplied object according to the supplied ownership semantics.
 TReferenceCountedSmartPointer (TReferenceCountedSmartPointer< T > &&rhs) noexcept
 TReferenceCountedSmartPointer (const TReferenceCountedSmartPointer< T > &rhs)
virtual
TReferenceCountedSmartPointer
operator= (TReferenceCountedSmartPointer< T > &&rhs) noexcept
virtual
TReferenceCountedSmartPointer
operator= (const TReferenceCountedSmartPointer< T > &rhs)
virtual
TReferenceCountedSmartPointer
operator= (T *ref)
 This has the same ownership semantics as TakeOwnershipOfExistingReference, we take ownership of the current reference...
virtual ~TReferenceCountedSmartPointer ()
T * operator-> ()
 Access the managed object. If JETBYTE_REFERENCE_COUNTED_SMART_POINTER_THROW_ON_NULL_REFERENCE is defined as 1 then this will throw an exception if the smart pointer is not currently managing an object!
const T * operator-> () const
 Access the managed object. If JETBYTE_REFERENCE_COUNTED_SMART_POINTER_THROW_ON_NULL_REFERENCE is defined as 1 then this will throw an exception if the smart pointer is not currently managing an object!
T * Get ()
const T * Get () const
T & GetRef ()
 Obtain a reference to the managed object. If JETBYTE_REFERENCE_COUNTED_SMART_POINTER_THROW_ON_NULL_REFERENCE is defined as 1 then this will throw an exception if the smart pointer is not currently managing an object!
const T & GetRef () const
 Obtain a reference to the managed object. If JETBYTE_REFERENCE_COUNTED_SMART_POINTER_THROW_ON_NULL_REFERENCE is defined as 1 then this will throw an exception if the smart pointer is not currently managing an object!
void SilentDetach ()
 Detach the managed object from the smart pointer. It's assumed that the object's ownership has been given to something else before this call. This smart pointer no longer owns a reference and so we a) don't return one to the caller and b) don't do any clever stuff when in debug mode.
T * Detach ()
 Detach the managed object from the smart pointer and return it to the caller. The caller now owns the object and is responsible for calling Release() on it when it is finished with it.
void Attach (T *ref, ConstructionOwnershipSemantics semantics)
void AddRef ()
 Call AddRef() on the managed object if there is one. Note that it's safe to call this on an object even if it isn't currently managing an object.
void Release ()
 Detach the managed object from the smart pointer and call release on it. Note that it's safe to call this on an object even if it isn't currently managing an object.
virtual T * SafeRelease (T *ref)

Static Public Member Functions

static T * SafeAddRef (T *ref)

Classes

class  has_ReportOwnershipChange

Member Enumeration Documentation

Enumerator:
TakeOwnershipOfExistingReference  Construct a smart pointer that takes ownership of the supplied object. The pointer does NOT call AddRef() in the constructor but DOES call Release() in the destructor.
CreateNewReference  Construct a smart pointer that takes creates a new reference to the supplied object. The pointer DOES call AddRef() in the constructor and DOES call Release() in the destructor.


Constructor & Destructor Documentation

Construct an empty smart pointer.

TReferenceCountedSmartPointer ( T *  ref,
ConstructionOwnershipSemantics  semantics = TakeOwnershipOfExistingReference 
) [inline, explicit]

Construct a smart pointer that takes ownership of the supplied object according to the supplied ownership semantics.

TReferenceCountedSmartPointer ( T &  ref,
ConstructionOwnershipSemantics  semantics = TakeOwnershipOfExistingReference 
) [inline, explicit]

Construct a smart pointer that takes ownership of the supplied object according to the supplied ownership semantics.

TReferenceCountedSmartPointer ( const TReferenceCountedSmartPointer< T > &  rhs  )  [inline]

~TReferenceCountedSmartPointer (  )  [inline, virtual]


Member Function Documentation

TReferenceCountedSmartPointer< T > & operator= ( TReferenceCountedSmartPointer< T > &&  rhs  )  [inline, virtual]

TReferenceCountedSmartPointer< T > & operator= ( const TReferenceCountedSmartPointer< T > &  rhs  )  [inline, virtual]

TReferenceCountedSmartPointer< T > & operator= ( T *  ref  )  [inline, virtual]

This has the same ownership semantics as TakeOwnershipOfExistingReference, we take ownership of the current reference...

T * operator-> (  )  [inline]

Access the managed object. If JETBYTE_REFERENCE_COUNTED_SMART_POINTER_THROW_ON_NULL_REFERENCE is defined as 1 then this will throw an exception if the smart pointer is not currently managing an object!

const T * operator-> (  )  const [inline]

Access the managed object. If JETBYTE_REFERENCE_COUNTED_SMART_POINTER_THROW_ON_NULL_REFERENCE is defined as 1 then this will throw an exception if the smart pointer is not currently managing an object!

T * Get (  )  [inline]

const T * Get (  )  const [inline]

T & GetRef (  )  [inline]

Obtain a reference to the managed object. If JETBYTE_REFERENCE_COUNTED_SMART_POINTER_THROW_ON_NULL_REFERENCE is defined as 1 then this will throw an exception if the smart pointer is not currently managing an object!

const T & GetRef (  )  const [inline]

Obtain a reference to the managed object. If JETBYTE_REFERENCE_COUNTED_SMART_POINTER_THROW_ON_NULL_REFERENCE is defined as 1 then this will throw an exception if the smart pointer is not currently managing an object!

void SilentDetach (  )  [inline]

Detach the managed object from the smart pointer. It's assumed that the object's ownership has been given to something else before this call. This smart pointer no longer owns a reference and so we a) don't return one to the caller and b) don't do any clever stuff when in debug mode.

T * Detach (  )  [inline]

Detach the managed object from the smart pointer and return it to the caller. The caller now owns the object and is responsible for calling Release() on it when it is finished with it.

void Attach ( T *  ref,
ConstructionOwnershipSemantics  semantics 
) [inline]

void AddRef (  )  [inline]

Call AddRef() on the managed object if there is one. Note that it's safe to call this on an object even if it isn't currently managing an object.

void Release (  )  [inline]

Detach the managed object from the smart pointer and call release on it. Note that it's safe to call this on an object even if it isn't currently managing an object.

T * SafeAddRef ( T *  ref  )  [inline, static]

T * SafeRelease ( T *  ref  )  [inline, virtual]


Generated on Sun Sep 12 19:08:48 2021 for The Server Framework - v7.4 by doxygen 1.5.3