FDIOHandler Class Reference

Allows the web server to read from a file, operation is blocking. More...

#include <fd_io_handler.h>

Inheritance diagram for FDIOHandler:
IOHandler zmm::Object

Public Member Functions

 FDIOHandler (zmm::String filename)
 Sets the filename to work with.
 FDIOHandler (int fd)
 Sets an aleady opened file descriptor to work with, call to open() will be ignored.
void addReference (zmm::Ref< zmm::Object > reference)
void closeOther (zmm::Ref< IOHandler > other)
virtual void open (IN enum UpnpOpenFileMode mode)
 Opens file for reading (writing is not supported).
virtual int read (OUT char *buf, IN size_t length)
 Reads a previously opened file sequentially.
virtual int write (OUT char *buf, IN size_t length)
 Writes to a previously opened file.
virtual void seek (IN off_t offset, IN int whence)
 Performs seek on an open file.
virtual void close ()
 Close a previously opened file.
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 int write (char *buf, size_t length)
 Writes to previously opened/initialized data sequentially.
virtual void seek (off_t offset, int whence)
 Performs a seek on an open/initialized data.
void retain ()
void release ()
int getRefCount ()

Static Public Member Functions

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

Protected Attributes

zmm::String filename
 Name of the file.
int fd
 Handle of the file.
bool closed
zmm::Ref< IOHandlerother
zmm::Ref< zmm::Array
< zmm::Object > > 
reference_list
mt_atomic_t _ref_count
pthread_mutex_t mutex

Detailed Description

Allows the web server to read from a file, operation is blocking.

Definition at line 39 of file fd_io_handler.h.


Constructor & Destructor Documentation

FDIOHandler::FDIOHandler ( zmm::String  filename  ) 

Sets the filename to work with.

Definition at line 49 of file fd_io_handler.cc.

References closed, fd, nil, other, and reference_list.

FDIOHandler::FDIOHandler ( int  fd  ) 

Sets an aleady opened file descriptor to work with, call to open() will be ignored.

Definition at line 58 of file fd_io_handler.cc.

References closed, filename, nil, other, and reference_list.


Member Function Documentation

void FDIOHandler::addReference ( zmm::Ref< zmm::Object reference  ) 

Definition at line 67 of file fd_io_handler.cc.

References reference_list.

void FDIOHandler::close (  )  [virtual]

Close a previously opened file.

Reimplemented from IOHandler.

Definition at line 135 of file fd_io_handler.cc.

References _, _Exception, zmm::String::c_str(), closed, fd, zmm::Exception::getMessage(), log_debug, nil, and other.

void FDIOHandler::closeOther ( zmm::Ref< IOHandler other  ) 

Definition at line 72 of file fd_io_handler.cc.

int Object::getRefCount (  )  [inherited]

Definition at line 78 of file object.cc.

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

virtual void IOHandler::open ( enum UpnpOpenFileMode  mode  )  [virtual, inherited]

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 in BufferedIOHandler, and IOHandlerBufferHelper.

void FDIOHandler::open ( IN enum UpnpOpenFileMode  mode  )  [virtual]

Opens file for reading (writing is not supported).

Definition at line 77 of file fd_io_handler.cc.

References _, _Exception, zmm::String::c_str(), fd, filename, log_debug, string_ok(), UPNP_READ, and UPNP_WRITE.

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

Referenced by web_read().

int FDIOHandler::read ( OUT char *  buf,
IN size_t  length 
) [virtual]

Reads a previously opened file sequentially.

Parameters:
buf Data from the file will be copied into this buffer.
length Number of bytes to be copied into the buffer.

Definition at line 109 of file fd_io_handler.cc.

References fd.

void Object::release (  )  [inherited]
void Object::retain (  )  [inherited]
virtual void IOHandler::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 in IOHandlerBufferHelper.

Referenced by web_seek().

void FDIOHandler::seek ( IN off_t  offset,
IN int  whence 
) [virtual]

Performs seek on an open file.

Parameters:
offset Number of bytes to move in the file. 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.

Definition at line 127 of file fd_io_handler.cc.

References _, _Exception, and fd.

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.
virtual int FDIOHandler::write ( OUT char *  buf,
IN size_t  length 
) [virtual]

Writes to a previously opened file.

Parameters:
buf Data from the buffer will be written to the file.
length Number of bytes to be written from the buffer.
Returns:
number of bytes written.

Field Documentation

mt_atomic_t zmm::Object::_ref_count [protected, inherited]
bool FDIOHandler::closed [protected]

Definition at line 47 of file fd_io_handler.h.

Referenced by close(), and FDIOHandler().

int FDIOHandler::fd [protected]

Handle of the file.

Definition at line 46 of file fd_io_handler.h.

Referenced by close(), FDIOHandler(), open(), read(), and seek().

Name of the file.

Definition at line 43 of file fd_io_handler.h.

Referenced by FDIOHandler(), and open().

pthread_mutex_t zmm::Object::mutex [protected, inherited]

Definition at line 48 of file fd_io_handler.h.

Referenced by close(), and FDIOHandler().

Definition at line 49 of file fd_io_handler.h.

Referenced by addReference(), and FDIOHandler().


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