hamcast  Version 0.7
Public Member Functions | List of all members
hamcast::util::buffered_sink< block_size, maximum_size > Class Template Reference

#include <buffered_sink.hpp>

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

Public Member Functions

 buffered_sink (const 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
 
- Public Member Functions inherited from hamcast::ref_counted
long ref_count ()
 

Additional Inherited Members

- Static Public Member Functions inherited from hamcast::ref_counted
static void add_ref (ref_counted *rc)
 
static void release (ref_counted *rc)
 
- Protected Member Functions inherited from hamcast::ref_counted
 ref_counted ()
 
void ref ()
 
bool deref ()
 

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 intrusive_ptr< sink > &  underlying_sink)

Create a buffered sink that decorates underlying_sink.

Parameters
underlying_sinkThe 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
Anyexception 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_sizeThe number of bytes that should be written from buf.
bufThe buffer.
Exceptions
ios_base::failureon errors (e.g. if the sink is closed)

Implements hamcast::util::sink.


The documentation for this class was generated from the following file: