library of assembled shared sources

http://lass.cocamware.com

lass::util::SmartI< I > Class Template Reference
[Smart Pointers]

smart pointer to COM interfaces More...

#include <smart_i.h>


Data Structures

struct  Rebind
 Rebind to another interface type. More...

Public Types

typedef SmartI< I > TSelf
 type of *this
typedef I TInterface
typedef I * TPointer
typedef I ** TAddress

Public Member Functions

 SmartI ()
 Default constructor initializes to NULL interface.
 SmartI (TInterface *iInterface)
 Constructor won't do an extra AddRef() on construction but will Release() on destruction.
 SmartI (const TSelf &iOther)
 Copy constructor performs AddRef() on interface.
 ~SmartI ()
 Destructor performs Release() on interface.
void reset ()
 Reinitialize to NULL interface.
void reset (TInterface *iInterface)
 Reinitialize to an interface, performs no AddRef on new interface, but will Release() it in destructor.
TSelfoperator= (const TSelf &iOther)
 assign the SmartI to another one, performing AddRef() on interface.
TPointer get () const
 return pointer to interface
TPointer operator-> () const
 access pointee as a pointer
TAddress address ()
 access address of interface pointer.
bool isEmpty () const
 return true if pointer doesn't own any interface.
bool operator! () const
 return true if pointer doesn't own any interface (same as isEmpty).
 operator num::SafeBool () const
 evaluates to true if pointer owns an interface (only in boolean context)
void swap (TSelf &iOther)
 exchange the pointees (and there reference counts) between two shared pointers

Private Member Functions

void safeAddRef ()
void safeRelease ()

Private Attributes

TPointer interface_


Detailed Description

template<typename I>
class lass::util::SmartI< I >

smart pointer to COM interfaces

Author:
Bram de Greve [Bramz]

Requirements for COM interface

COM interface I must implement two methods AddRef() and Release():

Definition at line 67 of file smart_i.h.


Member Typedef Documentation

template<typename I >
typedef SmartI<I> lass::util::SmartI< I >::TSelf

type of *this

Definition at line 72 of file smart_i.h.

template<typename I >
typedef I lass::util::SmartI< I >::TInterface

Definition at line 74 of file smart_i.h.

template<typename I >
typedef I* lass::util::SmartI< I >::TPointer

Definition at line 75 of file smart_i.h.

template<typename I >
typedef I** lass::util::SmartI< I >::TAddress

Definition at line 76 of file smart_i.h.


Constructor & Destructor Documentation

template<typename I >
lass::util::SmartI< I >::SmartI (  )  [inline]

Default constructor initializes to NULL interface.

Definition at line 90 of file smart_i.h.

template<typename I >
lass::util::SmartI< I >::SmartI ( TInterface iInterface  )  [inline, explicit]

Constructor won't do an extra AddRef() on construction but will Release() on destruction.

Definition at line 97 of file smart_i.h.

template<typename I >
lass::util::SmartI< I >::SmartI ( const TSelf iOther  )  [inline]

Copy constructor performs AddRef() on interface.

Definition at line 104 of file smart_i.h.

References lass::util::SmartI< I >::safeAddRef().

template<typename I >
lass::util::SmartI< I >::~SmartI (  )  [inline]

Destructor performs Release() on interface.

Definition at line 112 of file smart_i.h.

References lass::util::SmartI< I >::safeRelease().


Member Function Documentation

template<typename I >
void lass::util::SmartI< I >::reset (  )  [inline]

Reinitialize to NULL interface.

Performs Release() on old interface.

Definition at line 120 of file smart_i.h.

References lass::util::SmartI< I >::swap().

template<typename I >
void lass::util::SmartI< I >::reset ( TInterface iInterface  )  [inline]

Reinitialize to an interface, performs no AddRef on new interface, but will Release() it in destructor.

Performs Release() on old interface.

Definition at line 130 of file smart_i.h.

References lass::util::SmartI< I >::swap().

template<typename I >
TSelf& lass::util::SmartI< I >::operator= ( const TSelf iOther  )  [inline]

assign the SmartI to another one, performing AddRef() on interface.

Definition at line 138 of file smart_i.h.

References lass::util::SmartI< I >::swap().

template<typename I >
TPointer lass::util::SmartI< I >::get (  )  const [inline]

return pointer to interface

Definition at line 147 of file smart_i.h.

References lass::util::SmartI< I >::interface_.

template<typename I >
TPointer lass::util::SmartI< I >::operator-> (  )  const [inline]

access pointee as a pointer

Definition at line 154 of file smart_i.h.

References lass::util::SmartI< I >::interface_, and LASS_ASSERT.

template<typename I >
TAddress lass::util::SmartI< I >::address (  )  [inline]

access address of interface pointer.

Definition at line 162 of file smart_i.h.

References lass::util::SmartI< I >::interface_.

template<typename I >
bool lass::util::SmartI< I >::isEmpty (  )  const [inline]

return true if pointer doesn't own any interface.

Returns:
this->get() == 0

Definition at line 170 of file smart_i.h.

References lass::util::SmartI< I >::interface_.

template<typename I >
bool lass::util::SmartI< I >::operator! (  )  const [inline]

return true if pointer doesn't own any interface (same as isEmpty).

Returns:
this->get() == 0.

Definition at line 178 of file smart_i.h.

References lass::util::SmartI< I >::interface_.

template<typename I >
lass::util::SmartI< I >::operator num::SafeBool (  )  const [inline]

evaluates to true if pointer owns an interface (only in boolean context)

Returns:
this->get() != 0.
See also:
num::SafeBool

Definition at line 187 of file smart_i.h.

References lass::util::SmartI< I >::interface_, lass::num::safeFalse, and lass::num::safeTrue.

template<typename I >
void lass::util::SmartI< I >::swap ( TSelf iOther  )  [inline]

exchange the pointees (and there reference counts) between two shared pointers

Definition at line 194 of file smart_i.h.

References lass::util::SmartI< I >::interface_, and std::swap().

Referenced by lass::util::SmartI< I >::operator=(), and lass::util::SmartI< I >::reset().

template<typename I >
void lass::util::SmartI< I >::safeAddRef (  )  [inline, private]

Definition at line 201 of file smart_i.h.

Referenced by lass::util::SmartI< I >::SmartI().

template<typename I >
void lass::util::SmartI< I >::safeRelease (  )  [inline, private]

Definition at line 209 of file smart_i.h.

Referenced by lass::util::SmartI< I >::~SmartI().


Field Documentation

template<typename I >
TPointer lass::util::SmartI< I >::interface_ [private]


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

Generated on Mon Nov 10 14:22:17 2008 for Library of Assembled Shared Sources by doxygen 1.5.7.1
SourceForge.net Logo