Scale Stack 0.3 Developer Documentation

scalestack::network::stream_provider Class Reference

#include <stream.h>

Inheritance diagram for scalestack::network::stream_provider:
scalestack::event::handler scalestack::network::ip::tcp::connection scalestack::network::local::stream::connection

Public Member Functions

 stream_provider (event::handler_service &handler_service, stream_service &stream_service, int file_descriptor)
 stream_provider (event::handler_service &handler_service, stream_service &stream_service, const struct addrinfo *addresses)
virtual ~stream_provider ()
void started ()
void shutdown (void)
void timer_expired (void)
void run (void)
virtual void set_file_descriptor (int file_descriptor)
void reconnect (void)
void consume (size_t size)
size_t write (uint8_t *buffer, size_t size, bool flush=false)
void shutdown_write (void)

Protected Attributes

struct addrinfo * _addresses
struct addrinfo * _address

Private Member Functions

 stream_provider (const stream_provider &)
stream_provideroperator= (const stream_provider &)
void read_ready (int file_descriptor)
void write_ready (int file_descriptor)
void _connect (void)
void _consume (size_t size)
void _flush (void)
size_t _write (uint8_t *buffer, size_t size)

Private Attributes

bool _connecting
bool _waiting_for_consume
bool _call_flush_write
bool _shutdown_write
bool _connection_dead
int _file_descriptor
size_t _read_buffer_offset
size_t _read_buffer_size
size_t _write_buffer_offset
size_t _write_buffer_size
std::auto_ptr< stream_stream
stream_service_stream_service
uint8_t _read_buffer [_read_buffer_max_size]
uint8_t _write_buffer [_write_buffer_max_size]

Static Private Attributes

static const size_t _read_buffer_max_size = 8192
static const size_t _write_buffer_max_size = 8192

Detailed Description

This is the base class for classes providing streams.

Definition at line 174 of file stream.h.


Constructor & Destructor Documentation

scalestack::network::stream_provider::stream_provider ( event::handler_service handler_service,
stream_service stream_service,
int  file_descriptor 
)

Constructor when the stream was accepted by a listener.

Parameters:
[in] handler_service Handler service the datagram provider is associated with.
[in] stream_service Stream service the stream provider is associated with.
[in] file_descriptor File descriptor of the accepted connection.

Definition at line 47 of file stream.cc.

scalestack::network::stream_provider::stream_provider ( event::handler_service handler_service,
stream_service stream_service,
const struct addrinfo *  addresses 
)

Constructor when the stream is initiating the connection.

Parameters:
[in] handler_service Handler service the datagram provider is associated with.
[in] stream_service Stream service the stream provider is associated with.
[in] addresses List of addresses to use while connecting.

Definition at line 69 of file stream.cc.

scalestack::network::stream_provider::~stream_provider (  )  [virtual]

Definition at line 91 of file stream.cc.

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

Don't allow copying of objects.


Member Function Documentation

void scalestack::network::stream_provider::started ( void   )  [virtual]

See event::handler::started().

Reimplemented from scalestack::event::handler.

Definition at line 95 of file stream.cc.

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

See event::handler::shutdown().

Reimplemented from scalestack::event::handler.

Definition at line 415 of file stream.h.

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

See event::handler::timer_expired().

Reimplemented from scalestack::event::handler.

Definition at line 420 of file stream.h.

void scalestack::network::stream_provider::run ( void   )  [virtual]

See event::handler::run().

Reimplemented from scalestack::event::handler.

Definition at line 107 of file stream.cc.

void scalestack::network::stream_provider::set_file_descriptor ( int  file_descriptor  )  [virtual]

See event::handler::set_file_descriptor().

Reimplemented from scalestack::event::handler.

Reimplemented in scalestack::network::ip::tcp::connection.

Definition at line 124 of file stream.cc.

void scalestack::network::stream_provider::reconnect ( void   ) 

See stream::reconnect().

Definition at line 130 of file stream.cc.

void scalestack::network::stream_provider::consume ( size_t  size  ) 

See stream::consume().

Definition at line 137 of file stream.cc.

size_t scalestack::network::stream_provider::write ( uint8_t *  buffer,
size_t  size,
bool  flush = false 
)

See stream::write().

Definition at line 146 of file stream.cc.

void scalestack::network::stream_provider::shutdown_write ( void   ) 

See stream::shutdown_write().

Definition at line 234 of file stream.cc.

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

Don't allow assignment of objects.

void scalestack::network::stream_provider::read_ready ( int  file_descriptor  )  [private, virtual]

This will read data from the connection into the buffer and call read(). This implements a method in the base class so does not have the _ prefix.

Parameters:
[in] file_descriptor File descriptor to read data on.

Reimplemented from scalestack::event::handler.

Definition at line 244 of file stream.cc.

void scalestack::network::stream_provider::write_ready ( int  file_descriptor  )  [private, virtual]

This flushes any data that was in the buffer and calls write_ready() for derived classes if needed. This implements a method in the base class so does not have the _ prefix.

Parameters:
[in] file_descriptor File descriptor to write data to.

Reimplemented from scalestack::event::handler.

Definition at line 313 of file stream.cc.

void scalestack::network::stream_provider::_connect ( void   )  [private]

Try connecting to the next entry in the address info list.

Definition at line 341 of file stream.cc.

void scalestack::network::stream_provider::_consume ( size_t  size  )  [private]

Perform the read buffer consumption, used by both read_ready() and consume().

Parameters:
[in] size Amount of buffer to consume.

Definition at line 398 of file stream.cc.

void scalestack::network::stream_provider::_flush ( void   )  [private]

Flush data that is in the write buffer.

Definition at line 426 of file stream.cc.

size_t scalestack::network::stream_provider::_write ( uint8_t *  buffer,
size_t  size 
) [private]

Write data to connection and handle any errors.

Parameters:
[in] buffer Buffer to write.
[in] size Size of buffer.
Returns:
Amount of data written.

Definition at line 457 of file stream.cc.


Field Documentation

Definition at line 253 of file stream.h.

struct addrinfo* scalestack::network::stream_provider::_address [protected]

Definition at line 254 of file stream.h.

const size_t scalestack::network::stream_provider::_read_buffer_max_size = 8192 [static, private]

Definition at line 321 of file stream.h.

const size_t scalestack::network::stream_provider::_write_buffer_max_size = 8192 [static, private]

Definition at line 322 of file stream.h.

Definition at line 324 of file stream.h.

Definition at line 325 of file stream.h.

Definition at line 326 of file stream.h.

Definition at line 327 of file stream.h.

Definition at line 328 of file stream.h.

Definition at line 329 of file stream.h.

Definition at line 330 of file stream.h.

Definition at line 331 of file stream.h.

Definition at line 332 of file stream.h.

Definition at line 333 of file stream.h.

Definition at line 334 of file stream.h.

Definition at line 335 of file stream.h.

Definition at line 336 of file stream.h.

Definition at line 337 of file stream.h.


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