ug4
SmartPtr< void > Class Reference

#include <smart_pointer.h>

Public Member Functions

template<class T , template< class TPtr > class TFreePolicy>
SmartPtr< T, TFreePolicy > cast_reinterpret () const
 Returns a SmartPtr with the specified type and shared reference counting. More...
 
void * get ()
 
const void * get () const
 
bool invalid () const
 returns true if the pointer is invalid, false if not. More...
 
void invalidate ()
 
 operator bool () const noexcept
 
template<class T >
SmartPtr< void > & operator= (const SmartPtr< T > &sp)
 
SmartPtr< void > & operator= (const SmartPtr< void > &sp)
 
template<class T >
SmartPtr< void > & operator= (NullSmartPtr)
 
int refcount () const
 
template<class T , template< class TPtr > class TFreePolicy>
void set_impl (void *ptr)
 sets the void* to a different location correspoding to a cast to a new type T More...
 
 SmartPtr ()
 
template<class T >
 SmartPtr (const SmartPtr< T > &sp)
 
 SmartPtr (const SmartPtr< void > &sp)
 
 SmartPtr (NullSmartPtr)
 
 SmartPtr (void *ptr, void(*freeFunc)(const void *))
 
bool valid () const
 returns true if the pointer is valid, false if not. More...
 
 ~SmartPtr ()
 

Private Member Functions

void release ()
 

Private Attributes

void(* m_freeFunc )(const void *)
 
void * m_ptr
 
int * m_refCountPtr
 

Friends

class ConstSmartPtr< void >
 

Detailed Description

The SmartPtr<void> is a specialization of the SmartPtr class. It can only be constructed from an existing SmartPtr or from an existing SmartPtr<void>. This is crucial to guarantee save release methods.

In contrary to the original SmartPtr class, the void specialization does not feature the -> and * operators. One also can't directly access the encapsulated pointer.

If you need a const smart pointer use ConstSmartPtr<void>.

Todo:
add to_smart_ptr_dynamic

Constructor & Destructor Documentation

◆ SmartPtr() [1/5]

SmartPtr< void >::SmartPtr ( )
inlineexplicit

◆ SmartPtr() [2/5]

SmartPtr< void >::SmartPtr ( NullSmartPtr< void >  )
inline

◆ SmartPtr() [3/5]

SmartPtr< void >::SmartPtr ( const SmartPtr< void > &  sp)
inline

◆ SmartPtr() [4/5]

SmartPtr< void >::SmartPtr ( void *  ptr,
void(*)(const void *)  freeFunc 
)
inlineexplicit

◆ SmartPtr() [5/5]

template<class T >
SmartPtr< void >::SmartPtr ( const SmartPtr< T > &  sp)
inline

◆ ~SmartPtr()

SmartPtr< void >::~SmartPtr ( )
inline

Member Function Documentation

◆ cast_reinterpret()

template<class T , template< class TPtr > class TFreePolicy>
SmartPtr<T, TFreePolicy> SmartPtr< void >::cast_reinterpret ( ) const
inline

Returns a SmartPtr with the specified type and shared reference counting.

USE WITH CARE! ONLY COMPATIBLE TYPES SHOULD BE USED

References SmartPtr< T, FreePolicy >::m_ptr.

Referenced by ug::bridge::ParameterStack::_to_native_vector(), ug::bridge::ParameterStack::_to_pointer_vector(), and ug::bridge::ParameterStack::_to_void_pointer_vector().

◆ get() [1/2]

◆ get() [2/2]

const void* SmartPtr< void >::get ( ) const
inline

◆ invalid()

bool SmartPtr< void >::invalid ( ) const
inline

returns true if the pointer is invalid, false if not.

References SmartPtr< T, FreePolicy >::m_ptr.

◆ invalidate()

◆ operator bool()

SmartPtr< void >::operator bool ( ) const
inlineexplicitnoexcept

◆ operator=() [1/3]

template<class T >
SmartPtr<void>& SmartPtr< void >::operator= ( const SmartPtr< T > &  sp)
inline

◆ operator=() [2/3]

SmartPtr<void>& SmartPtr< void >::operator= ( const SmartPtr< void > &  sp)
inline

◆ operator=() [3/3]

template<class T >
SmartPtr<void>& SmartPtr< void >::operator= ( NullSmartPtr< void >  )
inline

◆ refcount()

int SmartPtr< void >::refcount ( ) const
inline

◆ release()

void SmartPtr< void >::release ( )
inlineprivate

◆ set_impl()

template<class T , template< class TPtr > class TFreePolicy>
void SmartPtr< void >::set_impl ( void *  ptr)
inline

sets the void* to a different location correspoding to a cast to a new type T

!!! WARNING: THIS METHOD IS DANDGEROUS: DO NOT USE IT UNLESS YOU REALLY KNOW WHAT YOU ARE DOING !!!

References SmartPtr< T, FreePolicy >::m_ptr.

◆ valid()

bool SmartPtr< void >::valid ( ) const
inline

returns true if the pointer is valid, false if not.

References SmartPtr< T, FreePolicy >::m_ptr.

Friends And Related Function Documentation

◆ ConstSmartPtr< void >

friend class ConstSmartPtr< void >
friend

Member Data Documentation

◆ m_freeFunc

void(* SmartPtr< void >::m_freeFunc) (const void *)
private

◆ m_ptr

void* SmartPtr< void >::m_ptr
private

◆ m_refCountPtr

int* SmartPtr< void >::m_refCountPtr
private

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