30template <
class Base, const IID *pi
id,
class T,
class Copy,
class ThreadModel = CComObjectThreadModel>
33#define DECLARE_CLASSFACTORY_EX(cf) typedef ATL::CComCreator<ATL::CComObjectCached<cf> > _ClassFactoryCreatorClass;
34#define DECLARE_CLASSFACTORY() DECLARE_CLASSFACTORY_EX(ATL::CComClassFactory)
35#define DECLARE_CLASSFACTORY_SINGLETON(obj) DECLARE_CLASSFACTORY_EX(ATL::CComClassFactorySingleton<obj>)
93template <
class ThreadModel>
97 typename ThreadModel::AutoDeleteCriticalSection
m_critsec;
106 return ThreadModel::Increment(&
m_dwRef);
112 return ThreadModel::Decrement(&
m_dwRef);
142 this->FinalRelease();
143 _pAtlModule->Unlock();
148 return this->InternalAddRef();
155 newRefCount = this->InternalRelease();
156 if (newRefCount == 0)
163 return this->_InternalQueryInterface(iid,
ppvObject);
178 if (newInstance !=
NULL)
180 newInstance->SetVoid(
NULL);
181 newInstance->InternalFinalConstructAddRef();
182 hResult = newInstance->_AtlInitialConstruct();
184 hResult = newInstance->FinalConstruct();
186 hResult = newInstance->_AtlFinalConstruct();
187 newInstance->InternalFinalConstructRelease();
231template <
class contained>
245 _pAtlModule->Unlock();
259 return this->InternalAddRef();
265 newRefCount = this->InternalRelease();
266 if (newRefCount == 0)
276 *
ppvObject =
reinterpret_cast<void*
>(
this);
294 if (newInstance !=
NULL)
296 newInstance->SetVoid(
NULL);
297 newInstance->InternalFinalConstructAddRef();
298 hResult = newInstance->_AtlInitialConstruct();
302 hResult = newInstance->_AtlFinalConstruct();
303 newInstance->InternalFinalConstructRelease();
315template <
class contained>
322 :
m_contained(pv ? static_cast<contained*>(pv) : this)
330 _pAtlModule->Unlock();
344 return this->InternalAddRef();
350 newRefCount = this->InternalRelease();
351 if (newRefCount == 0)
361 *
ppvObject =
reinterpret_cast<void*
>(
this);
379 if (newInstance !=
NULL)
381 newInstance->SetVoid(
NULL);
382 newInstance->InternalFinalConstructAddRef();
383 hResult = newInstance->_AtlInitialConstruct();
387 hResult = newInstance->_AtlFinalConstruct();
388 newInstance->InternalFinalConstructRelease();
400template <HRESULT hResult>
431 ATLTRY(newInstance =
new T1(pv))
432 if (newInstance !=
NULL)
434 newInstance->SetVoid(pv);
435 newInstance->InternalFinalConstructAddRef();
436 hResult = newInstance->_AtlInitialConstruct();
438 hResult = newInstance->FinalConstruct();
440 hResult = newInstance->_AtlFinalConstruct();
441 newInstance->InternalFinalConstructRelease();
454template <
class T1,
class T2>
465 return T2::CreateInstance(pv,
riid,
ppv);
479 this->FinalRelease();
486 newRefCount = this->InternalAddRef();
487 if (newRefCount == 2)
496 newRefCount = this->InternalRelease();
497 if (newRefCount == 0)
499 else if (newRefCount == 1)
500 _pAtlModule->Unlock();
506 return this->_InternalQueryInterface(iid,
ppvObject);
521 if (newInstance !=
NULL)
523 newInstance->SetVoid(
NULL);
524 newInstance->InternalFinalConstructAddRef();
525 hResult = newInstance->_AtlInitialConstruct();
527 hResult = newInstance->FinalConstruct();
529 hResult = newInstance->_AtlFinalConstruct();
530 newInstance->InternalFinalConstructRelease();
542#define BEGIN_COM_MAP(x) \
544 typedef x _ComMapClass; \
545 HRESULT _InternalQueryInterface(REFIID iid, void **ppvObject) \
547 return this->InternalQueryInterface(this, _GetEntries(), iid, ppvObject); \
549 const static ATL::_ATL_INTMAP_ENTRY *WINAPI _GetEntries() \
551 static const ATL::_ATL_INTMAP_ENTRY _entries[] = {
553#define END_COM_MAP() \
558 virtual ULONG STDMETHODCALLTYPE AddRef() = 0; \
559 virtual ULONG STDMETHODCALLTYPE Release() = 0; \
560 STDMETHOD(QueryInterface)(REFIID, void **) = 0;
562#define COM_INTERFACE_ENTRY_IID(iid, x) \
563 {&iid, offsetofclass(x, _ComMapClass), _ATL_SIMPLEMAPENTRY},
565#define COM_INTERFACE_ENTRY(x) \
567 offsetofclass(x, _ComMapClass), \
568 _ATL_SIMPLEMAPENTRY},
570#define COM_INTERFACE_ENTRY2_IID(iid, x, x2) \
572 reinterpret_cast<DWORD_PTR>(static_cast<x *>(static_cast<x2 *>(reinterpret_cast<_ComMapClass *>(_ATL_PACKING)))) - _ATL_PACKING, \
573 _ATL_SIMPLEMAPENTRY},
575#define COM_INTERFACE_ENTRY_BREAK(x) \
580#define COM_INTERFACE_ENTRY_NOINTERFACE(x) \
585#define COM_INTERFACE_ENTRY_FUNC(iid, dw, func) \
590#define COM_INTERFACE_ENTRY_FUNC_BLIND(dw, func) \
595#define COM_INTERFACE_ENTRY_CHAIN(classname) \
597 reinterpret_cast<DWORD>(&_CComChainData<classname, _ComMapClass>::data), \
600#define DECLARE_NO_REGISTRY()\
601 static HRESULT WINAPI UpdateRegistry(BOOL ) \
606#define DECLARE_REGISTRY_RESOURCEID(x) \
607 static HRESULT WINAPI UpdateRegistry(BOOL bRegister) \
609 return ATL::_pAtlModule->UpdateRegistryFromResource(x, bRegister); \
612#define DECLARE_NOT_AGGREGATABLE(x) \
614 typedef ATL::CComCreator2<ATL::CComCreator<ATL::CComObject<x> >, ATL::CComFailCreator<CLASS_E_NOAGGREGATION> > _CreatorClass;
616#define DECLARE_AGGREGATABLE(x) \
618 typedef ATL::CComCreator2<ATL::CComCreator<ATL::CComObject<x> >, ATL::CComCreator<ATL::CComAggObject<x> > > _CreatorClass;
620#define DECLARE_ONLY_AGGREGATABLE(x) \
622 typedef ATL::CComCreator2<ATL::CComFailCreator<E_FAIL>, ATL::CComCreator<ATL::CComAggObject<x> > > _CreatorClass;
624#define DECLARE_POLY_AGGREGATABLE(x) \
626 typedef ATL::CComCreator<ATL::CComPolyObject<x> > _CreatorClass;
628#define COM_INTERFACE_ENTRY_AGGREGATE(iid, punk) \
630 (DWORD_PTR)offsetof(_ComMapClass, punk), \
633#define DECLARE_GET_CONTROLLING_UNKNOWN() \
635 virtual IUnknown *GetControllingUnknown() \
637 return GetUnknown(); \
640#define DECLARE_PROTECT_FINAL_CONSTRUCT() \
641 void InternalFinalConstructAddRef() \
645 void InternalFinalConstructRelease() \
650#define BEGIN_OBJECT_MAP(x) static ATL::_ATL_OBJMAP_ENTRY x[] = {
652#define END_OBJECT_MAP() {NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL, NULL}};
654#define OBJECT_ENTRY(clsid, class) \
657 class::UpdateRegistry, \
658 class::_ClassFactoryCreatorClass::CreateInstance, \
659 class::_CreatorClass::CreateInstance, \
662 class::GetObjectDescription, \
663 class::GetCategoryMap, \
700 _pAtlModule->Unlock();
737 if (pUnkOuter !=
NULL)
770template <
class T, const CLSID *pcls
id = &CLSID_NULL>
813 static void init(CONNECTDATA *)
854template <
class Base, const IID *pi
id,
class T,
class Copy>
900 for (sourcePtr =
begin; sourcePtr !=
end; sourcePtr++)
903 hResult = Copy::copy(destPtr, sourcePtr);
907 while (cleanupPtr < destPtr)
908 Copy::destroy(cleanupPtr++);
935 if (pceltFetched !=
NULL)
939 if (rgelt ==
NULL || (celt != 1 && pceltFetched ==
NULL))
945 if (celt < numAvailable)
948 numToFetch = numAvailable;
949 if (pceltFetched !=
NULL)
950 *pceltFetched = numToFetch;
952 while (numToFetch != 0)
954 hResult = Copy::copy(rgeltTemp,
m_iter);
957 while (rgelt < rgeltTemp)
958 Copy::destroy(rgelt++);
959 if (pceltFetched !=
NULL)
967 if (numAvailable < celt)
981 if (celt < numAvailable)
984 numToSkip = numAvailable;
986 if (numAvailable < celt)
1012 newInstance->m_iter =
m_iter;
1013 hResult = newInstance->_InternalQueryInterface(*piid, (
void **)ppEnum);
1030template <
class Base, const IID *pi
id,
class T,
class Copy,
class ThreadModel>
1044#ifndef _DEFAULT_VECTORLENGTH
1045#define _DEFAULT_VECTORLENGTH 4
1078 if (nIndex >= 0 && nIndex <
m_nSize)
1087 if (dwCookie != 0 && dwCookie <=
static_cast<DWORD>(
m_nSize))
1088 return GetAt(dwCookie - 1);
1099 if (ppFind !=
NULL && *ppFind !=
NULL)
1124 if (newArray ==
NULL)
1126 memset(newArray, 0, newSize);
1142 if (newArray ==
NULL)
1156 index = dwCookie - 1;
1182template <const IID *pi
id>
1191template<
class T, const IID *pi
id,
class CDV = CComDynamicUnkArray>
1242 pThis =
static_cast<T *
>(
this);
1252 if (pdwCookie !=
NULL)
1254 if (pUnkSink ==
NULL || pdwCookie ==
NULL)
1257 hResult = pUnkSink->
QueryInterface(interfaceID,
reinterpret_cast<void **
>(&adviseTarget));
1260 *pdwCookie =
m_vec.Add(adviseTarget);
1261 if (*pdwCookie != 0)
1279 adviseTarget =
m_vec.GetUnknown(dwCookie);
1280 if (
m_vec.Remove(dwCookie))
1282 if (adviseTarget !=
NULL)
1294 CONNECTDATA *itemBuffer;
1295 CONNECTDATA *itemBufferEnd;
1305 if (itemBuffer ==
NULL)
1307 itemBufferEnd = itemBuffer;
1313 itemBufferEnd->pUnk = *
x;
1314 itemBufferEnd->dwCookie =
m_vec.GetCookie(
x);
1319 if (newEnumerator ==
NULL)
1324 delete newEnumerator;
1340 int connectionPointCount;
1352 entryPtr = T::GetConnMap(&connectionPointCount);
1354 if (itemBuffer ==
NULL)
1364 entryPtr = handlerFunction(
NULL);
1374 if (newEnumerator ==
NULL)
1376 delete [] itemBuffer;
1383 delete newEnumerator;
1399 entryPtr = T::GetConnMap(
NULL);
1406 entryPtr = handlerFunction(
NULL);
1413 *ppCP = connectionPoint;
1414 connectionPoint->
AddRef();
1425#define BEGIN_CONNECTION_POINT_MAP(x) \
1426 typedef x _atl_conn_classtype; \
1427 static const ATL::_ATL_CONNMAP_ENTRY *GetConnMap(int *pnEntries) { \
1428 static const ATL::_ATL_CONNMAP_ENTRY _entries[] = {
1430#define END_CONNECTION_POINT_MAP() \
1431 {(DWORD_PTR)-1} }; \
1433 *pnEntries = sizeof(_entries) / sizeof(ATL::_ATL_CONNMAP_ENTRY) - 1; \
1436#define CONNECTION_POINT_ENTRY(iid) \
1437 {offsetofclass(ATL::_ICPLocator<&iid>, _atl_conn_classtype) - \
1438 offsetofclass(ATL::IConnectionPointContainerImpl<_atl_conn_classtype>, _atl_conn_classtype)},
1467 if (wMajor == 0xffff && wMinor == 0xffff)
1468 OutputDebugStringA(
"IDispatchImpl: not fully implemented, missing functionality to load TLB from file!\r\n");
1488 if (pctinfo ==
NULL)
1499 if (ppTInfo ==
NULL)
1505 (*ppTInfo)->AddRef();
1514 hr =
m_pTypeInfo->GetIDsOfNames(rgszNames, cNames, rgDispId);
1522 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)
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