29 template <
class Base, const IID *pi
id,
class T,
class Copy,
class ThreadModel = CComObjectThreadModel>
32 #define DECLARE_CLASSFACTORY_EX(cf) typedef ATL::CComCreator<ATL::CComObjectCached<cf> > _ClassFactoryCreatorClass; 33 #define DECLARE_CLASSFACTORY() DECLARE_CLASSFACTORY_EX(ATL::CComClassFactory) 34 #define DECLARE_CLASSFACTORY_SINGLETON(obj) DECLARE_CLASSFACTORY_EX(ATL::CComClassFactorySingleton<obj>) 92 template <
class ThreadModel>
96 typename ThreadModel::AutoDeleteCriticalSection
m_critsec;
111 return ThreadModel::Decrement(&
m_dwRef);
130 template <
class Base>
141 this->FinalRelease();
142 _pAtlModule->Unlock();
147 return this->InternalAddRef();
154 newRefCount = this->InternalRelease();
155 if (newRefCount == 0)
162 return this->_InternalQueryInterface(iid,
ppvObject);
177 if (newInstance !=
NULL)
179 newInstance->SetVoid(
NULL);
180 newInstance->InternalFinalConstructAddRef();
181 hResult = newInstance->_AtlInitialConstruct();
183 hResult = newInstance->FinalConstruct();
185 hResult = newInstance->_AtlFinalConstruct();
186 newInstance->InternalFinalConstructRelease();
200 template <
class Base>
230 template <
class contained>
244 _pAtlModule->Unlock();
258 return this->InternalAddRef();
264 newRefCount = this->InternalRelease();
265 if (newRefCount == 0)
275 *
ppvObject = reinterpret_cast<void*>(
this);
293 if (newInstance !=
NULL)
295 newInstance->SetVoid(
NULL);
296 newInstance->InternalFinalConstructAddRef();
297 hResult = newInstance->_AtlInitialConstruct();
301 hResult = newInstance->_AtlFinalConstruct();
302 newInstance->InternalFinalConstructRelease();
314 template <
class contained>
329 _pAtlModule->Unlock();
343 return this->InternalAddRef();
349 newRefCount = this->InternalRelease();
350 if (newRefCount == 0)
360 *
ppvObject = reinterpret_cast<void*>(
this);
378 if (newInstance !=
NULL)
380 newInstance->SetVoid(
NULL);
381 newInstance->InternalFinalConstructAddRef();
382 hResult = newInstance->_AtlInitialConstruct();
386 hResult = newInstance->_AtlFinalConstruct();
387 newInstance->InternalFinalConstructRelease();
399 template <HRESULT hResult>
431 if (newInstance !=
NULL)
433 newInstance->SetVoid(
pv);
434 newInstance->InternalFinalConstructAddRef();
435 hResult = newInstance->_AtlInitialConstruct();
437 hResult = newInstance->FinalConstruct();
439 hResult = newInstance->_AtlFinalConstruct();
440 newInstance->InternalFinalConstructRelease();
442 hResult = newInstance->QueryInterface(
riid,
ppv);
453 template <
class T1,
class T2>
464 return T2::CreateInstance(
pv,
riid,
ppv);
468 template <
class Base>
478 this->FinalRelease();
485 newRefCount = this->InternalAddRef();
486 if (newRefCount == 2)
495 newRefCount = this->InternalRelease();
496 if (newRefCount == 0)
498 else if (newRefCount == 1)
499 _pAtlModule->Unlock();
505 return this->_InternalQueryInterface(iid,
ppvObject);
520 if (newInstance !=
NULL)
522 newInstance->SetVoid(
NULL);
523 newInstance->InternalFinalConstructAddRef();
524 hResult = newInstance->_AtlInitialConstruct();
526 hResult = newInstance->FinalConstruct();
528 hResult = newInstance->_AtlFinalConstruct();
529 newInstance->InternalFinalConstructRelease();
541 #define BEGIN_COM_MAP(x) \ 543 typedef x _ComMapClass; \ 544 HRESULT _InternalQueryInterface(REFIID iid, void **ppvObject) \ 546 return this->InternalQueryInterface(this, _GetEntries(), iid, ppvObject); \ 548 const static ATL::_ATL_INTMAP_ENTRY *WINAPI _GetEntries() \ 550 static const ATL::_ATL_INTMAP_ENTRY _entries[] = { 552 #define END_COM_MAP() \ 557 virtual ULONG STDMETHODCALLTYPE AddRef() = 0; \ 558 virtual ULONG STDMETHODCALLTYPE Release() = 0; \ 559 STDMETHOD(QueryInterface)(REFIID, void **) = 0; 561 #define COM_INTERFACE_ENTRY_IID(iid, x) \ 562 {&iid, offsetofclass(x, _ComMapClass), _ATL_SIMPLEMAPENTRY}, 564 #define COM_INTERFACE_ENTRY(x) \ 566 offsetofclass(x, _ComMapClass), \ 567 _ATL_SIMPLEMAPENTRY}, 569 #define COM_INTERFACE_ENTRY2_IID(iid, x, x2) \ 571 reinterpret_cast<DWORD_PTR>(static_cast<x *>(static_cast<x2 *>(reinterpret_cast<_ComMapClass *>(_ATL_PACKING)))) - _ATL_PACKING, \ 572 _ATL_SIMPLEMAPENTRY}, 574 #define COM_INTERFACE_ENTRY_BREAK(x) \ 577 _Break}, // Break is a function that issues int 3. 579 #define COM_INTERFACE_ENTRY_NOINTERFACE(x) \ 582 _NoInterface}, // NoInterface returns E_NOINTERFACE. 584 #define COM_INTERFACE_ENTRY_FUNC(iid, dw, func) \ 589 #define COM_INTERFACE_ENTRY_FUNC_BLIND(dw, func) \ 594 #define COM_INTERFACE_ENTRY_CHAIN(classname) \ 596 reinterpret_cast<DWORD>(&_CComChainData<classname, _ComMapClass>::data), \ 599 #define DECLARE_NO_REGISTRY()\ 600 static HRESULT WINAPI UpdateRegistry(BOOL ) \ 605 #define DECLARE_REGISTRY_RESOURCEID(x) \ 606 static HRESULT WINAPI UpdateRegistry(BOOL bRegister) \ 608 return ATL::_pAtlModule->UpdateRegistryFromResource(x, bRegister); \ 611 #define DECLARE_NOT_AGGREGATABLE(x) \ 613 typedef ATL::CComCreator2<ATL::CComCreator<ATL::CComObject<x> >, ATL::CComFailCreator<CLASS_E_NOAGGREGATION> > _CreatorClass; 615 #define DECLARE_AGGREGATABLE(x) \ 617 typedef ATL::CComCreator2<ATL::CComCreator<ATL::CComObject<x> >, ATL::CComCreator<ATL::CComAggObject<x> > > _CreatorClass; 619 #define DECLARE_ONLY_AGGREGATABLE(x) \ 621 typedef ATL::CComCreator2<ATL::CComFailCreator<E_FAIL>, ATL::CComCreator<ATL::CComAggObject<x> > > _CreatorClass; 623 #define DECLARE_POLY_AGGREGATABLE(x) \ 625 typedef ATL::CComCreator<ATL::CComPolyObject<x> > _CreatorClass; 627 #define COM_INTERFACE_ENTRY_AGGREGATE(iid, punk) \ 629 (DWORD_PTR)offsetof(_ComMapClass, punk), \ 632 #define DECLARE_GET_CONTROLLING_UNKNOWN() \ 634 virtual IUnknown *GetControllingUnknown() \ 636 return GetUnknown(); \ 639 #define DECLARE_PROTECT_FINAL_CONSTRUCT() \ 640 void InternalFinalConstructAddRef() \ 644 void InternalFinalConstructRelease() \ 649 #define BEGIN_OBJECT_MAP(x) static ATL::_ATL_OBJMAP_ENTRY x[] = { 651 #define END_OBJECT_MAP() {NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL, NULL}}; 653 #define OBJECT_ENTRY(clsid, class) \ 656 class::UpdateRegistry, \ 657 class::_ClassFactoryCreatorClass::CreateInstance, \ 658 class::_CreatorClass::CreateInstance, \ 661 class::GetObjectDescription, \ 662 class::GetCategoryMap, \ 699 _pAtlModule->Unlock();
736 if (pUnkOuter !=
NULL)
769 template <
class T, const CLSID *pcls
id = &CLSID_NULL>
812 static void init(CONNECTDATA *)
853 template <
class Base, const IID *pi
id,
class T,
class Copy>
899 for (sourcePtr =
begin; sourcePtr !=
end; sourcePtr++)
906 while (cleanupPtr < destPtr)
934 if (pceltFetched !=
NULL)
938 if (rgelt ==
NULL || (celt != 1 && pceltFetched ==
NULL))
944 if (celt < numAvailable)
947 numToFetch = numAvailable;
948 if (pceltFetched !=
NULL)
949 *pceltFetched = numToFetch;
951 while (numToFetch != 0)
956 while (rgelt < rgeltTemp)
958 if (pceltFetched !=
NULL)
966 if (numAvailable < celt)
980 if (celt < numAvailable)
983 numToSkip = numAvailable;
985 if (numAvailable < celt)
1011 newInstance->m_iter =
m_iter;
1012 hResult = newInstance->_InternalQueryInterface(*piid, (
void **)ppEnum);
1029 template <
class Base, const IID *pi
id,
class T,
class Copy,
class ThreadModel>
1031 public CComEnumImpl<Base, piid, T, Copy>,
1032 public CComObjectRootEx<ThreadModel>
1043 #ifndef _DEFAULT_VECTORLENGTH 1044 #define _DEFAULT_VECTORLENGTH 4 1086 if (dwCookie != 0 && dwCookie <= static_cast<DWORD>(
m_nSize))
1087 return GetAt(dwCookie - 1);
1098 if (ppFind !=
NULL && *ppFind !=
NULL)
1122 ATLTRY(newArray = reinterpret_cast<IUnknown **>(
malloc(newSize)));
1123 if (newArray ==
NULL)
1125 memset(newArray, 0, newSize);
1141 if (newArray ==
NULL)
1155 index = dwCookie - 1;
1181 template <const IID *pi
id>
1190 template<
class T, const IID *pi
id,
class CDV = CComDynamicUnkArray>
1241 pThis = static_cast<T *>(
this);
1251 if (pdwCookie !=
NULL)
1253 if (pUnkSink ==
NULL || pdwCookie ==
NULL)
1256 hResult = pUnkSink->
QueryInterface(interfaceID, reinterpret_cast<void **>(&adviseTarget));
1259 *pdwCookie =
m_vec.Add(adviseTarget);
1260 if (*pdwCookie != 0)
1278 adviseTarget =
m_vec.GetUnknown(dwCookie);
1279 if (
m_vec.Remove(dwCookie))
1281 if (adviseTarget !=
NULL)
1293 CONNECTDATA *itemBuffer;
1294 CONNECTDATA *itemBufferEnd;
1304 if (itemBuffer ==
NULL)
1306 itemBufferEnd = itemBuffer;
1312 itemBufferEnd->pUnk = *
x;
1313 itemBufferEnd->dwCookie =
m_vec.GetCookie(
x);
1318 if (newEnumerator ==
NULL)
1323 delete newEnumerator;
1339 int connectionPointCount;
1351 entryPtr = T::GetConnMap(&connectionPointCount);
1353 if (itemBuffer ==
NULL)
1357 while (entryPtr->
dwOffset != static_cast<DWORD_PTR>(-1))
1359 if (entryPtr->
dwOffset == static_cast<DWORD_PTR>(-2))
1362 handlerFunction = reinterpret_cast<handlerFunctionType>(entryPtr->
dwOffset);
1363 entryPtr = handlerFunction(
NULL);
1367 itemBuffer[destIndex++] = reinterpret_cast<IConnectionPoint *>((
char *)
this + entryPtr->
dwOffset);
1373 if (newEnumerator ==
NULL)
1375 delete [] itemBuffer;
1382 delete newEnumerator;
1398 entryPtr = T::GetConnMap(
NULL);
1399 while (entryPtr->
dwOffset != static_cast<DWORD_PTR>(-1))
1401 if (entryPtr->
dwOffset == static_cast<DWORD_PTR>(-2))
1404 handlerFunction = reinterpret_cast<handlerFunctionType>(entryPtr->
dwOffset);
1405 entryPtr = handlerFunction(
NULL);
1409 connectionPoint = reinterpret_cast<IConnectionPoint *>(reinterpret_cast<char *>(
this) + entryPtr->
dwOffset);
1412 *ppCP = connectionPoint;
1413 connectionPoint->
AddRef();
1424 #define BEGIN_CONNECTION_POINT_MAP(x) \ 1425 typedef x _atl_conn_classtype; \ 1426 static const ATL::_ATL_CONNMAP_ENTRY *GetConnMap(int *pnEntries) { \ 1427 static const ATL::_ATL_CONNMAP_ENTRY _entries[] = { 1429 #define END_CONNECTION_POINT_MAP() \ 1430 {(DWORD_PTR)-1} }; \ 1432 *pnEntries = sizeof(_entries) / sizeof(ATL::_ATL_CONNMAP_ENTRY) - 1; \ 1435 #define CONNECTION_POINT_ENTRY(iid) \ 1436 {offsetofclass(ATL::_ICPLocator<&iid>, _atl_conn_classtype) - \ 1437 offsetofclass(ATL::IConnectionPointContainerImpl<_atl_conn_classtype>, _atl_conn_classtype)}, 1466 if (wMajor == 0xffff && wMinor == 0xffff)
1467 OutputDebugStringA(
"IDispatchImpl: not fully implemented, missing functionality to load TLB from file!\r\n");
1487 if (pctinfo ==
NULL)
1498 if (ppTInfo ==
NULL)
1504 (*ppTInfo)->AddRef();
1513 hr =
m_pTypeInfo->GetIDsOfNames(rgszNames, cNames, rgDispId);
1521 hr =
m_pTypeInfo->Invoke(
this, dispIdMember,
wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
virtual ~CComObjectCached()
STDMETHOD() GetConnectionInterface(IID *piid2)
STDMETHOD() Advise(IUnknown *pUnkSink, DWORD *pdwCookie)
STDMETHOD_(ULONG, AddRef)()
static HRESULT WINAPI CreateInstance(void *pv, REFIID riid, LPVOID *ppv)
#define CONNECT_E_ADVISELIMIT
STDMETHOD_(ULONG, AddRef)()
static HRESULT WINAPI CreateInstance(CComObjectCached< Base > **pp)
#define CONNECT_E_CANNOTCONNECT
HRESULT GetConnectionInterface([out] IID *pIID)
STDMETHOD() CreateInstance(LPUNKNOWN pUnkOuter, REFIID riid, void **ppvObj)
#define CONNECT_E_NOCONNECTION
CComContainedObject< contained > m_contained
const GUID IID_IConnectionPointContainer
static HRESULT copy(T **pTo, T **pFrom)
STDMETHOD() EnsureTILoaded(LCID lcid)
BOOL Remove(DWORD dwCookie)
const GUID IID_IEnumConnections
HRESULT WINAPI AtlInternalQueryInterface(void *pThis, const _ATL_INTMAP_ENTRY *pEntries, REFIID iid, void **ppvObject)
CComEnum< IEnumConnectionPoints, &IID_IEnumConnectionPoints, IConnectionPoint *, _CopyInterface< IConnectionPoint > > CComEnumConnectionPoints
static HRESULT copy(T *pTo, const T *pFrom)
STDMETHOD_(ULONG, AddRef)()
const _ATL_CONNMAP_ENTRY *(* handlerFunctionType)(int *)
STDMETHOD() QueryInterface(REFIID iid, void **ppvObject)
void InternalFinalConstructAddRef()
HRESULT _AtlFinalConstruct()
DWORD Add(IUnknown *pUnk)
static HRESULT WINAPI InternalQueryInterface(void *pThis, const _ATL_INTMAP_ENTRY *pEntries, REFIID iid, void **ppvObject)
STDMETHOD() GetTypeInfoCount(UINT *pctinfo)
static HRESULT WINAPI CreateInstance(void *, REFIID, LPVOID *ppv)
CComAggObject(void *pv=NULL)
static const struct _ATL_CATMAP_ENTRY * GetCategoryMap()
HRESULT _AtlInitialConstruct()
STDMETHOD() GetTypeInfo(UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
virtual ~CComClassFactory()
#define _DEFAULT_VECTORLENGTH
static LPCTSTR WINAPI GetObjectDescription()
CComPtr< ITypeInfo > m_pTypeInfo
static void destroy(CONNECTDATA *p)
static void init(CONNECTDATA *)
CComContainedObject(void *pv=NULL)
CComObjectCached(void *=NULL)
STDMETHOD_(ULONG, Release)()
IUnknown * GetControllingUnknown()
IUnknown * GetAt(int nIndex)
STDMETHOD() QueryInterface(REFIID iid, void **ppvObject)
ThreadModel::AutoDeleteCriticalSection m_critsec
#define STDMETHODCALLTYPE
STDMETHOD() CreateInstance(LPUNKNOWN pUnkOuter, REFIID riid, void **ppvObj)
CComDynamicUnkArray(const CComDynamicUnkArray &)
BOOL WINAPI InlineIsEqualUnknown(REFGUID rguid1)
void InternalFinalConstructRelease()
const GUID IID_IEnumConnectionPoints
static void destroy(T **p)
_ATL_CREATORFUNC * m_pfnCreateInstance
static HRESULT copy(CONNECTDATA *pTo, const CONNECTDATA *pFrom)
virtual ULONG STDMETHODCALLTYPE AddRef()=0
STDMETHOD_(ULONG, Release)()
void destroy(_Tp *__pointer)
STDMETHOD_(ULONG, Release)()
STDMETHOD_(ULONG, Release)()
DWORD WINAPI GetCookie(IUnknown **ppFind)
STDMETHOD() GetIDsOfNames(REFIID, LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
#define memcpy(s1, s2, n)
STDMETHOD() EnumConnectionPoints(IEnumConnectionPoints **ppEnum)
REFIID LPVOID * ppvObject
STDMETHOD() FindConnectionPoint(REFIID riid, IConnectionPoint **ppCP)
#define CLASS_E_NOAGGREGATION
STDMETHOD() _LocCPQueryInterface(REFIID riid, void **ppvObject)=0
STDMETHOD() QueryInterface(REFIID iid, void **ppvObject)
IUnknown *WINAPI GetUnknown(DWORD dwCookie)
static void WINAPI ObjectMain(bool)
_In_ DWORD _Out_ _In_ WORD wFlags
STDMETHOD() Invoke(DISPID dispIdMember, REFIID, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
const GUID IID_IConnectionPoint
struct stdole::EXCEPINFO EXCEPINFO
static VARIANTARG static DISPID
STDMETHOD() Unadvise(DWORD dwCookie)
HRESULT WINAPI LoadRegTypeLib(REFGUID rguid, WORD wVerMajor, WORD wVerMinor, LCID lcid, ITypeLib **ppTLib)
static HRESULT WINAPI CreateInstance(IUnknown *punkOuter, CComAggObject< contained > **pp)
CComClassFactorySingleton()
STDMETHOD() LockServer(BOOL fLock)
#define COM_INTERFACE_ENTRY_IID(iid, x)
CComEnum< IEnumConnections, &IID_IEnumConnections, CONNECTDATA, _Copy< CONNECTDATA > > CComEnumConnections
INT copy(TCHAR source[MAX_PATH], TCHAR dest[MAX_PATH], INT append, DWORD lpdwFlags, BOOL bTouch)
CComPolyObject(void *pv=NULL)
static HRESULT WINAPI CreateInstance(void *pv, REFIID riid, LPVOID *ppv)
STDMETHOD_(ULONG, Release)()
static ULONG WINAPI AddRef(IStream *iface)
STDMETHOD() QueryInterface(REFIID iid, void **ppvObject)
#define DECLARE_CLASSFACTORY()
HRESULT QueryInterface([in] REFIID riid, [out, iid_is(riid)] void **ppvObject)
STDMETHOD_(ULONG, AddRef)()
struct stdole::DISPPARAMS DISPPARAMS
virtual ULONG STDMETHODCALLTYPE Release()=0
STDMETHOD_(ULONG, AddRef)()
STDMETHOD() GetConnectionPointContainer(IConnectionPointContainer **ppCPC)
STDMETHOD() _LocCPQueryInterface(REFIID riid, void **ppvObject)
STDMETHOD() QueryInterface(REFIID iid, void **ppvObject)
virtual ~CComPolyObject()
static HRESULT WINAPI CreateInstance(IUnknown *punkOuter, CComPolyObject< contained > **pp)
IN OUT PLONG IN OUT PLONG Addend IN OUT PLONG IN LONG Increment
const GUID IID_IClassFactory
#define IsEqualCLSID(rclsid1, rclsid2)
static HRESULT WINAPI CreateInstance(CComObject< Base > **pp)
static void *static void *static LPDIRECTPLAY IUnknown * pUnk
void WINAPI SHIM_OBJ_NAME() OutputDebugStringA(LPCSTR lpOutputString)
#define InlineIsEqualGUID(rguid1, rguid2)
CComContainedObject< contained > m_contained
CComDynamicUnkArray & operator=(const CComDynamicUnkArray &)