Introduction
p6loader, which is used to load all P6R component libraries, uses an p6IDataStream interface to write out all it's error and debug information. CConsoleStream is just a sample of an p6IDataStream implementation which writes this information to the console (via prinf()).
It's important to note that its methods can be called before p6Loader is initialized, and therefore, the implementation can not call any p6loader APIs
#ifndef CCONSOLESTREAM_H_
#define CCONSOLESTREAM_H_ 1
namespace {
{
public:
{
if (!ppIface) return P6R::eAccessFault;
*ppIface = NULL;
if(iid == IID_p6ICom) *ppIface = static_cast<p6IDataStream*>(this);
else if(iid == IID_p6IDataStream) *ppIface = static_cast<p6IDataStream*>(this);
else return P6R::eNoInterface;
reinterpret_cast<p6ICom*>(*ppIface)->addref();
return P6R::eOk;
}
{
return m_cRef++;
}
{
if(0 == (tmp = (--m_cRef))) { delete this; }
return tmp;
}
{
return P6R::eOk;
}
{
if (m_cBuffer && cData+1 > m_cBuffer)
{
free( m_pBuffer );
m_pBuffer = NULL;
m_cBuffer = 0;
}
if (!m_pBuffer)
{
m_cBuffer = cData;
}
if (m_pBuffer)
{
memcpy( m_pBuffer, pData, cData );
m_pBuffer[cData] = '\0';
printf( m_pBuffer );
}
return P6R::eOk;
}
{
CConsoleStream *pObj = NULL;
if(NULL != pOuter) return P6R::eNoAgregation;
if(NULL == ppIface) return P6R::eAccessFault;
*ppIface = NULL;
if (NULL != (pObj = new (std::nothrow) CConsoleStream() ))
{
pObj->addref();
err = pObj->queryInterface( iid, ppIface );
pObj->release();
}
return err;
}
CConsoleStream() : m_cRef(0), m_pBuffer(NULL), m_cBuffer(0) {;}
virtual ~CConsoleStream() { if (m_pBuffer) free(m_pBuffer); }
protected:
};
}
#endif