IOHandlerBufferHelper 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 <io_handler_buffer_helper.h>

Inheritance diagram for IOHandlerBufferHelper:
IOHandler zmm::Object BufferedIOHandler

Public Member Functions

 IOHandlerBufferHelper (size_t bufSize, size_t initialFillSize)
 get an instance of a IOHandlerBufferHelper
virtual ~IOHandlerBufferHelper ()
virtual void open (enum UpnpOpenFileMode mode)
 Opens a data for the web server.
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 void close ()
 Close/free previously opened/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 ()
virtual void threadProc ()=0

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

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 45 of file io_handler_buffer_helper.h.


Constructor & Destructor Documentation

IOHandlerBufferHelper::IOHandlerBufferHelper ( size_t  bufSize,
size_t  initialFillSize 
)

get an instance of a IOHandlerBufferHelper

Parameters:
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 42 of file io_handler_buffer_helper.cc.

References _, _Exception, a, b, buffer, checkSocket, cond, doSeek, empty, eof, isOpen, mutex, NULL, posRead, readError, seekEnabled, signalAfterEveryRead, threadShutdown, and waitForInitialFillSize.

IOHandlerBufferHelper::~IOHandlerBufferHelper (  )  [virtual]

Definition at line 81 of file io_handler_buffer_helper.cc.

References close(), and isOpen.


Member Function Documentation

void IOHandlerBufferHelper::close (  )  [virtual]

Close/free previously opened/initialized data.

Reimplemented from IOHandler.

Reimplemented in BufferedIOHandler.

Definition at line 189 of file io_handler_buffer_helper.cc.

References _, _Exception, buffer, FREE, isOpen, NULL, and stopBufferThread().

Referenced by ~IOHandlerBufferHelper().

int Object::getRefCount (  )  [inherited]

Definition at line 78 of file object.cc.

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

virtual void IOHandlerBufferHelper::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 IOHandler.

Reimplemented in BufferedIOHandler.

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]

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]

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]

Definition at line 201 of file io_handler_buffer_helper.cc.

References bufferThread, NULL, and staticThreadProc().

void * IOHandlerBufferHelper::staticThreadProc ( void *  arg  )  [static, protected]

Definition at line 222 of file io_handler_buffer_helper.cc.

References log_debug, NULL, and threadProc().

Referenced by startBufferThread().

void IOHandlerBufferHelper::stopBufferThread (  )  [protected]

Definition at line 211 of file io_handler_buffer_helper.cc.

References AUTOLOCK, AUTOUNLOCK, bufferThread, cond, mutex, NULL, and threadShutdown.

Referenced by close().

virtual void IOHandlerBufferHelper::threadProc (  )  [protected, pure virtual]

Implemented in BufferedIOHandler.

Referenced by staticThreadProc().

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]
size_t IOHandlerBufferHelper::b [protected]
char* IOHandlerBufferHelper::buffer [protected]
pthread_t IOHandlerBufferHelper::bufferThread [protected]

Definition at line 93 of file io_handler_buffer_helper.h.

Referenced by startBufferThread(), and stopBufferThread().

size_t IOHandlerBufferHelper::bufSize [protected]

Definition at line 65 of file io_handler_buffer_helper.h.

Referenced by BufferedIOHandler::threadProc().

bool IOHandlerBufferHelper::empty [protected]
bool IOHandlerBufferHelper::eof [protected]

Definition at line 66 of file io_handler_buffer_helper.h.

Referenced by BufferedIOHandler::threadProc().

Definition at line 68 of file io_handler_buffer_helper.h.

Referenced by close(), IOHandlerBufferHelper(), and ~IOHandlerBufferHelper().

Reimplemented from zmm::Object.

Definition at line 96 of file io_handler_buffer_helper.h.

Referenced by IOHandlerBufferHelper(), stopBufferThread(), and BufferedIOHandler::threadProc().

off_t IOHandlerBufferHelper::posRead [protected]

Definition at line 82 of file io_handler_buffer_helper.h.

Referenced by IOHandlerBufferHelper().

Definition at line 84 of file io_handler_buffer_helper.h.

Referenced by BufferedIOHandler::threadProc().

Definition at line 85 of file io_handler_buffer_helper.h.

Referenced by BufferedIOHandler::threadProc().

Definition at line 72 of file io_handler_buffer_helper.h.

Referenced by IOHandlerBufferHelper().


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

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