2017-10-11 00:41:56 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <atomic>
|
|
|
|
|
|
|
|
#include "com_include.h"
|
|
|
|
|
|
|
|
#define COM_QUERY_IFACE(riid, ppvObject, Iface) \
|
2017-10-11 15:31:36 +02:00
|
|
|
do { \
|
|
|
|
if (riid == __uuidof(Iface)) { \
|
|
|
|
this->AddRef(); \
|
|
|
|
*ppvObject = static_cast<Iface*>(this); \
|
|
|
|
return S_OK; \
|
|
|
|
} \
|
|
|
|
} while (0)
|
2017-12-10 00:55:30 +01:00
|
|
|
|
2017-10-11 00:41:56 +02:00
|
|
|
namespace dxvk {
|
|
|
|
|
|
|
|
template<typename... Base>
|
|
|
|
class ComObject : public Base... {
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
virtual ~ComObject() { }
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
ULONG STDMETHODCALLTYPE AddRef() {
|
2017-10-11 00:41:56 +02:00
|
|
|
return ++m_refCount;
|
|
|
|
}
|
|
|
|
|
2017-12-12 12:50:52 +01:00
|
|
|
ULONG STDMETHODCALLTYPE Release() {
|
2017-10-11 00:41:56 +02:00
|
|
|
ULONG refCount = --m_refCount;
|
2017-12-09 22:20:40 +01:00
|
|
|
if (refCount == 0) {
|
2017-12-09 23:20:31 +01:00
|
|
|
m_refCount += 0x80000000u;
|
2017-10-11 00:41:56 +02:00
|
|
|
delete this;
|
2017-12-09 22:20:40 +01:00
|
|
|
}
|
2017-10-11 00:41:56 +02:00
|
|
|
return refCount;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
std::atomic<ULONG> m_refCount = { 0ul };
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|