ICF 3.1.1.10
Technical documentation of ICF Libraries
istd::TOptDelPtr< Type, DelArray > Class Template Reference

Pointer wrapper providing activatable deleting pointed object during destruction. More...

#include <TOptDelPtr.h>

Inheritance diagram for istd::TOptDelPtr< Type, DelArray >:
Collaboration diagram for istd::TOptDelPtr< Type, DelArray >:

Public Types

typedef TPointerBase< Type > BaseClass
 
typedef std::function< void(Type *)> ReleaseFn
 

Public Member Functions

 TOptDelPtr (const TOptDelPtr &ptr)=delete
 
 TOptDelPtr (Type *ptr=nullptr, ReleaseFn releaseFn=nullptr)
 Construct and init this pointer.
 
 TOptDelPtr (Type *ptr, bool releaseFlag)
 Construct and init this pointer.
 
 TOptDelPtr (TOptDelPtr &&ptr)
 Move constructor.
 
 TOptDelPtr (std::unique_ptr< Type > &&ptr)
 Construct and init this pointer using unique pointer.
 
 ~TOptDelPtr ()
 Destructor.
 
bool IsToRelase () const
 Get state of release flag.
 
void Reset ()
 Remove object pointed by internal pointer and set this pointer to nullptr.
 
void SetPtr (Type *ptr, ReleaseFn releaseFn=nullptr)
 Set new value of internal pointer.
 
Type * GetFreePtr () const
 Get internal pointer only if it is free, it means will be not released.
 
Type * release ()
 Reset internal pointer value without deleting instance and return previos value.
 
void Swap (TOptDelPtr &ptr)
 Swap two pointers.
 
TOptDelPtr & operator= (const TOptDelPtr &ptr)
 Assign operator.
 
TOptDelPtr & operator= (TOptDelPtr &&ptr)
 Assign move operator.
 
TOptDelPtr & operator= (std::unique_ptr< Type > &&ptr)
 Assign operator.
 
TOptDelPtr & operator= (Type *ptr)
 Assign operator.
 
template<class SourceType >
bool SetCastedOrRemove (SourceType *ptr, ReleaseFn releaseFn=nullptr)
 Set internal pointer using casted pointer of other type.
 
template<class SourcePtrType >
bool SetCastedOrRemove (std::unique_ptr< SourcePtrType > ptr)
 Set internal pointer using casted pointer of other type.
 
- Public Member Functions inherited from istd::TPointerBase< Type >
 TPointerBase (Type *ptr=nullptr)
 Construct and assign internal pointer.
 
void SetPtr (Type *ptr)
 Set value of internal stored pointer.
 
void Reset ()
 Set internal pointer value to nullptr.
 
Type * get () const
 Return access to internal stored pointer.
 
bool IsValid () const
 Check if internal pointer not nullptr.
 
Type & operator* () const
 Get an access to object pointed at.
 
template<class CastedType >
CastedType Cast () const
 
Type * operator-> () const
 
bool operator== (const TPointerBase< Type > &ptr) const
 
bool operator!= (const TPointerBase< Type > &ptr) const
 
bool operator< (const TPointerBase< Type > &ptr) const
 
bool operator> (const TPointerBase< Type > &ptr) const
 
bool operator<= (const TPointerBase< Type > &ptr) const
 
bool operator>= (const TPointerBase< Type > &ptr) const
 
bool operator== (const Type *ptr) const
 
bool operator!= (const Type *ptr) const
 
bool operator< (const Type *ptr) const
 
bool operator> (const Type *ptr) const
 
bool operator<= (const Type *ptr) const
 
bool operator>= (const Type *ptr) const
 
 operator bool () const
 

Static Public Member Functions

static void SimpleDeleter (Type *ptr)
 Function calling delete operator.
 

Protected Member Functions

void Detach ()
 Remove referenced object.
 
- Protected Member Functions inherited from istd::TPointerBase< Type >
TPointerBase< Type > & operator= (const TPointerBase< Type > ptr)
 
Type *& GetPtrRef ()
 
void Swap (TPointerBase &ptr)
 Swap two pointers.
 

Additional Inherited Members

