soui 5.0.0.1
Soui5 Doc
 
Loading...
Searching...
No Matches
SAutoRefPtr< T > Class Template Reference

Smart pointer class for managing COM-style reference-counted objects. More...

#include <obj-ref-impl.hpp>

Public Member Functions

 SAutoRefPtr ()
 Default constructor that initializes the pointer to NULL.
 
 SAutoRefPtr (T *lp, BOOL bAddRef=TRUE)
 Constructor that takes a pointer and optionally adds a reference.
 
 SAutoRefPtr (const SAutoRefPtr &src)
 Copy constructor that adds a reference to the object.
 
 ~SAutoRefPtr ()
 Destructor that releases the object.
 
T * operator-> () const
 Overloaded operator-> to access members of the object.
 
 operator T* () const
 Overloaded cast operator to T*.
 
T & operator* () const
 Overloaded dereference operator.
 
T ** operator& ()
 Overloaded address-of operator.
 
bool operator! () const
 Overloaded not operator to check if the pointer is NULL.
 
bool operator< (T *pT) const
 Overloaded less-than operator.
 
bool operator!= (T *pT) const
 Overloaded not-equal operator.
 
bool operator== (T *pT) const
 Overloaded equal operator.
 
T * operator= (T *lp)
 Overloaded assignment operator from a raw pointer.
 
T * operator= (const SAutoRefPtr< T > &lp)
 Overloaded assignment operator from another SAutoRefPtr.
 
void Release ()
 Releases the object and sets the pointer to NULL.
 
void Attach (T *p2)
 Attaches to an existing object without adding a reference.
 
T * Detach ()
 Detaches the object without releasing it.
 
HRESULT CopyTo (T **ppT)
 Copies the pointer to another location and adds a reference.
 

Protected Attributes

T * p
 Pointer to the managed object.
 

Detailed Description

template<class T>
class SAutoRefPtr< T >

Smart pointer class for managing COM-style reference-counted objects.

Template Parameters
TThe type of the object being managed.

Definition at line 74 of file obj-ref-impl.hpp.

Constructor & Destructor Documentation

◆ SAutoRefPtr() [1/3]

template<class T>
SAutoRefPtr< T >::SAutoRefPtr ( )
inline

Default constructor that initializes the pointer to NULL.

Definition at line 78 of file obj-ref-impl.hpp.

◆ SAutoRefPtr() [2/3]

template<class T>
SAutoRefPtr< T >::SAutoRefPtr ( T * lp,
BOOL bAddRef = TRUE )
inline

Constructor that takes a pointer and optionally adds a reference.

Parameters
lpThe pointer to the object.
bAddRefWhether to add a reference to the object.

Definition at line 86 of file obj-ref-impl.hpp.

◆ SAutoRefPtr() [3/3]

template<class T>
SAutoRefPtr< T >::SAutoRefPtr ( const SAutoRefPtr< T > & src)
inline

Copy constructor that adds a reference to the object.

Parameters
srcThe source smart pointer.

Definition at line 97 of file obj-ref-impl.hpp.

◆ ~SAutoRefPtr()

template<class T>
SAutoRefPtr< T >::~SAutoRefPtr ( )
inline

Destructor that releases the object.

Definition at line 107 of file obj-ref-impl.hpp.

Member Function Documentation

◆ Attach()

template<class T>
void SAutoRefPtr< T >::Attach ( T * p2)
inline

Attaches to an existing object without adding a reference.

Parameters
p2The pointer to attach.

Definition at line 228 of file obj-ref-impl.hpp.

◆ CopyTo()

template<class T>
HRESULT SAutoRefPtr< T >::CopyTo ( T ** ppT)
inline

Copies the pointer to another location and adds a reference.

Parameters
ppTThe destination pointer.
Returns
S_OK if successful, E_POINTER if ppT is NULL.

Definition at line 249 of file obj-ref-impl.hpp.

◆ Detach()

template<class T>
T * SAutoRefPtr< T >::Detach ( )
inline

Detaches the object without releasing it.

Returns
The pointer to the object.

Definition at line 239 of file obj-ref-impl.hpp.

◆ operator T*()

template<class T>
SAutoRefPtr< T >::operator T* ( ) const
inline

Overloaded cast operator to T*.

Returns
The pointer to the object.

Definition at line 124 of file obj-ref-impl.hpp.

◆ operator!()

template<class T>
bool SAutoRefPtr< T >::operator! ( ) const
inline

Overloaded not operator to check if the pointer is NULL.

Returns
TRUE if the pointer is NULL, FALSE otherwise.

Definition at line 146 of file obj-ref-impl.hpp.

◆ operator!=()

template<class T>
bool SAutoRefPtr< T >::operator!= ( T * pT) const
inline

Overloaded not-equal operator.

Parameters
pTThe pointer to compare with.
Returns
TRUE if the current pointer is not equal to pT, FALSE otherwise.

Definition at line 162 of file obj-ref-impl.hpp.

◆ operator&()

template<class T>
T ** SAutoRefPtr< T >::operator& ( )
inline

Overloaded address-of operator.

Returns
The address of the pointer.

Definition at line 138 of file obj-ref-impl.hpp.

◆ operator*()

template<class T>
T & SAutoRefPtr< T >::operator* ( ) const
inline

Overloaded dereference operator.

Returns
The reference to the object.

Definition at line 131 of file obj-ref-impl.hpp.

◆ operator->()

template<class T>
T * SAutoRefPtr< T >::operator-> ( ) const
inline

Overloaded operator-> to access members of the object.

Returns
The pointer to the object.

Definition at line 117 of file obj-ref-impl.hpp.

◆ operator<()

template<class T>
bool SAutoRefPtr< T >::operator< ( T * pT) const
inline

Overloaded less-than operator.

Parameters
pTThe pointer to compare with.
Returns
TRUE if the current pointer is less than pT, FALSE otherwise.

Definition at line 154 of file obj-ref-impl.hpp.

◆ operator=() [1/2]

template<class T>
T * SAutoRefPtr< T >::operator= ( const SAutoRefPtr< T > & lp)
inline

Overloaded assignment operator from another SAutoRefPtr.

Parameters
lpThe source smart pointer.
Returns
The pointer to the object.

Definition at line 198 of file obj-ref-impl.hpp.

◆ operator=() [2/2]

template<class T>
T * SAutoRefPtr< T >::operator= ( T * lp)
inline

Overloaded assignment operator from a raw pointer.

Parameters
lpThe pointer to assign.
Returns
The pointer to the object.

Definition at line 178 of file obj-ref-impl.hpp.

◆ operator==()

template<class T>
bool SAutoRefPtr< T >::operator== ( T * pT) const
inline

Overloaded equal operator.

Parameters
pTThe pointer to compare with.
Returns
TRUE if the current pointer is equal to pT, FALSE otherwise.

Definition at line 170 of file obj-ref-impl.hpp.

◆ Release()

template<class T>
void SAutoRefPtr< T >::Release ( )
inline

Releases the object and sets the pointer to NULL.

Definition at line 216 of file obj-ref-impl.hpp.

Member Data Documentation

◆ p

template<class T>
T* SAutoRefPtr< T >::p
protected

Pointer to the managed object.

Definition at line 263 of file obj-ref-impl.hpp.


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