ReactOS 0.4.15-dev-7705-g2320c37
unknownbase.h
Go to the documentation of this file.
1#ifndef APITESTS_UNKNOWNBASE_H
2#define APITESTS_UNKNOWNBASE_H
3
4template<typename Interface>
5class CUnknownBase : public Interface
6{
9protected:
10 virtual const QITAB* GetQITab() = 0;
11public:
12
13 CUnknownBase(bool autoDelete = true, LONG initialRef = 0)
14 : m_lRef(initialRef),
15 m_AutoDelete(autoDelete)
16 {
17 }
18
20 {
22 }
23
25 {
26 long newref = InterlockedDecrement( &m_lRef );
27 if (m_AutoDelete && newref<=0)
28 {
29 delete this;
30 }
31 return newref;
32 }
33
35 {
36 return QISearch(this, GetQITab(), riid, ppv);
37 }
38
39 virtual ~CUnknownBase() {}
40
41 LONG GetRef() const
42 {
43 return m_lRef;
44 }
45};
46
47#endif // APITESTS_UNKNOWNBASE_H
#define InterlockedIncrement
Definition: armddk.h:53
#define InterlockedDecrement
Definition: armddk.h:52
#define STDMETHODCALLTYPE
Definition: bdasup.h:9
bool m_AutoDelete
Definition: unknownbase.h:8
LONG GetRef() const
Definition: unknownbase.h:41
ULONG STDMETHODCALLTYPE Release()
Definition: unknownbase.h:24
virtual const QITAB * GetQITab()=0
HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void **ppv)
Definition: unknownbase.h:34
CUnknownBase(bool autoDelete=true, LONG initialRef=0)
Definition: unknownbase.h:13
ULONG STDMETHODCALLTYPE AddRef()
Definition: unknownbase.h:19
virtual ~CUnknownBase()
Definition: unknownbase.h:39
HRESULT WINAPI QISearch(void *base, const QITAB *table, REFIID riid, void **ppv)
Definition: ordinal.c:2392
REFIID riid
Definition: atlbase.h:39
REFIID LPVOID * ppv
Definition: atlbase.h:39
long LONG
Definition: pedump.c:60
#define REFIID
Definition: guiddef.h:118
uint32_t ULONG
Definition: typedefs.h:59
_Must_inspect_result_ _In_ WDFDEVICE _In_ LPCGUID _Out_ PINTERFACE Interface
Definition: wdffdo.h:465