xoreos  0.0.5
Public Types | Public Member Functions | Private Attributes | List of all members
Common::DisposablePtrBase< T, Deallocator > Class Template Reference

Base template class for a disposable pointer. More...

#include <disposableptr.h>

Inheritance diagram for Common::DisposablePtrBase< T, Deallocator >:
Inheritance graph
[legend]
Collaboration diagram for Common::DisposablePtrBase< T, Deallocator >:
Collaboration graph
[legend]

Public Types

typedef T ValueType
 
typedef T * PointerType
 
typedef T & ReferenceType
 

Public Member Functions

 DisposablePtrBase (PointerType o, bool d)
 
XOREOS_EXPLICIT_OPERATOR_CONV operator bool () const
 Implicit conversion operator to bool for convenience, to make checks like "if (disposablePtr) ..." possible. More...
 
 ~DisposablePtrBase ()
 
void reset (PointerType o=0)
 Resets the pointer with the new value. More...
 
PointerType get () const
 Returns the plain pointer value. More...
 
void setDisposable (bool d)
 Change the disposable flag. More...
 
void dispose ()
 Unconditionally dispose of the pointer, destroying the old object. More...
 

Private Attributes

PointerType _pointer
 
bool _dispose
 

Detailed Description

template<typename T, class Deallocator>
class Common::DisposablePtrBase< T, Deallocator >

Base template class for a disposable pointer.

Manages the pointer and allows for optional, automatic deletion through a deallocator template parameter.

Definition at line 68 of file disposableptr.h.

Member Typedef Documentation

◆ PointerType

template<typename T, class Deallocator>
typedef T* Common::DisposablePtrBase< T, Deallocator >::PointerType

Definition at line 71 of file disposableptr.h.

◆ ReferenceType

template<typename T, class Deallocator>
typedef T& Common::DisposablePtrBase< T, Deallocator >::ReferenceType

Definition at line 72 of file disposableptr.h.

◆ ValueType

template<typename T, class Deallocator>
typedef T Common::DisposablePtrBase< T, Deallocator >::ValueType

Definition at line 70 of file disposableptr.h.

Constructor & Destructor Documentation

◆ DisposablePtrBase()

template<typename T, class Deallocator>
Common::DisposablePtrBase< T, Deallocator >::DisposablePtrBase ( PointerType  o,
bool  d 
)
inlineexplicit

Definition at line 74 of file disposableptr.h.

◆ ~DisposablePtrBase()

template<typename T, class Deallocator>
Common::DisposablePtrBase< T, Deallocator >::~DisposablePtrBase ( )
inline

Definition at line 81 of file disposableptr.h.

Member Function Documentation

◆ dispose()

template<typename T, class Deallocator>
void Common::DisposablePtrBase< T, Deallocator >::dispose ( )
inline

Unconditionally dispose of the pointer, destroying the old object.

Definition at line 104 of file disposableptr.h.

Referenced by Common::MemoryWriteStreamDynamic::dispose(), and Common::MemoryWriteStreamDynamic::reserve().

Here is the caller graph for this function:

◆ get()

template<typename T, class Deallocator>
PointerType Common::DisposablePtrBase< T, Deallocator >::get ( ) const
inline

◆ operator bool()

template<typename T, class Deallocator>
XOREOS_EXPLICIT_OPERATOR_CONV Common::DisposablePtrBase< T, Deallocator >::operator bool ( ) const
inline

Implicit conversion operator to bool for convenience, to make checks like "if (disposablePtr) ..." possible.

Definition at line 79 of file disposableptr.h.

◆ reset()

template<typename T, class Deallocator>
void Common::DisposablePtrBase< T, Deallocator >::reset ( PointerType  o = 0)
inline

Resets the pointer with the new value.

The old object will be destroyed.

Definition at line 87 of file disposableptr.h.

Referenced by Common::MemoryWriteStreamDynamic::reserve().

Here is the caller graph for this function:

◆ setDisposable()

template<typename T, class Deallocator>
void Common::DisposablePtrBase< T, Deallocator >::setDisposable ( bool  d)
inline

Change the disposable flag.

Definition at line 101 of file disposableptr.h.

Referenced by Common::MemoryWriteStreamDynamic::setDisposable().

Here is the caller graph for this function:

Member Data Documentation

◆ _dispose

template<typename T, class Deallocator>
bool Common::DisposablePtrBase< T, Deallocator >::_dispose
private

◆ _pointer

template<typename T, class Deallocator>
PointerType Common::DisposablePtrBase< T, Deallocator >::_pointer
private

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