//
// $Id: LayeredOutStream.h,v 1.9 2005/07/12 19:15:37 will_mason Exp $
//
// vi: set ft=objc:

/*
 * ObjectiveLib - a library of containers and algorithms for Objective-C
 *
 * Copyright (c) 2004
 * Will Mason
 *
 * Portions:
 *
 * Copyright (c) 1994
 * Hewlett-Packard Company
 *
 * Copyright (c) 1996,1997
 * Silicon Graphics Computer Systems, Inc.
 *
 * Copyright (c) 1997
 * Moscow Center for SPARC Technology
 *
 * Copyright (c) 1999 
 * Boris Fomitchev
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 * You may contact the author at will_mason@users.sourceforge.net.
 */

#if !defined(LAYEREDOUTSTREAM_OL_GUARD)
#define LAYEREDOUTSTREAM_OL_GUARD

#import <ObjectiveLib/OutStream.h>

/**
 * @class OLLayeredOutStream LayeredOutStream.h ObjectiveLib/LayeredOutStream.h
 *
 * An out stream that is layered over another out stream. Layered streams can
 * filter data that are ultimately written out to connected streams. The methods
 * in OLLayeredOutStream merely forward messages to the underlying out stream.
*
 * @sa Streams
 *
 * @ingroup Streams
 */
@interface OLLayeredOutStream : OLOutStream
{
@protected
    /**
     * The stream on top of which this stream is layered
     */
    OLOutStream* stream;
}

/**
 * @name Initializers and Deallocators
 */
/* @{ */
/**
 * Initialize the stream.
 *
 * @param underStream the stream that functions as the layer under this one
 * @return a reference to this stream
 */
- (id) initWithOutStream: (OLOutStream*)underStream;

/**
 * Finalize the stream and deallocate any allocated memory.
 */
- (void) dealloc;
/* @} */

- (void) close;
- (void) flush;

/**
 * Write bytes to the stream. This implementation merely forwards the message
 * to the next lower stream in the stream stack.
 *
 * @exception OLInputOutputException if there is an error writing to the stream
 * @param bytes the bytes to write
 * @param count the number of bytes to write
 * @return the number of bytes written
 */
- (unsigned) writeBytes: (const uint8_t*)bytes count: (unsigned)count;

@end

#endif
