refeactor all IUnknown implementations using IComSrvBase

svn path=/trunk/; revision=18063
This commit is contained in:
Martin Fuchs 2005-09-25 17:59:20 +00:00
parent 029ccdccaa
commit 8b950fec34
4 changed files with 121 additions and 216 deletions

View file

@ -58,8 +58,7 @@ struct BrowserCallback
/// Implementation of IShellBrowserImpl interface in explorer child windows /// Implementation of IShellBrowserImpl interface in explorer child windows
struct ShellBrowser : public IShellBrowserImpl struct ShellBrowser : public IShellBrowserImpl
#ifndef __MINGW32__ // IShellFolderViewCB missing in MinGW (as of 25.09.2005) #ifndef __MINGW32__ // IShellFolderViewCB missing in MinGW (as of 25.09.2005)
, public IComSrvBase<IShellFolderViewCB, ShellBrowser>, , public IComSrvBase<IShellFolderViewCB, ShellBrowser>, public SimpleComObject
public SimpleComObject
#endif #endif
{ {
ShellBrowser(HWND hwnd, HWND left_hwnd, WindowHandle& right_hwnd, ShellPathInfo& create_info, ShellBrowser(HWND hwnd, HWND left_hwnd, WindowHandle& right_hwnd, ShellPathInfo& create_info,

View file

@ -530,8 +530,8 @@ interface FixedDWebBrowserEvents2 : public IDispatch
#endif #endif
}; };
struct ANSUNC DWebBrowserEvents2Impl : public SimpleComObject, struct ANSUNC DWebBrowserEvents2Impl
public IComSrvBase<FixedDWebBrowserEvents2, DWebBrowserEvents2Impl>, : public IComSrvBase<FixedDWebBrowserEvents2, DWebBrowserEvents2Impl>, public SimpleComObject,
public DWebBrowserEvents2IF public DWebBrowserEvents2IF
{ {
typedef IComSrvBase<FixedDWebBrowserEvents2, DWebBrowserEvents2Impl> super; typedef IComSrvBase<FixedDWebBrowserEvents2, DWebBrowserEvents2Impl> super;

View file

@ -22,7 +22,8 @@
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
IDataObjectImpl::IDataObjectImpl(IDropSourceImpl* pDropSource) IDataObjectImpl::IDataObjectImpl(IDropSourceImpl* pDropSource)
: m_pDropSource(pDropSource), : super(IID_IDataObject),
m_pDropSource(pDropSource),
m_cRefCount(0) m_cRefCount(0)
{ {
} }
@ -33,37 +34,6 @@ IDataObjectImpl::~IDataObjectImpl()
ReleaseStgMedium(it->_medium); ReleaseStgMedium(it->_medium);
} }
STDMETHODIMP IDataObjectImpl::QueryInterface(/* [in] */ REFIID riid,
/* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject)
{
*ppvObject = NULL;
if (IID_IUnknown==riid || IID_IDataObject==riid)
*ppvObject=this;
/*if (riid == IID_IAsyncOperation)
*ppvObject=(IAsyncOperation*)this;*/
if (NULL!=*ppvObject)
{
((LPUNKNOWN)*ppvObject)->AddRef();
return S_OK;
}
return E_NOINTERFACE;
}
STDMETHODIMP_(ULONG) IDataObjectImpl::AddRef()
{
return ++m_cRefCount;
}
STDMETHODIMP_(ULONG) IDataObjectImpl::Release()
{
long nTemp = --m_cRefCount;
if (nTemp == 0)
delete this;
return nTemp;
}
STDMETHODIMP IDataObjectImpl::GetData( STDMETHODIMP IDataObjectImpl::GetData(
/* [unique][in] */ FORMATETC __RPC_FAR *pformatetcIn, /* [unique][in] */ FORMATETC __RPC_FAR *pformatetcIn,
/* [out] */ STGMEDIUM __RPC_FAR *pmedium) /* [out] */ STGMEDIUM __RPC_FAR *pmedium)
@ -255,38 +225,6 @@ HRESULT STDMETHODCALLTYPE IDataObjectImpl::EnumDAdvise(
// IDropSourceImpl Class // IDropSourceImpl Class
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
STDMETHODIMP IDropSourceImpl::QueryInterface(/* [in] */ REFIID riid,
/* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject)
{
*ppvObject = NULL;
if (IID_IUnknown==riid || IID_IDropSource==riid)
*ppvObject=this;
if (*ppvObject != NULL)
{
((LPUNKNOWN)*ppvObject)->AddRef();
return S_OK;
}
return E_NOINTERFACE;
}
STDMETHODIMP_(ULONG) IDropSourceImpl::AddRef()
{
return ++m_cRefCount;
}
STDMETHODIMP_(ULONG) IDropSourceImpl::Release()
{
long nTemp = --m_cRefCount;
assert(nTemp >= 0);
if (nTemp == 0)
delete this;
return nTemp;
}
STDMETHODIMP IDropSourceImpl::QueryContinueDrag( STDMETHODIMP IDropSourceImpl::QueryContinueDrag(
/* [in] */ BOOL fEscapePressed, /* [in] */ BOOL fEscapePressed,
/* [in] */ DWORD grfKeyState) /* [in] */ DWORD grfKeyState)
@ -314,7 +252,8 @@ STDMETHODIMP IDropSourceImpl::GiveFeedback(
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
EnumFormatEtcImpl::EnumFormatEtcImpl(const FormatArray& ArrFE) EnumFormatEtcImpl::EnumFormatEtcImpl(const FormatArray& ArrFE)
: m_cRefCount(0), : super(IID_IEnumFORMATETC),
m_cRefCount(0),
m_iCur(0) m_iCur(0)
{ {
for(FormatArray::const_iterator it=ArrFE.begin(); it!=ArrFE.end(); ++it) for(FormatArray::const_iterator it=ArrFE.begin(); it!=ArrFE.end(); ++it)
@ -322,44 +261,14 @@ EnumFormatEtcImpl::EnumFormatEtcImpl(const FormatArray& ArrFE)
} }
EnumFormatEtcImpl::EnumFormatEtcImpl(const StorageArray& ArrFE) EnumFormatEtcImpl::EnumFormatEtcImpl(const StorageArray& ArrFE)
: m_cRefCount(0), : super(IID_IEnumFORMATETC),
m_cRefCount(0),
m_iCur(0) m_iCur(0)
{ {
for(StorageArray::const_iterator it=ArrFE.begin(); it!=ArrFE.end(); ++it) for(StorageArray::const_iterator it=ArrFE.begin(); it!=ArrFE.end(); ++it)
m_pFmtEtc.push_back(*it->_format); m_pFmtEtc.push_back(*it->_format);
} }
STDMETHODIMP EnumFormatEtcImpl::QueryInterface(REFIID refiid, void** ppv)
{
*ppv = NULL;
if (IID_IUnknown==refiid || IID_IEnumFORMATETC==refiid)
*ppv=this;
if (*ppv != NULL)
{
((LPUNKNOWN)*ppv)->AddRef();
return S_OK;
}
return E_NOINTERFACE;
}
STDMETHODIMP_(ULONG) EnumFormatEtcImpl::AddRef(void)
{
return ++m_cRefCount;
}
STDMETHODIMP_(ULONG) EnumFormatEtcImpl::Release(void)
{
long nTemp = --m_cRefCount;
assert(nTemp >= 0);
if (nTemp == 0)
delete this;
return nTemp;
}
STDMETHODIMP EnumFormatEtcImpl::Next(ULONG celt,LPFORMATETC lpFormatEtc, ULONG* pceltFetched) STDMETHODIMP EnumFormatEtcImpl::Next(ULONG celt,LPFORMATETC lpFormatEtc, ULONG* pceltFetched)
{ {
if (pceltFetched != NULL) if (pceltFetched != NULL)

View file

@ -24,8 +24,11 @@ typedef vector<DataStorage> StorageArray;
/// implementation of IEnumFORMATETC interface /// implementation of IEnumFORMATETC interface
class EnumFormatEtcImpl : public IEnumFORMATETC class EnumFormatEtcImpl
: public IComSrvBase<IEnumFORMATETC, EnumFormatEtcImpl>, public SimpleComObject
{ {
typedef IComSrvBase<IEnumFORMATETC, EnumFormatEtcImpl> super;
private: private:
ULONG m_cRefCount; ULONG m_cRefCount;
FormatArray m_pFmtEtc; FormatArray m_pFmtEtc;
@ -36,11 +39,6 @@ class EnumFormatEtcImpl : public IEnumFORMATETC
EnumFormatEtcImpl(const StorageArray& ArrFE); EnumFormatEtcImpl(const StorageArray& ArrFE);
virtual ~EnumFormatEtcImpl() {} virtual ~EnumFormatEtcImpl() {}
//IUnknown members
virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID, void**);
virtual ULONG STDMETHODCALLTYPE AddRef(void);
virtual ULONG STDMETHODCALLTYPE Release(void);
//IEnumFORMATETC members //IEnumFORMATETC members
virtual HRESULT STDMETHODCALLTYPE Next(ULONG, LPFORMATETC, ULONG*); virtual HRESULT STDMETHODCALLTYPE Next(ULONG, LPFORMATETC, ULONG*);
virtual HRESULT STDMETHODCALLTYPE Skip(ULONG); virtual HRESULT STDMETHODCALLTYPE Skip(ULONG);
@ -49,22 +47,24 @@ class EnumFormatEtcImpl : public IEnumFORMATETC
}; };
/// implementation of IDropSource interface /// implementation of IDropSource interface
class IDropSourceImpl : public IDropSource class IDropSourceImpl
: public IComSrvBase<IDropSource, IDropSourceImpl>, public SimpleComObject
{ {
typedef IComSrvBase<IDropSource, IDropSourceImpl> super;
long m_cRefCount; long m_cRefCount;
public: public:
bool m_bDropped; bool m_bDropped;
IDropSourceImpl::IDropSourceImpl() : m_cRefCount(0), m_bDropped(false) {} IDropSourceImpl()
virtual ~IDropSourceImpl() {} : super(IID_IDropSource),
m_cRefCount(0),
m_bDropped(false)
{
}
//IUnknown virtual ~IDropSourceImpl() {}
virtual HRESULT STDMETHODCALLTYPE QueryInterface(
/* [in] */ REFIID riid,
/* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject);
virtual ULONG STDMETHODCALLTYPE AddRef();
virtual ULONG STDMETHODCALLTYPE Release();
//IDropSource //IDropSource
virtual HRESULT STDMETHODCALLTYPE QueryContinueDrag( virtual HRESULT STDMETHODCALLTYPE QueryContinueDrag(
@ -76,8 +76,12 @@ public:
}; };
/// implementation of IDataObject interface /// implementation of IDataObject interface
class IDataObjectImpl : public IDataObject//,public IAsyncOperation class IDataObjectImpl
: public IComSrvBase<IDataObject, IDataObjectImpl>, public SimpleComObject
//public IAsyncOperation
{ {
typedef IComSrvBase<IDataObject, IDataObjectImpl> super;
IDropSourceImpl* m_pDropSource; IDropSourceImpl* m_pDropSource;
long m_cRefCount; long m_cRefCount;
@ -89,13 +93,6 @@ public:
void CopyMedium(STGMEDIUM* pMedDest, STGMEDIUM* pMedSrc, FORMATETC* pFmtSrc); void CopyMedium(STGMEDIUM* pMedDest, STGMEDIUM* pMedSrc, FORMATETC* pFmtSrc);
//IUnknown
virtual HRESULT STDMETHODCALLTYPE QueryInterface(
/* [in] */ REFIID riid,
/* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject);
virtual ULONG STDMETHODCALLTYPE AddRef();
virtual ULONG STDMETHODCALLTYPE Release();
//IDataObject //IDataObject
virtual /* [local] */ HRESULT STDMETHODCALLTYPE GetData( virtual /* [local] */ HRESULT STDMETHODCALLTYPE GetData(
/* [unique][in] */ FORMATETC __RPC_FAR *pformatetcIn, /* [unique][in] */ FORMATETC __RPC_FAR *pformatetcIn,