/** \file
 *
 *  Contains the IOStream and NullIOStream class declarations.
 *
 *  Copyright (c) 2009 MBARI
 *  MBARI Proprietary Information.  All Rights Reserved
 *
 */

#ifndef IOSTREAM_H_
#define IOSTREAM_H_

#include "InStream.h"
#include "OutStream.h"

class NullIOStream;

/**
 *  This is a rather abstract class that
 *  can be implemented by classes that
 *  want to send and receive stream input.
 *
 *  Inherits directly from InStream and OutStream
 *
 *  Part of an attempt to avoid the
 *  standard template library
 *
 *  \ingroup io
 */
class IOStream: public InStream, public OutStream
{
};

/**
 *  This is an implementation of IOStream that does nothing.  Useful as as
 *  "invalid" iostream.
 *
 *  Does not inherit from NullInStream and NullOutStream, because it
 *  needs to inherit from IOStream, which inherits from NullInStream and
 *  NullOutStream parent classes.
 *
 *  Part of an attempt to avoid the
 *  standard template library
 *
 *  \ingroup io
 */
class NullIOStream: public IOStream
{
    /// doesn't really read num bytes from stream to the buffer
    virtual InStream& read( char* buffer, unsigned int num )
    {
        return *this;
    }

    /// indicates that the stream can't actually be read from.
    virtual bool isReadable()
    {
        return false;
    }

    /// Indicates that the end of file has been reached
    virtual bool eof()
    {
        return true;
    }

    /// doesn't write num bytes from buffer to the output buffer/stream
    virtual OutStream& write( const char* buffer, unsigned int num )
    {
        return *this;
    }

    /// indicates that the stream can't actually be written to.
    virtual bool isWritable()
    {
        return false;
    }

};

#endif /* IOSTREAM_H_ */
