SOFA API  ca665544
Open source framework for multi-physics simuation
sofa::helper::OwnershipSPtr< T > Class Template Reference

#include <OwnershipSPtr.h>

Detailed Description

template<class T>
class sofa::helper::OwnershipSPtr< T >

Smart pointer where the user precises if it must take the ownership (and so be in charge of deleting the data). Either it can point to an existing data without taking the ownership or it can point to a new temporary Data that will be deleted when this smart pointer is deleted (taking ownership).

Warning
Maybe an equivalent smart pointer exists in stl or boost that I do not know
Author
Matthieu Nesme

Public Member Functions

 OwnershipSPtr ()
 default constructor: no pointed data, no ownership More...
 
 OwnershipSPtr (const T *t, bool ownership)
 point to a data, manually set ownership More...
 
 OwnershipSPtr (const OwnershipSPtr< T > &other)
 copy constructor that steals the ownership if 'other' had it More...
 
 ~OwnershipSPtr ()
 destructor will delete the data only if it has the ownership More...
 
void operator= (const OwnershipSPtr< T > &other)
 copy operator is stealing the ownership if 'other' had it More...
 
const T & operator* () const
 get a const ref to the pointed data More...
 
const T * operator-> () const
 get a const pointer to the pointer data More...
 

Constructor details

◆ OwnershipSPtr() [1/3]

template<class T >
sofa::helper::OwnershipSPtr< T >::OwnershipSPtr ( )
inline

default constructor: no pointed data, no ownership

◆ OwnershipSPtr() [2/3]

template<class T >
sofa::helper::OwnershipSPtr< T >::OwnershipSPtr ( const T *  t,
bool  ownership 
)
inline

point to a data, manually set ownership

◆ OwnershipSPtr() [3/3]

template<class T >
sofa::helper::OwnershipSPtr< T >::OwnershipSPtr ( const OwnershipSPtr< T > &  other)
inline

copy constructor that steals the ownership if 'other' had it

◆ ~OwnershipSPtr()

template<class T >
sofa::helper::OwnershipSPtr< T >::~OwnershipSPtr ( )
inline

destructor will delete the data only if it has the ownership

Function details

◆ operator*()

template<class T >
const T& sofa::helper::OwnershipSPtr< T >::operator* ( ) const
inline

get a const ref to the pointed data

◆ operator->()

template<class T >
const T* sofa::helper::OwnershipSPtr< T >::operator-> ( ) const
inline

get a const pointer to the pointer data

◆ operator=()

template<class T >
void sofa::helper::OwnershipSPtr< T >::operator= ( const OwnershipSPtr< T > &  other)
inline

copy operator is stealing the ownership if 'other' had it