30template <
class Base, const IID *pi
id,
class T,
class Copy,
class ThreadModel = CComObjectThreadModel>
33#if defined(_WINDLL) | defined(_USRDLL)
34#define DECLARE_CLASSFACTORY_EX(cf) typedef ATL::CComCreator<ATL::CComObjectCached<cf> > _ClassFactoryCreatorClass;
37#define DECLARE_CLASSFACTORY_EX(cf) typedef ATL::CComCreator<ATL::CComObjectNoLock<cf>> _ClassFactoryCreatorClass;
39#define DECLARE_CLASSFACTORY() DECLARE_CLASSFACTORY_EX(ATL::CComClassFactory)
40#define DECLARE_CLASSFACTORY_SINGLETON(obj) DECLARE_CLASSFACTORY_EX(ATL::CComClassFactorySingleton<obj>)
98template <
class ThreadModel>
102 typename ThreadModel::AutoDeleteCriticalSection
m_critsec;
111 return ThreadModel::Increment(&
m_dwRef);
117 return ThreadModel::Decrement(&
m_dwRef);
147 this->FinalRelease();
148 _pAtlModule->Unlock();
153 return this->InternalAddRef();
160 newRefCount = this->InternalRelease();
161 if (newRefCount == 0)
168 return this->_InternalQueryInterface(iid,
ppvObject);
183 if (newInstance !=
NULL)
185 newInstance->SetVoid(
NULL);
186 newInstance->InternalFinalConstructAddRef();
187 hResult = newInstance->_AtlInitialConstruct();
189 hResult = newInstance->FinalConstruct();
191 hResult = newInstance->_AtlFinalConstruct();
192 newInstance->InternalFinalConstructRelease();
236template <
class contained>
250 _pAtlModule->Unlock();
264 return this->InternalAddRef();
270 newRefCount = this->InternalRelease();
271 if (newRefCount == 0)
281 *
ppvObject =
reinterpret_cast<void*
>(
this);
299 if (newInstance !=
NULL)
301 newInstance->SetVoid(
NULL);
302 newInstance->InternalFinalConstructAddRef();
303 hResult = newInstance->_AtlInitialConstruct();
307 hResult = newInstance->_AtlFinalConstruct();
308 newInstance->InternalFinalConstructRelease();
320template <
class contained>
327 :
m_contained(pv ? static_cast<contained*>(pv) : this)
335 _pAtlModule->Unlock();
349 return this->InternalAddRef();
355 newRefCount = this->InternalRelease();
356 if (newRefCount == 0)
366 *
ppvObject =
reinterpret_cast<void*
>(
this);
384 if (newInstance !=
NULL)
386 newInstance->SetVoid(
NULL);
387 newInstance->InternalFinalConstructAddRef();
388 hResult = newInstance->_AtlInitialConstruct();
392 hResult = newInstance->_AtlFinalConstruct();
393 newInstance->InternalFinalConstructRelease();
405template <HRESULT hResult>
436 ATLTRY(newInstance =
new T1(pv))
437 if (newInstance !=
NULL)
439 newInstance->SetVoid(pv);
440 newInstance->InternalFinalConstructAddRef();
441 hResult = newInstance->_AtlInitialConstruct();
443 hResult = newInstance->FinalConstruct();
445 hResult = newInstance->_AtlFinalConstruct();
446 newInstance->InternalFinalConstructRelease();
459template <
class T1,
class T2>
470 return T2::CreateInstance(pv,
riid,
ppv);
484 this->FinalRelease();
491 newRefCount = this->InternalAddRef();
492 if (newRefCount == 2)
501 newRefCount = this->InternalRelease();
502 if (newRefCount == 0)
504 else if (newRefCount == 1)
505 _pAtlModule->Unlock();
511 return this->_InternalQueryInterface(iid,
ppvObject);
526 if (newInstance !=
NULL)
528 newInstance->SetVoid(
NULL);
529 newInstance->InternalFinalConstructAddRef();
530 hResult = newInstance->_AtlInitialConstruct();
532 hResult = newInstance->FinalConstruct();
534 hResult = newInstance->_AtlFinalConstruct();
535 newInstance->InternalFinalConstructRelease();
558 this->FinalRelease();
563 return this->InternalAddRef();
568 ULONG newRefCount = this->InternalRelease();
569 if (newRefCount == 0)
576 return this->_InternalQueryInterface(iid,
ppvObject);
581#define BEGIN_COM_MAP(x) \
583 typedef x _ComMapClass; \
584 HRESULT _InternalQueryInterface(REFIID iid, void **ppvObject) \
586 return this->InternalQueryInterface(this, _GetEntries(), iid, ppvObject); \
588 const static ATL::_ATL_INTMAP_ENTRY *WINAPI _GetEntries() \
590 static const ATL::_ATL_INTMAP_ENTRY _entries[] = {
592#define END_COM_MAP() \
597 virtual ULONG STDMETHODCALLTYPE AddRef() = 0; \
598 virtual ULONG STDMETHODCALLTYPE Release() = 0; \
599 STDMETHOD(QueryInterface)(REFIID, void **) = 0;
601#define COM_INTERFACE_ENTRY_IID(iid, x) \
602 {&iid, offsetofclass(x, _ComMapClass), _ATL_SIMPLEMAPENTRY},
604#define COM_INTERFACE_ENTRY(x) \
606 offsetofclass(x, _ComMapClass), \
607 _ATL_SIMPLEMAPENTRY},
609#define COM_INTERFACE_ENTRY2_IID(iid, x, x2) \
611 reinterpret_cast<DWORD_PTR>(static_cast<x *>(static_cast<x2 *>(reinterpret_cast<_ComMapClass *>(_ATL_PACKING)))) - _ATL_PACKING, \
612 _ATL_SIMPLEMAPENTRY},
614#define COM_INTERFACE_ENTRY_BREAK(x) \
619#define COM_INTERFACE_ENTRY_NOINTERFACE(x) \
624#define COM_INTERFACE_ENTRY_FUNC(iid, dw, func) \
629#define COM_INTERFACE_ENTRY_FUNC_BLIND(dw, func) \
634#define COM_INTERFACE_ENTRY_CHAIN(classname) \
636 reinterpret_cast<DWORD>(&_CComChainData<classname, _ComMapClass>::data), \
639#define DECLARE_NO_REGISTRY()\
640 static HRESULT WINAPI UpdateRegistry(BOOL ) \
645#define DECLARE_REGISTRY_RESOURCEID(x) \
646 static HRESULT WINAPI UpdateRegistry(BOOL bRegister) \
648 return ATL::_pAtlModule->UpdateRegistryFromResource(x, bRegister); \
651#define DECLARE_NOT_AGGREGATABLE(x) \
653 typedef ATL::CComCreator2<ATL::CComCreator<ATL::CComObject<x> >, ATL::CComFailCreator<CLASS_E_NOAGGREGATION> > _CreatorClass;
655#define DECLARE_AGGREGATABLE(x) \
657 typedef ATL::CComCreator2<ATL::CComCreator<ATL::CComObject<x> >, ATL::CComCreator<ATL::CComAggObject<x> > > _CreatorClass;
659#define DECLARE_ONLY_AGGREGATABLE(x) \
661 typedef ATL::CComCreator2<ATL::CComFailCreator<E_FAIL>, ATL::CComCreator<ATL::CComAggObject<x> > > _CreatorClass;
663#define DECLARE_POLY_AGGREGATABLE(x) \
665 typedef ATL::CComCreator<ATL::CComPolyObject<x> > _CreatorClass;
667#define COM_INTERFACE_ENTRY_AGGREGATE(iid, punk) \
669 (DWORD_PTR)offsetof(_ComMapClass, punk), \
672#define DECLARE_GET_CONTROLLING_UNKNOWN() \
674 virtual IUnknown *GetControllingUnknown() \
676 return GetUnknown(); \
679#define DECLARE_PROTECT_FINAL_CONSTRUCT() \
680 void InternalFinalConstructAddRef() \
684 void InternalFinalConstructRelease() \
689#define BEGIN_OBJECT_MAP(x) static ATL::_ATL_OBJMAP_ENTRY x[] = {
691#define END_OBJECT_MAP() {NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL, NULL}};
693#define OBJECT_ENTRY(clsid, class) \
696 class::UpdateRegistry, \
697 class::_ClassFactoryCreatorClass::CreateInstance, \
698 class::_CreatorClass::CreateInstance, \
701 class::GetObjectDescription, \
702 class::GetCategoryMap, \
707#define OBJECT_ENTRY_AUTO(clsid, class) \
708 ATL::_ATL_OBJMAP_ENTRY __objMap_##class = { \
710 class ::UpdateRegistry, \
711 class ::_ClassFactoryCreatorClass::CreateInstance, \
712 class ::_CreatorClass::CreateInstance, \
715 class ::GetObjectDescription, \
716 class ::GetCategoryMap, \
717 class ::ObjectMain}; \
718 extern "C" _ATLALLOC("ATL$__m") ATL::_ATL_OBJMAP_ENTRY *const __pobjMap_##class = &__objMap_##class; \
719 OBJECT_ENTRY_PRAGMA(class)
757 _pAtlModule->Unlock();
794 if (pUnkOuter !=
NULL)
827template <
class T, const CLSID *pcls
id = &CLSID_NULL>
871 static void init(CONNECTDATA *)
912template <
class Base, const IID *pi
id,
class T,
class Copy>
958 for (sourcePtr =
begin; sourcePtr !=
end; sourcePtr++)
961 hResult = Copy::copy(destPtr, sourcePtr);
965 while (cleanupPtr < destPtr)
966 Copy::destroy(cleanupPtr++);
993 if (pceltFetched !=
NULL)
997 if (rgelt ==
NULL || (celt != 1 && pceltFetched ==
NULL))
1003 if (celt < numAvailable)
1006 numToFetch = numAvailable;
1007 if (pceltFetched !=
NULL)
1008 *pceltFetched = numToFetch;
1010 while (numToFetch != 0)
1012 hResult = Copy::copy(rgeltTemp,
m_iter);
1015 while (rgelt < rgeltTemp)
1016 Copy::destroy(rgelt++);
1017 if (pceltFetched !=
NULL)
1025 if (numAvailable < celt)
1039 if (celt < numAvailable)
1042 numToSkip = numAvailable;
1044 if (numAvailable < celt)
1070 newInstance->m_iter =
m_iter;
1071 hResult = newInstance->_InternalQueryInterface(*piid, (
void **)ppEnum);
1088template <
class Base, const IID *pi
id,
class T,
class Copy,
class ThreadModel>
1102#ifndef _DEFAULT_VECTORLENGTH
1103#define _DEFAULT_VECTORLENGTH 4
1136 if (nIndex >= 0 && nIndex <
m_nSize)
1145 if (dwCookie != 0 && dwCookie <=
static_cast<DWORD>(
m_nSize))
1146 return GetAt(dwCookie - 1);
1157 if (ppFind !=
NULL && *ppFind !=
NULL)
1182 if (newArray ==
NULL)
1184 memset(newArray, 0, newSize);
1200 if (newArray ==
NULL)
1214 index = dwCookie - 1;
1240template <const IID *pi
id>
1249template<
class T, const IID *pi
id,
class CDV = CComDynamicUnkArray>
1300 pThis =
static_cast<T *
>(
this);
1310 if (pdwCookie !=
NULL)
1312 if (pUnkSink ==
NULL || pdwCookie ==
NULL)
1315 hResult = pUnkSink->
QueryInterface(interfaceID,
reinterpret_cast<void **
>(&adviseTarget));
1318 *pdwCookie =
m_vec.Add(adviseTarget);
1319 if (*pdwCookie != 0)
1337 adviseTarget =
m_vec.GetUnknown(dwCookie);
1338 if (
m_vec.Remove(dwCookie))
1340 if (adviseTarget !=
NULL)
1352 CONNECTDATA *itemBuffer;
1353 CONNECTDATA *itemBufferEnd;
1363 if (itemBuffer ==
NULL)
1365 itemBufferEnd = itemBuffer;
1371 itemBufferEnd->pUnk = *
x;
1372 itemBufferEnd->dwCookie =
m_vec.GetCookie(
x);
1377 if (newEnumerator ==
NULL)
1382 delete newEnumerator;
1398 int connectionPointCount;
1410 entryPtr = T::GetConnMap(&connectionPointCount);
1412 if (itemBuffer ==
NULL)
1422 entryPtr = handlerFunction(
NULL);
1432 if (newEnumerator ==
NULL)
1434 delete [] itemBuffer;
1441 delete newEnumerator;
1457 entryPtr = T::GetConnMap(
NULL);
1464 entryPtr = handlerFunction(
NULL);
1471 *ppCP = connectionPoint;
1472 connectionPoint->
AddRef();
1483#define BEGIN_CONNECTION_POINT_MAP(x) \
1484 typedef x _atl_conn_classtype; \
1485 static const ATL::_ATL_CONNMAP_ENTRY *GetConnMap(int *pnEntries) { \
1486 static const ATL::_ATL_CONNMAP_ENTRY _entries[] = {
1488#define END_CONNECTION_POINT_MAP() \
1489 {(DWORD_PTR)-1} }; \
1491 *pnEntries = sizeof(_entries) / sizeof(ATL::_ATL_CONNMAP_ENTRY) - 1; \
1494#define CONNECTION_POINT_ENTRY(iid) \
1495 {offsetofclass(ATL::_ICPLocator<&iid>, _atl_conn_classtype) - \
1496 offsetofclass(ATL::IConnectionPointContainerImpl<_atl_conn_classtype>, _atl_conn_classtype)},
1525 if (wMajor == 0xffff && wMinor == 0xffff)
1526 OutputDebugStringA(
"IDispatchImpl: not fully implemented, missing functionality to load TLB from file!\r\n");
1546 if (pctinfo ==
NULL)
1557 if (ppTInfo ==
NULL)
1563 (*ppTInfo)->AddRef();
1572 hr =
m_pTypeInfo->GetIDsOfNames(rgszNames, cNames, rgDispId);
1580 hr =
m_pTypeInfo->Invoke(
this, dispIdMember,
wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
const GUID IID_IClassFactory
#define STDMETHODCALLTYPE
CComContainedObject< contained > m_contained
STDMETHOD_(ULONG, Release)()
static HRESULT WINAPI CreateInstance(IUnknown *punkOuter, CComAggObject< contained > **pp)
CComAggObject(void *pv=NULL)
STDMETHOD_(ULONG, AddRef)()
STDMETHOD() QueryInterface(REFIID iid, void **ppvObject)
CComClassFactorySingleton()
STDMETHOD() CreateInstance(LPUNKNOWN pUnkOuter, REFIID riid, void **ppvObj)
STDMETHOD() CreateInstance(LPUNKNOWN pUnkOuter, REFIID riid, void **ppvObj)
STDMETHOD() LockServer(BOOL fLock)
_ATL_CREATORFUNC * m_pfnCreateInstance
virtual ~CComClassFactory()
static LPCTSTR WINAPI GetObjectDescription()
CComContainedObject(void *pv=NULL)
STDMETHOD() QueryInterface(REFIID iid, void **ppvObject)
STDMETHOD_(ULONG, AddRef)()
IUnknown * GetControllingUnknown()
STDMETHOD_(ULONG, Release)()
static HRESULT WINAPI CreateInstance(void *pv, REFIID riid, LPVOID *ppv)
static HRESULT WINAPI CreateInstance(void *pv, REFIID riid, LPVOID *ppv)
BOOL Remove(DWORD dwCookie)
IUnknown *WINAPI GetUnknown(DWORD dwCookie)
IUnknown * GetAt(int nIndex)
CComDynamicUnkArray(const CComDynamicUnkArray &)
DWORD WINAPI GetCookie(IUnknown **ppFind)
DWORD Add(IUnknown *pUnk)
CComDynamicUnkArray & operator=(const CComDynamicUnkArray &)
static HRESULT WINAPI CreateInstance(void *, REFIID, LPVOID *ppv)
static HRESULT WINAPI CreateInstance(CComObjectCached< Base > **pp)
STDMETHOD_(ULONG, AddRef)()
CComObjectCached(void *=NULL)
STDMETHOD_(ULONG, Release)()
virtual ~CComObjectCached()
STDMETHOD() QueryInterface(REFIID iid, void **ppvObject)
STDMETHOD_(ULONG, AddRef)()
STDMETHOD_(ULONG, Release)()
STDMETHOD() QueryInterface(REFIID iid, void **ppvObject)
virtual ~CComObjectNoLock()
CComObjectNoLock(void *=NULL)
void InternalFinalConstructAddRef()
static HRESULT WINAPI InternalQueryInterface(void *pThis, const _ATL_INTMAP_ENTRY *pEntries, REFIID iid, void **ppvObject)
static void WINAPI ObjectMain(bool)
void InternalFinalConstructRelease()
static const struct _ATL_CATMAP_ENTRY * GetCategoryMap()
HRESULT _AtlFinalConstruct()
HRESULT _AtlInitialConstruct()
ThreadModel::AutoDeleteCriticalSection m_critsec
static HRESULT WINAPI CreateInstance(CComObject< Base > **pp)
STDMETHOD_(ULONG, Release)()
STDMETHOD_(ULONG, AddRef)()
STDMETHOD() QueryInterface(REFIID iid, void **ppvObject)
STDMETHOD_(ULONG, AddRef)()
CComPolyObject(void *pv=NULL)
static HRESULT WINAPI CreateInstance(IUnknown *punkOuter, CComPolyObject< contained > **pp)
STDMETHOD() QueryInterface(REFIID iid, void **ppvObject)
STDMETHOD_(ULONG, Release)()
virtual ~CComPolyObject()
CComContainedObject< contained > m_contained
const _ATL_CONNMAP_ENTRY *(* handlerFunctionType)(int *)
CComEnum< IEnumConnectionPoints, &IID_IEnumConnectionPoints, IConnectionPoint *, _CopyInterface< IConnectionPoint > > CComEnumConnectionPoints
STDMETHOD() EnumConnectionPoints(IEnumConnectionPoints **ppEnum)
STDMETHOD() FindConnectionPoint(REFIID riid, IConnectionPoint **ppCP)
STDMETHOD() Unadvise(DWORD dwCookie)
STDMETHOD() _LocCPQueryInterface(REFIID riid, void **ppvObject)
STDMETHOD() Advise(IUnknown *pUnkSink, DWORD *pdwCookie)
STDMETHOD() GetConnectionInterface(IID *piid2)
STDMETHOD() GetConnectionPointContainer(IConnectionPointContainer **ppCPC)
CComEnum< IEnumConnections, &IID_IEnumConnections, CONNECTDATA, _Copy< CONNECTDATA > > CComEnumConnections
STDMETHOD() GetTypeInfoCount(UINT *pctinfo)
CComPtr< ITypeInfo > m_pTypeInfo
STDMETHOD() Invoke(DISPID dispIdMember, REFIID, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
STDMETHOD() EnsureTILoaded(LCID lcid)
STDMETHOD() GetTypeInfo(UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
STDMETHOD() GetIDsOfNames(REFIID, LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
static HRESULT copy(T **pTo, T **pFrom)
static void destroy(T **p)
static HRESULT copy(CONNECTDATA *pTo, const CONNECTDATA *pFrom)
static void destroy(CONNECTDATA *p)
static void init(CONNECTDATA *)
static HRESULT copy(T *pTo, const T *pFrom)
virtual ULONG STDMETHODCALLTYPE Release()=0
STDMETHOD() _LocCPQueryInterface(REFIID riid, void **ppvObject)=0
virtual ULONG STDMETHODCALLTYPE AddRef()=0
HRESULT WINAPI LoadRegTypeLib(REFGUID rguid, WORD wVerMajor, WORD wVerMinor, LCID lcid, ITypeLib **ppTLib)
static void *static void *static LPDIRECTPLAY IUnknown * pUnk
GLint GLint GLint GLint GLint x
void WINAPI SHIM_OBJ_NAME() OutputDebugStringA(LPCSTR lpOutputString)
HRESULT GetConnectionInterface([out] IID *pIID)
HRESULT QueryInterface([in] REFIID riid, [out, iid_is(riid)] void **ppvObject)
#define COM_INTERFACE_ENTRY_IID(iid, x)
#define _DEFAULT_VECTORLENGTH
#define DECLARE_CLASSFACTORY()
#define memcpy(s1, s2, n)
static ULONG WINAPI AddRef(IStream *iface)
static VARIANTARG static DISPID
HRESULT WINAPI AtlInternalQueryInterface(void *pThis, const _ATL_INTMAP_ENTRY *pEntries, REFIID iid, void **ppvObject)
BOOL WINAPI InlineIsEqualUnknown(REFGUID rguid1)
#define CONNECT_E_CANNOTCONNECT
#define CONNECT_E_ADVISELIMIT
#define CONNECT_E_NOCONNECTION
const GUID IID_IEnumConnections
const GUID IID_IConnectionPointContainer
const GUID IID_IConnectionPoint
const GUID IID_IEnumConnectionPoints
#define InlineIsEqualGUID(rguid1, rguid2)
#define IsEqualCLSID(rclsid1, rclsid2)
_In_ DWORD _Out_ _In_ WORD wFlags
_In_ void _In_ PCCERT_CONTEXT _In_opt_ LPFILETIME _In_ DWORD _In_ DWORD _Outptr_opt_ void ** ppvObject
#define CLASS_E_NOAGGREGATION