7 #ifndef _INC_cIUnkPtr_H
8 #define _INC_cIUnkPtr_H
17 #if defined(_DEBUG) && ! defined(UNDER_CE)
18 #define USE_IUNK_TRACE
26 template<
class TYPE = IUnknown>
47 static void AssertIUnk(
TYPE* p2)
64 int iRefCount = (int)p2->AddRef();
103 #ifdef USE_IUNK_TRACE
121 if (this->
m_p ==
nullptr)
123 int iRefCount = (int) this->
m_p->AddRef();
124 this->
m_p->Release();
125 return iRefCount - 1;
143 TYPE** ppObj = &this->
m_p;
144 return reinterpret_cast<void**
>(ppObj);
167 return E_NOINTERFACE;
170 TYPE* pInterface =
nullptr;
171 HRESULT hRes = p2->QueryInterface(riid,
reinterpret_cast<void**
>(&pInterface));
180 ASSERT(pInterface !=
nullptr);
181 AssertIUnk(pInterface);
183 #ifdef USE_IUNK_TRACE
184 TraceOpen(pInterface);
188 this->
m_p = pInterface;
193 static const IID& GetIID()
197 return __uuidof(
TYPE);
203 return SetQI(p2, GetIID());
211 if (this->
m_p ==
nullptr)
214 TYPE* p2 = this->
m_p;
216 AssertIUnk(this->
m_p);
218 #ifdef USE_IUNK_TRACE
222 int iRefCount = (int)p2->Release();
262 #ifdef USE_IUNK_TRACE
288 m_rpIObj.AssertIUnk(p);
290 m_rpIObj.TraceOpen(p);
293 operator TYPE** ()
const
298 operator void** ()
const
305 #define IUNK_GETPPTR(p,TYPE) cIUnkTraceOpaque<TYPE>(p,DEBUGSOURCELINE)
306 #define IUNK_GETPPTRV(p,TYPE) cIUnkTraceOpaque<TYPE>(p,DEBUGSOURCELINE)
307 #define IUNK_ATTACH(p) ASSERT((p).get_Ptr()!=nullptr); (p).m_Src = DEBUGSOURCELINE; (p).TraceOpen((p).get_Ptr());
309 #define IUNK_GETPPTR(p,TYPE) (p).get_PPtr()
310 #define IUNK_GETPPTRV(p,TYPE) (p).get_PPtrV()
311 #define IUNK_ATTACH(p) __noop
#define GRAYCORE_LINK
Definition: GrayCore.h:47
#define FAILED(x)
Definition: HResult.h:30
#define TYPE
Definition: StrT.cpp:38
INT32 HRESULT
_WIN32 style error codes. INT32
Definition: SysTypes.h:465
#define ASSERT(exp)
Definition: cDebugAssert.h:87
Definition: cIUnkPtr.h:32
TYPE ** get_PPtr()
Definition: cIUnkPtr.h:127
cIUnkPtr(THIS_t &&ref)
Definition: cIUnkPtr.h:102
THIS_t & operator=(const TYPE *p2)
Assignment ops.
Definition: cIUnkPtr.h:227
int get_RefCount() const
Definition: cIUnkPtr.h:118
cIUnkPtr(const TYPE *p2)
Definition: cIUnkPtr.h:85
void SetFirstIUnk(TYPE *p2)
Definition: cIUnkPtr.h:56
void ** get_PPtrV()
Definition: cIUnkPtr.h:135
void put_Ptr(TYPE *p2)
Definition: cIUnkPtr.h:152
cIUnkPtr()
Construct and destruction.
Definition: cIUnkPtr.h:79
cIUnkPtr(const THIS_t &ref)
Definition: cIUnkPtr.h:92
TYPE & operator*() const
Accessor ops.
Definition: cIUnkPtr.h:248
~cIUnkPtr()
Definition: cIUnkPtr.h:113
TYPE * operator->() const
Definition: cIUnkPtr.h:253
TYPE * GetInterfacePtr() const
Definition: cIUnkPtr.h:146
int ReleasePtr()
Definition: cIUnkPtr.h:207
HRESULT SetQI(IUnknown *p2, const IID &riid)
Definition: cIUnkPtr.h:161
Definition: cIUnkPtr.h:23
Definition: cLogAppender.h:168
Definition: cPtrFacade.h:19
IUnknown * m_p
Pointer to some object of TYPE.
Definition: cPtrFacade.h:28
bool isValidPtr() const noexcept
Definition: cPtrFacade.h:41
TYPE * get_Ptr() const noexcept
Definition: cPtrFacade.h:53
Definition: cPtrTrace.h:21
Definition: IUnknown.h:68
< The main namespace for all Core functions.
Definition: GrayCore.cpp:14
__DECL_IMPORT cIUnkPtr cIUnkBasePtr
Definition: cIUnkPtr.h:260
const cDebugSourceLine & src
Definition: cDebugAssert.h:51
Definition: cDebugAssert.h:29
Definition: IUnknown.h:34