Public Member Functions

hamcast::util::buffered_sink< block_size, maximum_size > Class Template Reference

A decorator class that adds a write buffer to an otherwise unbuffered sink. More...

#include <buffered_sink.hpp>

Inheritance diagram for hamcast::util::buffered_sink< block_size, maximum_size >:
hamcast::util::sink hamcast::util::closeable hamcast::ref_counted

List of all members.

Public Member Functions

 buffered_sink (const boost::intrusive_ptr< sink > &underlying_sink)
virtual void write (size_t buf_size, const void *buf)
virtual void flush ()
virtual int flush_hint () const
virtual void close ()
virtual bool closed () const

Detailed Description

template<size_t block_size = default_block_size, size_t maximum_size = default_max_write_buffer_size>
class hamcast::util::buffered_sink< block_size, maximum_size >

A decorator class that adds a write buffer to an otherwise unbuffered sink.

block_size: buffered_sink allocates storage always in chunks to minimize resizing of the internal buffer.

maximum_size: The maximum number of bytes buffered_sink should allocate.


Constructor & Destructor Documentation

template<size_t block_size = default_block_size, size_t maximum_size = default_max_write_buffer_size>
hamcast::util::buffered_sink< block_size, maximum_size >::buffered_sink ( const boost::intrusive_ptr< sink > &  underlying_sink  ) 

Create a buffered sink that decorates underlying_sink.

Parameters:
underlying_sink The original sink.
Precondition:
underlying_sink is valid

Member Function Documentation

template<size_t block_size = default_block_size, size_t maximum_size = default_max_write_buffer_size>
virtual void hamcast::util::buffered_sink< block_size, maximum_size >::close (  )  [virtual]

Close the data channel.

Implements hamcast::util::closeable.

template<size_t block_size = default_block_size, size_t maximum_size = default_max_write_buffer_size>
virtual bool hamcast::util::buffered_sink< block_size, maximum_size >::closed (  )  const [virtual]

Check if the data channel is closed.

Returns:
true if this is closed for read/write operations; otherwise false.

Implements hamcast::util::closeable.

template<size_t block_size = default_block_size, size_t maximum_size = default_max_write_buffer_size>
virtual void hamcast::util::buffered_sink< block_size, maximum_size >::flush (  )  [virtual]

Force the data sink to flush any buffers.

Exceptions:
Any exception that might be thrown by write().

Implements hamcast::util::sink.

template<size_t block_size = default_block_size, size_t maximum_size = default_max_write_buffer_size>
virtual int hamcast::util::buffered_sink< block_size, maximum_size >::flush_hint (  )  const [virtual]

Return the optimal block size for write operations.

Returns:
A value > 0 if this device has an optimal block size; otherwise (default implementation) 0 is returned.

Reimplemented from hamcast::util::sink.

template<size_t block_size = default_block_size, size_t maximum_size = default_max_write_buffer_size>
virtual void hamcast::util::buffered_sink< block_size, maximum_size >::write ( size_t  buf_size,
const void *  buf 
) [virtual]

Writes buf_size bytes from buf to the sink.

Parameters:
buf_size The number of bytes that should be written from buf.
buf The buffer.
Exceptions:
ios_base::failure on errors (e.g. if the sink is closed)

Implements hamcast::util::sink.


The documentation for this class was generated from the following file:
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator