Re: Interface implementation
Sorry Victor, but about what FAQ you talking? Where can I find it?
Wow, I understand :) sorry.
This is my code. Task is next: I want write template class, CUnknown,
with implemented nessesary methods (Queryinterface, Release ...), to
use it for other classes.
CUnknown:
template < class ClassType, REFIID ObjectIID >
class CUnknown : public IUnknown
{
protected:
// IUnknown methods.
virtual STDMETHODIMP QueryInterface( REFIID riid, void** ppv )
{
if ( ppv == NULL )
{
return E_POINTER;
}
if ( riid == *ObjectIID || riid == IID_IUnknown )
{
*ppv = static_cast< ClassType* >( this );
AddRef();
return S_OK;
}
*ppv = NULL;
return E_NOINTERFACE;
}
virtual STDMETHODIMP_( ULONG ) AddRef()
{
return InterlockedIncrement( &m_cRef );
}
virtual STDMETHODIMP_( ULONG ) Release()
{
LSCOPE( "CMediaBuffer::Release" );
LONG lRef = InterlockedDecrement( &m_cRef );
if ( lRef == 0 )
{
delete this;
// m_cRef is no longer valid! Return lRef.
}
return lRef;
}
LONG m_cRef;
};
#include "Unknown.h"
class ISMSNotificationHandler
{
public:
virtual void HandleSMSMessageReceived( const CEOID messageID ) = 0;
};
// IMAPIAdviseSink also derived from IUnknown
class CAdviseSinc
// This is my CUnknown,but anyway "Cannot instantiate abstract
class" error
: public virtual CUnknown< CAdviseSinc, IID_IMAPIAdviseSink >
, public virtual IMAPIAdviseSink
{
public:
CAdviseSinc();
~CAdviseSinc();
private:
ULONG OnNotify( ULONG cNotif, LPNOTIFICATION lpNotifications );
};
Is that your first day here?
Actually in this group yes, but not in other, I am sorry.