SIfacePtr< T > Struct Template Reference

wrapper class for COM interface pointers More...

#include <comutil.h>

Inheritance diagram for SIfacePtr< T >:

Inheritance graph
[legend]
Collaboration diagram for SIfacePtr< T >:

Collaboration graph
[legend]

Public Member Functions

 SIfacePtr ()
 SIfacePtr (T *p)
 SIfacePtr (IUnknown *unknown, REFIID riid)
 ~SIfacePtr ()
T * operator-> ()
const T * operator-> () const
 operator T * ()
T ** operator & ()
bool empty () const
SIfacePtroperator= (T *p)
void operator= (SIfacePtr const &o)
HRESULT CreateInstance (REFIID clsid, REFIID riid)
template<typename I>
HRESULT QueryInterface (REFIID riid, I *p)
T * get ()
void Free ()

Protected Member Functions

 SIfacePtr (const SIfacePtr &o)

Protected Attributes

T * _p

Detailed Description

template<typename T>
struct SIfacePtr< T >

wrapper class for COM interface pointers

Definition at line 208 of file comutil.h.


Constructor & Destructor Documentation

template<typename T>
SIfacePtr< T >::SIfacePtr (  )  [inline]

Definition at line 210 of file comutil.h.

00211      :  _p(0)
00212     {
00213     }

template<typename T>
SIfacePtr< T >::SIfacePtr ( T *  p  )  [inline]

Definition at line 215 of file comutil.h.

00216      :  _p(p)
00217     {
00218         if (p)
00219             p->AddRef();
00220     }

template<typename T>
SIfacePtr< T >::SIfacePtr ( IUnknown unknown,
REFIID  riid 
) [inline]

Definition at line 222 of file comutil.h.

00223     {
00224         CHECKERROR(unknown->QueryInterface(riid, (LPVOID*)&_p));
00225     }

template<typename T>
SIfacePtr< T >::~SIfacePtr (  )  [inline]

Definition at line 227 of file comutil.h.

00228     {
00229         Free();
00230     }

template<typename T>
SIfacePtr< T >::SIfacePtr ( const SIfacePtr< T > &  o  )  [inline, protected]

Definition at line 313 of file comutil.h.

00314      :  _p(o._p)
00315     {
00316         if (_p)
00317             _p->AddRef();
00318     }


Member Function Documentation

template<typename T>
T* SIfacePtr< T >::operator-> (  )  [inline]

Definition at line 232 of file comutil.h.

00233     {
00234         return _p;
00235     }

template<typename T>
const T* SIfacePtr< T >::operator-> (  )  const [inline]

Definition at line 237 of file comutil.h.

00238     {
00239         return _p;
00240     }

template<typename T>
SIfacePtr< T >::operator T * (  )  [inline]

Definition at line 248 of file comutil.h.

References SIfacePtr< T >::_p.

00249     {
00250         return _p;
00251     }

template<typename T>
T** SIfacePtr< T >::operator & (  )  [inline]

Definition at line 253 of file comutil.h.

00254     {
00255         return &_p;
00256     }

template<typename T>
bool SIfacePtr< T >::empty (  )  const [inline]

Definition at line 258 of file comutil.h.

00258                               : GCC seems not to work correctly when defining operator bool() AND operator T*() at one time
00259     {
00260         return !_p;
00261     }

template<typename T>
SIfacePtr& SIfacePtr< T >::operator= ( T *  p  )  [inline]

Definition at line 263 of file comutil.h.

00264     {
00265         Free();
00266 
00267         if (p) {
00268             p->AddRef();
00269             _p = p;
00270         }
00271 
00272         return *this;
00273     }

template<typename T>
void SIfacePtr< T >::operator= ( SIfacePtr< T > const &  o  )  [inline]

Definition at line 275 of file comutil.h.

00276     {
00277         T* h = _p;
00278 
00279         if (o._p)
00280             o._p->AddRef();
00281 
00282         _p = o._p;
00283 
00284         if (h)
00285             h->Release();
00286     }

template<typename T>
HRESULT SIfacePtr< T >::CreateInstance ( REFIID  clsid,
REFIID  riid 
) [inline]

Definition at line 288 of file comutil.h.

00289     {
00290         return CoCreateInstance(clsid, NULL, CLSCTX_INPROC_SERVER, riid, (LPVOID*)&_p);
00291     }

template<typename T>
template<typename I>
HRESULT SIfacePtr< T >::QueryInterface ( REFIID  riid,
I *  p 
) [inline]

Definition at line 293 of file comutil.h.

00294     {
00295         return _p->QueryInterface(riid, (LPVOID*)p);
00296     }

template<typename T>
T* SIfacePtr< T >::get (  )  [inline]

Definition at line 298 of file comutil.h.

00299     {
00300         return _p;
00301     }

template<typename T>
void SIfacePtr< T >::Free (  )  [inline]

Definition at line 303 of file comutil.h.

Referenced by SIfacePtr< IOleInPlaceObject >::operator=(), and SIfacePtr< IOleInPlaceObject >::~SIfacePtr().

00304     {
00305         T* h = _p;
00306         _p = NULL;
00307 
00308         if (h)
00309             h->Release();
00310     }

Here is the caller graph for this function:


Field Documentation

template<typename T>
T* SIfacePtr< T >::_p [protected]

Definition at line 320 of file comutil.h.

Referenced by SIfacePtr< IOleInPlaceObject >::CreateInstance(), SIfacePtr< IOleInPlaceObject >::empty(), SIfacePtr< IOleInPlaceObject >::Free(), SIfacePtr< IOleInPlaceObject >::get(), SIfacePtr< IOleInPlaceObject >::operator &(), SIfacePtr< T >::operator T *(), SIfacePtr< IOleInPlaceObject >::operator->(), SIfacePtr< IOleInPlaceObject >::operator=(), SIfacePtr< IOleInPlaceObject >::QueryInterface(), and SIfacePtr< IOleInPlaceObject >::SIfacePtr().


The documentation for this struct was generated from the following file:
IBrowser Source Code Documentation
generated on 18.09.2008 by doxygen

Homepage