Library of Assembled Shared Sources
lass::util::SmartI< I > Class Template Reference

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
 

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 (TSelf &&iOther) noexcept
 Move constructor.
 
 ~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.
 
TSelfoperator= (TSelf &&iOther) noexcept
 Move assignment.
 
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 bool () 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
 

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():

  • AddRef() should increase reference count to interface
  • Release() should decrease reference count

Definition at line 66 of file smart_i.h.

Member Function Documentation

◆ reset() [1/2]

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

Reinitialize to NULL interface.

Performs Release() on old interface.

Definition at line 127 of file smart_i.h.

References swap().

◆ reset() [2/2]

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 137 of file smart_i.h.

References swap().

◆ isEmpty()

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 186 of file smart_i.h.

◆ operator!()

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 194 of file smart_i.h.

◆ operator bool()

template<typename I>
lass::util::SmartI< I >::operator bool ( ) const
inlineexplicit

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

Returns
this->get() != 0.

Definition at line 202 of file smart_i.h.


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