-
Notifications
You must be signed in to change notification settings - Fork 2
/
classfactory.cpp
59 lines (47 loc) · 1016 Bytes
/
classfactory.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#include "classfactory.h"
#include "profiler.h"
ClassFactory::ClassFactory()
: m_referenceCount(1)
{
}
ClassFactory::~ClassFactory()
{
}
HRESULT STDMETHODCALLTYPE ClassFactory::QueryInterface(REFIID riid, void **ppvObject)
{
if (riid == IID_IUnknown || riid == IID_IClassFactory)
{
*ppvObject = this;
this->AddRef();
return S_OK;
}
*ppvObject = NULL;
return E_NOINTERFACE;
}
ULONG STDMETHODCALLTYPE ClassFactory::AddRef(void)
{
return __sync_fetch_and_add(&m_referenceCount, 1) + 1;
}
ULONG STDMETHODCALLTYPE ClassFactory::Release(void)
{
LONG result = __sync_fetch_and_sub(&m_referenceCount, 1) - 1;
if (result == 0)
{
delete this;
}
return result;
}
HRESULT STDMETHODCALLTYPE ClassFactory::CreateInstance(IUnknown *pUnkOuter, REFIID riid, void **ppvObject)
{
if (riid == IID_ICorProfilerCallback2)
{
if (ppvObject != NULL)
*ppvObject = new Profiler();
return S_OK;
}
return E_NOINTERFACE;
}
HRESULT STDMETHODCALLTYPE ClassFactory::LockServer(BOOL fLock)
{
return S_OK;
}