ug4
SmartPtr< T, FreePolicy > Class Template Reference

#include <smart_pointer.h>

Public Member Functions

ConstSmartPtr< T, FreePolicy > cast_const () const
 performs a const cast More...
 
template<class TDest >
SmartPtr< TDest, FreePolicy > cast_dynamic () const
 preforms a dynamic cast More...
 
template<class TDest >
SmartPtr< TDest, FreePolicy > cast_reinterpret () const
 performs a reinterpret cast More...
 
template<class TDest >
SmartPtr< TDest, FreePolicy > cast_static () const
 performs a static cast More...
 
T * get ()
 returns encapsulated pointer More...
 
const T * get () const
 returns encapsulated pointer More...
 
bool invalid () const
 returns true if the pointer is invalid, false if not. More...
 
template<class TDest >
bool is_of_type () const
 
 operator bool () const noexcept
 
template<class TPtr >
bool operator!= (const ConstSmartPtr< TPtr, FreePolicy > &sp) const
 
bool operator!= (const SmartPtr &sp) const
 
bool operator!= (NullSmartPtr) const
 
T & operator* ()
 
const T & operator* () const
 
T * operator-> ()
 
const T * operator-> () const
 
SmartPtroperator= (const SmartPtr &sp)
 
template<class TIn >
SmartPtr< T, FreePolicy > & operator= (const SmartPtr< TIn, FreePolicy > &sp)
 
SmartPtroperator= (NullSmartPtr)
 
template<class TPtr >
bool operator== (const ConstSmartPtr< TPtr, FreePolicy > &sp) const
 
bool operator== (const SmartPtr &sp) const
 
bool operator== (NullSmartPtr) const
 
int refcount () const
 returns refcount More...
 
 SmartPtr ()
 
 SmartPtr (const SmartPtr &sp)
 
template<class TPtr >
 SmartPtr (const SmartPtr< TPtr, FreePolicy > &sp)
 
 SmartPtr (NullSmartPtr)
 
 SmartPtr (T *ptr)
 
 SmartPtr (T *ptr, int *refCount)
 WARNING: this method is DANGEROUS! More...
 
bool valid () const
 returns true if the pointer is valid, false if not. More...
 
 ~SmartPtr ()
 
int * refcount_ptr () const
 WARNING: this method is DANGEROUS! More...
 
T * get_nonconst () const
 WARNING: this method is DANGEROUS! More...
 

Private Member Functions

void release ()
 decrements the refCount and frees the encapsulated pointer if required. More...
 

Static Private Member Functions

static void free_void_ptr (const void *ptr)
 this release method is required by SmartPtr<void> More...
 

Private Attributes

T * m_ptr
 
int * m_refCount
 

Friends

class ConstSmartPtr< T, FreePolicy >
 
class ConstSmartPtr< void >
 
class SmartPtr< void >
 

Detailed Description

template<typename T, template< class TT > class FreePolicy>
class SmartPtr< T, FreePolicy >

A Smart Pointer encapsulates a pointer. With each copy of the SmartPointer a shared reference count is increased and with each destructor call to a SmartPointer this shared reference count is decreased. If the shared reference count reaches 0 free as specified in the FreePolicy is executed on the pointer.

The FreePolicy has to feature the method free().

If a const smart pointer is required, use ConstSmartPtr

Constructor & Destructor Documentation

◆ SmartPtr() [1/6]

template<typename T , template< class TT > class FreePolicy>
SmartPtr< T, FreePolicy >::SmartPtr ( )
inlineexplicit

◆ SmartPtr() [2/6]

template<typename T , template< class TT > class FreePolicy>
SmartPtr< T, FreePolicy >::SmartPtr ( T *  ptr)
inlineexplicit

◆ SmartPtr() [3/6]

template<typename T , template< class TT > class FreePolicy>
SmartPtr< T, FreePolicy >::SmartPtr ( NullSmartPtr< T, FreePolicy >  )
inline

◆ SmartPtr() [4/6]

template<typename T , template< class TT > class FreePolicy>
SmartPtr< T, FreePolicy >::SmartPtr ( const SmartPtr< T, FreePolicy > &  sp)
inline

◆ SmartPtr() [5/6]

template<typename T , template< class TT > class FreePolicy>
template<class TPtr >
SmartPtr< T, FreePolicy >::SmartPtr ( const SmartPtr< TPtr, FreePolicy > &  sp)
inline

this template method allows to assign smart-pointers that encapsulate derivates of T. Make sure that the pointer-type of TSmartPtr is castable to T*.

References SmartPtr< T, FreePolicy >::m_refCount.

◆ ~SmartPtr()

template<typename T , template< class TT > class FreePolicy>
SmartPtr< T, FreePolicy >::~SmartPtr ( )
inline

◆ SmartPtr() [6/6]

template<typename T , template< class TT > class FreePolicy>
SmartPtr< T, FreePolicy >::SmartPtr ( T *  ptr,
int *  refCount 
)
inlineexplicit

WARNING: this method is DANGEROUS!

You should only use this constructor if you really know what you're doing! The following methods are required for SmartPtr<void> and casts

References SmartPtr< T, FreePolicy >::m_refCount.

Member Function Documentation

◆ cast_const()

template<typename T , template< class TT > class FreePolicy>
ConstSmartPtr< T, FreePolicy > SmartPtr< T, FreePolicy >::cast_const
inline

◆ cast_dynamic()

template<typename T , template< class TT > class FreePolicy>
template<class TDest >
SmartPtr<TDest, FreePolicy> SmartPtr< T, FreePolicy >::cast_dynamic ( ) const
inline

◆ cast_reinterpret()

template<typename T , template< class TT > class FreePolicy>
template<class TDest >
SmartPtr<TDest, FreePolicy> SmartPtr< T, FreePolicy >::cast_reinterpret ( ) const
inline

performs a reinterpret cast

References SmartPtr< T, FreePolicy >::m_ptr, SmartPtr< T, FreePolicy >::m_refCount, and p.

◆ cast_static()

template<typename T , template< class TT > class FreePolicy>
template<class TDest >
SmartPtr<TDest, FreePolicy> SmartPtr< T, FreePolicy >::cast_static ( ) const
inline

◆ free_void_ptr()

template<typename T , template< class TT > class FreePolicy>
static void SmartPtr< T, FreePolicy >::free_void_ptr ( const void *  ptr)
inlinestaticprivate

this release method is required by SmartPtr<void>

const void is not really correct here, of course...

◆ get() [1/2]

template<typename T , template< class TT > class FreePolicy>
T* SmartPtr< T, FreePolicy >::get ( )
inline

returns encapsulated pointer

References SmartPtr< T, FreePolicy >::m_ptr.

Referenced by ug::MultipleErrEstData< TDomain, TErrEstData >::add(), ug::node_tree::Traverser::apply(), ug::DomainDiscretizationBase< TDomain, TAlgebra, TGlobAssembler >::assemble_defect(), ug::DomainDiscretizationBase< TDomain, TAlgebra, TGlobAssembler >::assemble_jacobian(), ug::StdTransfer< TDomain, TAlgebra >::assemble_prolongation(), ug::StdTransfer< TDomain, TAlgebra >::assemble_restriction(), ug::BalanceWeightsLuaCallback< TDomain >::BalanceWeightsLuaCallback(), ug::AssembledMultiGridCycle< TDomain, TAlgebra >::base_solve(), ug::IDomain< TGrid, TSubsetHandler >::broadcast_refinement_projector(), ug::CollectIErrEstData(), ug::node_tree::CreateOctree(), ug::node_tree::CreateSubOctrees(), ug::DistributeDomain(), ug::DomainLoadBalancer< TDomain >::DomainLoadBalancer(), ug::LoadBalancer::estimate_distribution_quality_impl(), ug::OutNormCmp< TDomain >::evaluate(), ug::bridge::Evaluate::EvaluateAtClosestVertex(), ug::bridge::Evaluate::EvaluateAtClosestVertexAllProcs(), ug::bridge::Evaluate::EvaluateAtVertex(), ug::bridge::Evaluate::VectorValuedUserDataEvaluator< TDomain, TAlgebra >::evaluateOnThisProcessNeighbouring(), ug::node_tree::Traverser::handle_group(), ug::node_tree::Traverser_ProjectPoint::handle_group(), ug::IntegralNormalComponentOnManifoldSubset(), ug::vrl::jobjectArray2ParamStack(), ug::MarkForAdaption_VerticesInCube(), ug::MarkForAdaption_VerticesInSphereMaxLvl(), ug::MarkForRefinement_ElementsInSphere(), ug::UserDataInfo::obj_name(), std::less< SmartPtr< T, TFreePolicy > >::operator()(), ConstSmartPtr< T, FreePolicy >::operator=(), SmartPtr< T, FreePolicy >::operator==(), ConstSmartPtr< T, FreePolicy >::operator==(), ug::LuaUserDataFactory< TData, dim, TRet >::provide_or_create(), ug::UserDataInfo::set_obj_name(), ug::ProjectionHandler::set_subset_handler(), ug::ComponentGaussSeidel< TDomain, TAlgebra >::step(), ug::UzawaBase< TDomain, TAlgebra >::step(), and ug::MessageHub::unregister_callback().

◆ get() [2/2]

template<typename T , template< class TT > class FreePolicy>
const T* SmartPtr< T, FreePolicy >::get ( ) const
inline

returns encapsulated pointer

References SmartPtr< T, FreePolicy >::m_ptr.

◆ get_nonconst()

template<typename T , template< class TT > class FreePolicy>
T* SmartPtr< T, FreePolicy >::get_nonconst ( ) const
inline

WARNING: this method is DANGEROUS!

This method should never be used since it may be removed in future versions of the SmartPtr class. It is featured in order to allow to implement a template-constructor that casts element-pointers of a smart pointer.

References SmartPtr< T, FreePolicy >::m_ptr.

Referenced by SmartPtr< T, FreePolicy >::operator=().

◆ invalid()

◆ is_of_type()

template<typename T , template< class TT > class FreePolicy>
template<class TDest >
bool SmartPtr< T, FreePolicy >::is_of_type ( ) const
inline

◆ operator bool()

template<typename T , template< class TT > class FreePolicy>
SmartPtr< T, FreePolicy >::operator bool ( ) const
inlineexplicitnoexcept

◆ operator!=() [1/3]

template<typename T , template< class TT > class FreePolicy>
template<class TPtr >
bool SmartPtr< T, FreePolicy >::operator!= ( const ConstSmartPtr< TPtr, FreePolicy > &  sp) const
inline

◆ operator!=() [2/3]

template<typename T , template< class TT > class FreePolicy>
bool SmartPtr< T, FreePolicy >::operator!= ( const SmartPtr< T, FreePolicy > &  sp) const
inline

◆ operator!=() [3/3]

template<typename T , template< class TT > class FreePolicy>
bool SmartPtr< T, FreePolicy >::operator!= ( NullSmartPtr< T, FreePolicy >  ) const
inline

◆ operator*() [1/2]

template<typename T , template< class TT > class FreePolicy>
T& SmartPtr< T, FreePolicy >::operator* ( )
inline

◆ operator*() [2/2]

template<typename T , template< class TT > class FreePolicy>
const T& SmartPtr< T, FreePolicy >::operator* ( ) const
inline

◆ operator->() [1/2]

template<typename T , template< class TT > class FreePolicy>
T* SmartPtr< T, FreePolicy >::operator-> ( )
inline

◆ operator->() [2/2]

template<typename T , template< class TT > class FreePolicy>
const T* SmartPtr< T, FreePolicy >::operator-> ( ) const
inline

◆ operator=() [1/3]

template<typename T , template< class TT > class FreePolicy>
SmartPtr& SmartPtr< T, FreePolicy >::operator= ( const SmartPtr< T, FreePolicy > &  sp)
inline

◆ operator=() [2/3]

template<typename T , template< class TT > class FreePolicy>
template<class TIn >
SmartPtr<T, FreePolicy>& SmartPtr< T, FreePolicy >::operator= ( const SmartPtr< TIn, FreePolicy > &  sp)
inline

◆ operator=() [3/3]

template<typename T , template< class TT > class FreePolicy>
SmartPtr& SmartPtr< T, FreePolicy >::operator= ( NullSmartPtr< T, FreePolicy >  )
inline

◆ operator==() [1/3]

template<typename T , template< class TT > class FreePolicy>
template<class TPtr >
bool SmartPtr< T, FreePolicy >::operator== ( const ConstSmartPtr< TPtr, FreePolicy > &  sp) const
inline

◆ operator==() [2/3]

template<typename T , template< class TT > class FreePolicy>
bool SmartPtr< T, FreePolicy >::operator== ( const SmartPtr< T, FreePolicy > &  sp) const
inline

◆ operator==() [3/3]

template<typename T , template< class TT > class FreePolicy>
bool SmartPtr< T, FreePolicy >::operator== ( NullSmartPtr< T, FreePolicy >  ) const
inline

◆ refcount()

template<typename T , template< class TT > class FreePolicy>
int SmartPtr< T, FreePolicy >::refcount ( ) const
inline

returns refcount

References SmartPtr< T, FreePolicy >::m_refCount.

Referenced by ug::vrl::SmartTestFunction().

◆ refcount_ptr()

template<typename T , template< class TT > class FreePolicy>
int* SmartPtr< T, FreePolicy >::refcount_ptr ( ) const
inline

WARNING: this method is DANGEROUS!

This method should never be used since it may be removed in future versions of the SmartPtr class. It is featured in order to allow to implement a template-constructor that casts element-pointers of a smart pointer.

References SmartPtr< T, FreePolicy >::m_refCount.

Referenced by ug::SomaProjector::attach_surf_params(), SmartPtr< T, FreePolicy >::operator=(), ConstSmartPtr< T, FreePolicy >::operator=(), and ug::LuaUserDataFactory< TData, dim, TRet >::provide_or_create().

◆ release()

template<typename T , template< class TT > class FreePolicy>
void SmartPtr< T, FreePolicy >::release ( )
inlineprivate

◆ valid()

template<typename T , template< class TT > class FreePolicy>
bool SmartPtr< T, FreePolicy >::valid ( ) const
inline

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

References SmartPtr< T, FreePolicy >::m_ptr.

Referenced by ug::IRefiner::adaption_begins(), ug::IRefiner::adaption_ends(), ug::GridWriterUGX::add_projection_handler(), ug::IDomain< TGrid, TSubsetHandler >::additional_subset_handler(), ug::AdjustEdgeLength(), ug::PProcessChain< TVector >::apply(), ug::ApproximationSpace< TDomain >::ApproximationSpace(), ug::IDomain< TGrid, TSubsetHandler >::broadcast_refinement_projector(), ug::IRefiner::coarsen(), ug::AdaptiveRegularRefiner_MultiGrid::create_closure_elements_2d(), ug::AdaptiveRegularRefiner_MultiGrid::create_closure_elements_3d(), ug::bridge::CreateSmoothHierarchy(), ug::LUAParserClass::createVM(), ug::DistributeDomain(), ug::DomainLoadBalancer< TDomain >::DomainLoadBalancer(), ug::EnergyConvCheck< TVector >::energy_norm(), ug::NestedIterationSolver< TDomain, TAlgebra >::estimate_and_mark_domain(), ug::AssembledMultiGridCycle< TDomain, TAlgebra >::init(), ug::UzawaBase< TDomain, TAlgebra >::init(), ug::SchurInverseWithAGammaGamma< TAlgebra >::init(), SmartPtr< void >::invalidate(), pcl::ProcessCommunicator::is_local(), ug::CompositeSpace< TGridFunction >::is_time_dependent(), ug::NeuriteProjector::load(), ug::GlobalFracturedMediaRefiner::perform_refinement(), ug::GlobalMultiGridRefiner::perform_refinement(), ug::HangingNodeRefiner_MultiGrid::pre_refine(), ug::LoadBalancer::problems_occurred(), ug::GridReaderUGX::projection_handler(), ug::LoadBalancer::rebalance(), ug::ProjectionHandler::refinement_begins(), ug::AutoLinearSolver< TVector >::reinit(), ug::SelectElementsForTargetPartition(), ug::SerializeProjectionHandler(), ug::CopyAttachmentHandler< TElem, TAttachment >::set_attachment(), ug::CopyAttachmentHandler< TElem, TAttachment >::set_grid(), ug::SchurComplementOperator< TAlgebra >::set_inner_debug(), ug::UserDataInfo::set_obj_name(), ug::ProjectionHandler::set_projector(), ug::IDomain< TGrid, TSubsetHandler >::set_refinement_projector(), ug::SchurComplementOperator< TAlgebra >::set_skeleton_debug(), ug::IBlockJacobiPreconditioner< TAlgebra >::step(), ug::CompositeSpace< TGridFunction >::update_time_data(), and ug::CopyAttachmentHandler< TElem, TAttachment >::~CopyAttachmentHandler().

Friends And Related Function Documentation

◆ ConstSmartPtr< T, FreePolicy >

template<typename T , template< class TT > class FreePolicy>
friend class ConstSmartPtr< T, FreePolicy >
friend

◆ ConstSmartPtr< void >

template<typename T , template< class TT > class FreePolicy>
friend class ConstSmartPtr< void >
friend

◆ SmartPtr< void >

template<typename T , template< class TT > class FreePolicy>
friend class SmartPtr< void >
friend

Member Data Documentation

◆ m_ptr

◆ m_refCount


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