BufferedIOHandler Class Reference

a IOHandler with buffer support the buffer is only for read(). write() is not supported the public functions of this class are *not* thread safe! More...

#include <buffered_io_handler.h>

Inheritance diagram for BufferedIOHandler:
IOHandlerBufferHelper IOHandler zmm::Object

Public Member Functions

 BufferedIOHandler (zmm::Ref< IOHandler > underlyingHandler, size_t bufSize, size_t maxChunkSize, size_t initialFillSize)
 get an instance of a BufferedIOHandler
virtual void open (enum UpnpOpenFileMode mode)
 Opens a data for the web server.
virtual void close ()
 Close/free previously opened/initialized data.
virtual int read (char *buf, size_t length)
 Reads previously opened/initialized data sequentially.
virtual void seek (off_t offset, int whence)
 Performs a seek on an open/initialized data.
virtual int write (char *buf, size_t length)
 Writes to previously opened/initialized data sequentially.
void retain ()
void release ()
int getRefCount ()

Static Public Member Functions

static void * operator new (size_t size)
static void operator delete (void *ptr)

Protected Member Functions

void startBufferThread ()
void stopBufferThread ()

Static Protected Member Functions

static void * staticThreadProc (void *arg)

Protected Attributes

size_t bufSize
size_t initialFillSize
char * buffer
bool isOpen
bool eof
bool readError
bool waitForInitialFillSize
bool signalAfterEveryRead
bool checkSocket
bool empty
size_t a
size_t b
off_t posRead
bool seekEnabled
bool doSeek
off_t seekOffset
int seekWhence
pthread_t bufferThread
bool threadShutdown
zmm::Ref< Condcond
zmm::Ref< Mutexmutex
mt_atomic_t _ref_count

Private Member Functions

virtual void threadProc ()

Private Attributes

zmm::Ref< IOHandlerunderlyingHandler
size_t maxChunkSize

Detailed Description

a IOHandler with buffer support the buffer is only for read(). write() is not supported the public functions of this class are *not* thread safe!

Definition at line 42 of file buffered_io_handler.h.


Constructor & Destructor Documentation

BufferedIOHandler::BufferedIOHandler ( zmm::Ref< IOHandler underlyingHandler,
size_t  bufSize,
size_t  maxChunkSize,
size_t  initialFillSize 
)

get an instance of a BufferedIOHandler

Parameters:
underlyingHandler the IOHandler from which the buffer should read
bufSize the size of the buffer in bytes
maxChunkSize the maximum size of the chunks which are read by the buffer
initialFillSize the number of bytes which have to be in the buffer before the first read at the very beginning or after a seek returns; 0 disables the delay

Definition at line 41 of file buffered_io_handler.cc.

References _, _Exception, and nil.


Member Function Documentation

void BufferedIOHandler::close (  )  [virtual]

Close/free previously opened/initialized data.

Reimplemented from IOHandlerBufferHelper.

Definition at line 61 of file buffered_io_handler.cc.

References underlyingHandler.

int Object::getRefCount (  )  [inherited]

Definition at line 78 of file object.cc.

References zmm::Object::_ref_count, and atomic_get().

virtual void BufferedIOHandler::open ( enum UpnpOpenFileMode  mode  )  [virtual]

Opens a data for the web server.

Parameters:
mode in which the data will be opened (we only support UPNP_READ)
Todo:
Genych, ya tut che to zapamyatowal kak gawno rabotaet? kto filename poluchaet??

Reimplemented from IOHandlerBufferHelper.

void Object::operator delete ( void *  ptr  )  [static, inherited]

Definition at line 87 of file object.cc.

References FREE.

void * Object::operator new ( size_t  size  )  [static, inherited]

Definition at line 83 of file object.cc.

References MALLOC.

virtual int IOHandlerBufferHelper::read ( char *  buf,
size_t  length 
) [virtual, inherited]

Reads previously opened/initialized data sequentially.

Parameters:
buf This buffer will be filled by our read functions.
length Number of bytes to read.

Reimplemented from IOHandler.

void Object::release (  )  [inherited]
void Object::retain (  )  [inherited]
virtual void IOHandlerBufferHelper::seek ( off_t  offset,
int  whence 
) [virtual, inherited]

Performs a seek on an open/initialized data.

Parameters:
offset Number of bytes to move in the buffer. For seeking forwards positive values are used, for seeking backwards - negative. Offset must be positive if origin is set to SEEK_SET
whence The position to move relative to. SEEK_CUR to move relative to current position, SEEK_END to move relative to the end of file, SEEK_SET to specify an absolute offset.

Reimplemented from IOHandler.

void IOHandlerBufferHelper::startBufferThread (  )  [protected, inherited]
void * IOHandlerBufferHelper::staticThreadProc ( void *  arg  )  [static, protected, inherited]
void IOHandlerBufferHelper::stopBufferThread (  )  [protected, inherited]
void BufferedIOHandler::threadProc (  )  [private, virtual]
virtual int IOHandler::write ( char *  buf,
size_t  length 
) [virtual, inherited]

Writes to previously opened/initialized data sequentially.

Parameters:
buf Data to be written.
length Number of bytes to write.

Field Documentation

mt_atomic_t zmm::Object::_ref_count [protected, inherited]
size_t IOHandlerBufferHelper::a [protected, inherited]
size_t IOHandlerBufferHelper::b [protected, inherited]
char* IOHandlerBufferHelper::buffer [protected, inherited]
pthread_t IOHandlerBufferHelper::bufferThread [protected, inherited]
size_t IOHandlerBufferHelper::bufSize [protected, inherited]

Definition at line 65 of file io_handler_buffer_helper.h.

Referenced by threadProc().

bool IOHandlerBufferHelper::checkSocket [protected, inherited]
zmm::Ref<Cond> IOHandlerBufferHelper::cond [protected, inherited]
bool IOHandlerBufferHelper::doSeek [protected, inherited]
bool IOHandlerBufferHelper::empty [protected, inherited]
bool IOHandlerBufferHelper::eof [protected, inherited]
size_t IOHandlerBufferHelper::initialFillSize [protected, inherited]

Definition at line 66 of file io_handler_buffer_helper.h.

Referenced by threadProc().

bool IOHandlerBufferHelper::isOpen [protected, inherited]

Definition at line 60 of file buffered_io_handler.h.

Referenced by threadProc().

zmm::Ref<Mutex> IOHandlerBufferHelper::mutex [protected, inherited]
off_t IOHandlerBufferHelper::posRead [protected, inherited]
bool IOHandlerBufferHelper::readError [protected, inherited]
bool IOHandlerBufferHelper::seekEnabled [protected, inherited]
off_t IOHandlerBufferHelper::seekOffset [protected, inherited]

Definition at line 84 of file io_handler_buffer_helper.h.

Referenced by threadProc().

int IOHandlerBufferHelper::seekWhence [protected, inherited]

Definition at line 85 of file io_handler_buffer_helper.h.

Referenced by threadProc().

bool IOHandlerBufferHelper::signalAfterEveryRead [protected, inherited]
bool IOHandlerBufferHelper::threadShutdown [protected, inherited]

Definition at line 59 of file buffered_io_handler.h.

Referenced by close(), and threadProc().

bool IOHandlerBufferHelper::waitForInitialFillSize [protected, inherited]

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

Generated on Fri Mar 26 20:16:56 2010 for MediaTomb by  doxygen 1.6.1