- Protected Attributes inherited from istd::TPointerBase< Type >
Type * m_ptr
 

Detailed Description

template<class Type, bool DelArray = false>
class istd::TOptDelPtr< Type, DelArray >

Pointer wrapper providing activatable deleting pointed object during destruction.

Definition at line 22 of file TOptDelPtr.h.

Member Typedef Documentation

◆ BaseClass

template<class Type , bool DelArray = false>
TPointerBase<Type> istd::TOptDelPtr< Type, DelArray >::BaseClass

Definition at line 25 of file TOptDelPtr.h.

◆ ReleaseFn

template<class Type , bool DelArray = false>
std::function<void (Type*)> istd::TOptDelPtr< Type, DelArray >::ReleaseFn

Definition at line 27 of file TOptDelPtr.h.

Constructor & Destructor Documentation

◆ TOptDelPtr() [1/5]

template<class Type , bool DelArray = false>
istd::TOptDelPtr< Type, DelArray >::TOptDelPtr ( const TOptDelPtr< Type, DelArray > & ptr)
delete

◆ TOptDelPtr() [2/5]

template<class Type , bool DelArray>
istd::TOptDelPtr< Type, DelArray >::TOptDelPtr ( Type * ptr = nullptr,
ReleaseFn releaseFn = nullptr )
inline

Construct and init this pointer.

Parameters
ptrpointer to object.
releaseFnif set, pointed object will be automatically released by this function.

Definition at line 190 of file TOptDelPtr.h.

◆ TOptDelPtr() [3/5]

template<class Type , bool DelArray>
istd::TOptDelPtr< Type, DelArray >::TOptDelPtr ( Type * ptr,
bool releaseFlag )
inline

Construct and init this pointer.

Parameters
ptrpointer to object.
releaseFlagif true, pointed object will be automatically released.

Definition at line 197 of file TOptDelPtr.h.

◆ TOptDelPtr() [4/5]

template<class Type , bool DelArray>
istd::TOptDelPtr< Type, DelArray >::TOptDelPtr ( TOptDelPtr< Type, DelArray > && ptr)
inline

Move constructor.

Definition at line 204 of file TOptDelPtr.h.

◆ TOptDelPtr() [5/5]

template<class Type , bool DelArray>
istd::TOptDelPtr< Type, DelArray >::TOptDelPtr ( std::unique_ptr< Type > && ptr)
inline

Construct and init this pointer using unique pointer.

Parameters
ptrpointer to object, responsibility will be overtaken.

Definition at line 212 of file TOptDelPtr.h.

◆ ~TOptDelPtr()

template<class Type , bool DelArray>
istd::TOptDelPtr< Type, DelArray >::~TOptDelPtr ( )
inline

Destructor.

It calls Reset() to delete pointed object.

Definition at line 219 of file TOptDelPtr.h.

Member Function Documentation

◆ Detach()

template<class Type , bool DelArray>
void istd::TOptDelPtr< Type, DelArray >::Detach ( )
protected

Remove referenced object.

Warning: internal pointer will be not changed.

Definition at line 345 of file TOptDelPtr.h.

◆ GetFreePtr()

template<class Type , bool DelArray>
Type * istd::TOptDelPtr< Type, DelArray >::GetFreePtr ( ) const

Get internal pointer only if it is free, it means will be not released.

Definition at line 251 of file TOptDelPtr.h.

◆ IsToRelase()

template<class Type , bool DelArray>
bool istd::TOptDelPtr< Type, DelArray >::IsToRelase ( ) const
inline

Get state of release flag.

If this flag is true, pointed object will be automatically removed from memory. If this pointer isn't valid, returned value has no meaning.

Definition at line 233 of file TOptDelPtr.h.

◆ operator=() [1/4]

template<class Type , bool DelArray>
TOptDelPtr< Type, DelArray > & istd::TOptDelPtr< Type, DelArray >::operator= ( const TOptDelPtr< Type, DelArray > & ptr)

Assign operator.

This implementation has no function and is provided only for compatibility with STL. The source pointer must be invalid (nullptr).

Definition at line 284 of file TOptDelPtr.h.

References istd::TPointerBase< Type >::m_ptr.

◆ operator=() [2/4]

template<class Type , bool DelArray>
TOptDelPtr< Type, DelArray > & istd::TOptDelPtr< Type, DelArray >::operator= ( std::unique_ptr< Type > && ptr)

Assign operator.

Move assignement of unique pointer.

Definition at line 311 of file TOptDelPtr.h.

◆ operator=() [3/4]

template<class Type , bool DelArray>
TOptDelPtr< Type, DelArray > & istd::TOptDelPtr< Type, DelArray >::operator= ( TOptDelPtr< Type, DelArray > && ptr)

Assign move operator.

The source pointer must be invalid (nullptr) is it takes responsibility over the object life cycle.

Definition at line 299 of file TOptDelPtr.h.

◆ operator=() [4/4]

template<class Type , bool DelArray>
TOptDelPtr< Type, DelArray > & istd::TOptDelPtr< Type, DelArray >::operator= ( Type * ptr)

Assign operator.

It removes refererenced object before new is assigned.

Parameters
ptrpointer to object.

Definition at line 320 of file TOptDelPtr.h.

◆ release()

template<class Type , bool DelArray>
Type * istd::TOptDelPtr< Type, DelArray >::release ( )
inline

Reset internal pointer value without deleting instance and return previos value.

Definition at line 262 of file TOptDelPtr.h.

◆ Reset()

template<class Type , bool DelArray>
void istd::TOptDelPtr< Type, DelArray >::Reset ( )
inline

Remove object pointed by internal pointer and set this pointer to nullptr.

Definition at line 226 of file TOptDelPtr.h.

◆ SetCastedOrRemove() [1/2]

template<class Type , bool DelArray = false>
template<class SourceType >
bool istd::TOptDelPtr< Type, DelArray >::SetCastedOrRemove ( SourceType * ptr,
ReleaseFn releaseFn = nullptr )
inline

Set internal pointer using casted pointer of other type.

If casting is not possible, pointed object ptr will be deleted.

Parameters
releaseFnif set, pointed object will be automatically deleted by this function.

Definition at line 128 of file TOptDelPtr.h.

References istd::TOptDelPtr< Type, DelArray >::SetPtr().

◆ SetCastedOrRemove() [2/2]

template<class Type , bool DelArray = false>
template<class SourcePtrType >
bool istd::TOptDelPtr< Type, DelArray >::SetCastedOrRemove ( std::unique_ptr< SourcePtrType > ptr)
inline

Set internal pointer using casted pointer of other type.

If casting is not possible, pointed object ptr will be deleted.

Parameters
releaseFnif set, pointed object will be automatically deleted by this function.

Definition at line 152 of file TOptDelPtr.h.

References istd::TOptDelPtr< Type, DelArray >::SetPtr(), and istd::TOptDelPtr< Type, DelArray >::SimpleDeleter().

◆ SetPtr()

template<class Type , bool DelArray>
void istd::TOptDelPtr< Type, DelArray >::SetPtr ( Type * ptr,
ReleaseFn releaseFn = nullptr )
inline

Set new value of internal pointer.

If internal pointer wasn't nullptr, it will be deleted.

Parameters
ptrnew pointer value.
releaseFnif set, pointed object will be automatically released by this function.

Definition at line 240 of file TOptDelPtr.h.

Referenced by istd::TOptDelPtr< Type, DelArray >::SetCastedOrRemove(), and istd::TOptDelPtr< Type, DelArray >::SetCastedOrRemove().

◆ SimpleDeleter()

template<class Type , bool DelArray>
void istd::TOptDelPtr< Type, DelArray >::SimpleDeleter ( Type * ptr)
static

Function calling delete operator.

Definition at line 331 of file TOptDelPtr.h.

Referenced by istd::TOptDelPtr< Type, DelArray >::SetCastedOrRemove().

◆ Swap()

template<class Type , bool DelArray>
void istd::TOptDelPtr< Type, DelArray >::Swap ( TOptDelPtr< Type, DelArray > & ptr)

Swap two pointers.

Definition at line 276 of file TOptDelPtr.h.


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

© Witold Gantzke and Kirill Lepskiy