Scale Stack 0.3 Developer Documentation

scalestack::network::stream Class Reference

#include <stream.h>

Inheritance diagram for scalestack::network::stream:
scalestack::database_proxy::client scalestack::database_proxy::connection scalestack::echo::flood::stream scalestack::echo::server::stream scalestack::proxy::client scalestack::proxy::server

Public Member Functions

 stream (kernel::module &module)
virtual ~stream ()
virtual void shutdown (void)
void stop (void)
void set_timer (uint64_t milliseconds)
virtual void timer_expired (void)
void run_now (void)
virtual void run (void)
virtual void connected (void)
void reconnect (void)
virtual size_t read (uint8_t *buffer, size_t size)=0
void consume (size_t size)
virtual void read_eof (void)
size_t write (uint8_t *buffer, size_t size, bool flush=false)
virtual void flush_write (void)=0
void shutdown_write (void)

Protected Attributes

kernel::module_module

Private Member Functions

 stream (const stream &)
streamoperator= (const stream &)

Private Attributes

stream_provider_stream_provider

Friends

class stream_provider

Detailed Description

This is the base class for classes using streams.

Definition at line 46 of file stream.h.


Constructor & Destructor Documentation

scalestack::network::stream::stream ( kernel::module module  )  [inline]

Reimplemented in scalestack::echo::server::stream.

Definition at line 344 of file stream.h.

scalestack::network::stream::~stream (  )  [inline, virtual]

Reimplemented in scalestack::echo::flood::stream.

Definition at line 350 of file stream.h.

scalestack::network::stream::stream ( const stream  )  [private]

Don't allow copying of objects.


Member Function Documentation

void scalestack::network::stream::shutdown ( void   )  [inline, virtual]

See event::handler::shutdown().

Reimplemented in scalestack::proxy::client, and scalestack::proxy::server.

Definition at line 354 of file stream.h.

void scalestack::network::stream::stop ( void   )  [inline]

See event::handler::stop().

Definition at line 359 of file stream.h.

void scalestack::network::stream::set_timer ( uint64_t  milliseconds  )  [inline]

See event::handler::set_timer().

Definition at line 364 of file stream.h.

void scalestack::network::stream::timer_expired ( void   )  [inline, virtual]

See event::handler::timer_expired().

Reimplemented in scalestack::proxy::client.

Definition at line 369 of file stream.h.

void scalestack::network::stream::run_now ( void   )  [inline]

See event::handler::run_now().

Definition at line 373 of file stream.h.

void scalestack::network::stream::run ( void   )  [inline, virtual]
void scalestack::network::stream::connected ( void   )  [inline, virtual]

This is called to notify derived classes that the stream has been established. The default behavior is to ignore.

Reimplemented in scalestack::database_proxy::client, scalestack::echo::flood::stream, scalestack::proxy::client, and scalestack::proxy::server.

Definition at line 382 of file stream.h.

void scalestack::network::stream::reconnect ( void   )  [inline]

Reconnect using the set address list when this was not a stream accepted from a listening connection.

Definition at line 386 of file stream.h.

virtual size_t scalestack::network::stream::read ( uint8_t *  buffer,
size_t  size 
) [pure virtual]

This is called when data has been read and needs to be handled by derived classes.

Parameters:
[in] buffer Data that was read.
[in] size Size of data available in buffer.
Returns:
Amount of data that was consumed.

Implemented in scalestack::database_proxy::client, scalestack::database_proxy::connection, scalestack::echo::flood::stream, scalestack::echo::server::stream, scalestack::proxy::client, and scalestack::proxy::server.

void scalestack::network::stream::consume ( size_t  size  )  [inline]

Notify the connection that more data from the read buffer has been consumed. This is required after a read() call was not able to consume all the data. This can be called at a later time to remove the data from the read buffer, such as in flush_write(). If the read buffer was previously full the connection will start watching for new data.

Parameters:
[in] size The amount of data to consume.

Definition at line 391 of file stream.h.

void scalestack::network::stream::read_eof ( void   )  [inline, virtual]

Notify the connection that an EOF has been encountered while reading. The default behavior is to call shutdown().

Reimplemented in scalestack::proxy::client.

Definition at line 396 of file stream.h.

size_t scalestack::network::stream::write ( uint8_t *  buffer,
size_t  size,
bool  flush = false 
) [inline]

Write data to the connection. By default this is buffered and not flushed, but it will be flushed if the buffer becomes full. If the buffer being written is large enough, it will be written directly to the connection without being buffered. If this method is not able to write or buffer all data, the connection will return with the partial amount and call flush_write() when it is ready again.

Parameters:
[in] buffer Buffer to write.
[in] size Size of buffer.
[in] flush Whether to flush data immediately or not.
Returns:
Amount of data written or buffered.

Definition at line 401 of file stream.h.

virtual void scalestack::network::stream::flush_write ( void   )  [pure virtual]

This is called to notify derived classes that they should start flushing write data again by calling write(). This is called when the connection is ready for writing after a call to write() did not write all data.

Implemented in scalestack::database_proxy::client, scalestack::database_proxy::connection, scalestack::echo::flood::stream, scalestack::echo::server::stream, scalestack::proxy::client, and scalestack::proxy::server.

void scalestack::network::stream::shutdown_write ( void   )  [inline]

Shutdown the write end of the socket.

Definition at line 406 of file stream.h.

stream& scalestack::network::stream::operator= ( const stream  )  [private]

Don't allow assignment of objects.


Friends And Related Function Documentation

friend class stream_provider [friend]

Definition at line 168 of file stream.h.


Field Documentation

Definition at line 152 of file stream.h.

Definition at line 166 of file stream.h.


The documentation for this class was generated from the following file:
Generated on Thu Feb 17 13:10:22 2011 by  doxygen 1.6.3