30 template <
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>) 93 template <
class ThreadModel>
97 typename ThreadModel::AutoDeleteCriticalSection
m_critsec;
112 return ThreadModel::Decrement(&
m_dwRef);
131 template <
class Base>
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();
201 template <
class Base>
231 template <
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();
315 template <
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();
400 template <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();
443 hResult = newInstance->QueryInterface(
riid,
ppv);
454 template <
class T1,
class T2>
465 return T2::CreateInstance(pv,
riid,
ppv);
469 template <
class Base>
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) \ 578 _Break}, // Break is a function that issues int 3. 580 #define COM_INTERFACE_ENTRY_NOINTERFACE(x) \ 583 _NoInterface}, // NoInterface returns E_NOINTERFACE. 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)
770 template <
class T, const CLSID *pcls
id = &CLSID_NULL>
813 static void init(CONNECTDATA *)
854 template <
class Base, const IID *pi
id,
class T,
class Copy>
900 for (sourcePtr =
begin; sourcePtr !=
end; sourcePtr++)
907 while (cleanupPtr < destPtr)
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)
957 while (rgelt < rgeltTemp)
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);
1030 template <
class Base, const IID *pi
id,
class T,
class Copy,
class ThreadModel>
1032 public CComEnumImpl<Base, piid, T, Copy>,
1033 public CComObjectRootEx<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)
1123 ATLTRY(newArray = reinterpret_cast<IUnknown **>(
malloc(newSize)));
1124 if (newArray ==
NULL)
1126 memset(newArray, 0, newSize);
1142 if (newArray ==
NULL)
1156 index = dwCookie - 1;
1182 template <const IID *pi
id>
1191 template<
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)
1358 while (entryPtr->
dwOffset != static_cast<DWORD_PTR>(-1))
1360 if (entryPtr->
dwOffset == static_cast<DWORD_PTR>(-2))
1363 handlerFunction = reinterpret_cast<handlerFunctionType>(entryPtr->
dwOffset);
1364 entryPtr = handlerFunction(
NULL);
1368 itemBuffer[destIndex++] = reinterpret_cast<IConnectionPoint *>((
char *)
this + entryPtr->
dwOffset);
1374 if (newEnumerator ==
NULL)
1376 delete [] itemBuffer;
1383 delete newEnumerator;
1399 entryPtr = T::GetConnMap(
NULL);
1400 while (entryPtr->
dwOffset != static_cast<DWORD_PTR>(-1))
1402 if (entryPtr->
dwOffset == static_cast<DWORD_PTR>(-2))
1405 handlerFunction = reinterpret_cast<handlerFunctionType>(entryPtr->
dwOffset);
1406 entryPtr = handlerFunction(
NULL);
1410 connectionPoint = reinterpret_cast<IConnectionPoint *>(reinterpret_cast<char *>(
this) + entryPtr->
dwOffset);
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);
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)
GLint GLint GLint GLint GLint x
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 &)