Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
cconsolestream.h
#ifndef CCONSOLESTREAM_H_
#define CCONSOLESTREAM_H_ 1
#ifdef __cplusplus
#include <stdio.h> // printf
#include <stdlib.h>
#include <string.h> // memcpy()
#include "p6loader.h" // p6loader/platform API, type and interface defeinitions
#include <memory> // nothrow
namespace P6EXAMPLES {
//
// Simple p6IDataStream implementation which outputs data to stdout.
// This implementation is meant to be passes into p6Loader's
// p6InitializeLoader() function.
//
// - p6Loader will ensure that access to the p6IDataStream methods are serialized,
// so this implementation does not need to be thread-safe.
// - This impementation is used to log error/debug information during p6Loader's
// initialization process. As a result, this impementation can not make
// use of any p6Loader APIs or interfaces.
//
class CConsoleStream : public P6R::p6IDataStream
{
public:
//
// Standard p6COM queryInterface() method.
//
P6COMMETHOD queryInterface(const P6REFIID iid,P6R::P6VOID **ppIface);
//
// Standard p6COM addref() method.
//
//
// Standard p6COM release() method.
//
P6COMMETHOD_(P6R::P6INT32) release();
//
// beginStream() method prepares the stream for use.
// For this simple case there is nothing to do here.
//
P6COMMETHOD beginStream();
//
// processStream() is call to pass data to the data stream.
// This method then performs it's stream specific
// operations on the data (in this case, writing it out
// to stdout).
//
// Since printf() requires an ASCIIZ string (NULL terminated string),
// this method first copies the data into a buffer and NULL
// terminates, then passes that to printf().
//
P6COMMETHOD processStream(const P6R::P6VOID* pData,P6R::P6UINT32 cData);
//
// endStream() is called to notify the stream that there is
// no more data to be processed. In this simple case there is
// nothing to do.
//
P6COMMETHOD endStream();
//
// This method creates a new uninitialized instance
// of our component and returns a pointer to the
// requested interface.
//
static P6R::P6ERR createInstance(P6R::p6ICom *pOuter,const P6REFIID iid,P6R::P6VOID **ppIface);
CConsoleStream();
virtual ~CConsoleStream();
protected:
P6R::P6INT32 m_cRef; // Holds the components reference count
P6R::P6CHAR *m_pBuffer; // A pointer to our output buffer.
P6R::P6UINT32 m_cBuffer; // The current size in characters of our output buffer
};
} // namespace
#else
#include "p6err.h"
#include "p6datastream.h"
P6ERR createStream(p6IDataStream **ppStream);
#endif
#endif