blk_BufferReader Class Reference
[IVD Data format.]

#include <df.h>

Inheritance diagram for blk_BufferReader:

Inheritance graph
[legend]
Collaboration diagram for blk_BufferReader:

Collaboration graph
[legend]

List of all members.


Detailed Description

Base class for read buffering implementations.

Definition at line 468 of file df.h.


Public Member Functions

 blk_BufferReader (df_BlockManager &a_mgr)
virtual ~blk_BufferReader ()

Protected Member Functions

virtual void Run (void *a_arg)
virtual UInt32_t Read (UInt8_t *a_data, const UInt32_t a_size)=0

Protected Attributes

df_BlockManagerm_blkManager
df_MgrWriter m_mgrWriter

Private Attributes

 log_CLASSID_m

Constructor & Destructor Documentation

blk_BufferReader::blk_BufferReader ( df_BlockManager a_mgr  )  [inline]

Definition at line 470 of file df.h.

00471     : m_blkManager(a_mgr),
00472       m_mgrWriter(a_mgr) {
00473         // Empty
00474     };

blk_BufferReader::~blk_BufferReader (  )  [virtual]

Definition at line 34 of file blk_bufferreader.cpp.

References log_FUNC_m.

00034                                     {
00035     log_FUNC_m(~blk_DiskBuffer);
00036 
00037 }


Member Function Documentation

void blk_BufferReader::Run ( void *  a_arg  )  [protected, virtual]

Reimplemented from cmn_Thread.

Definition at line 39 of file blk_bufferreader.cpp.

References dbg_LOW, df_MgrWriter::Flush(), ivd_BaseException::GetDescription(), ivd_BaseException::GetError(), df_MgrWriter::GetFree(), df_DataBlock::GetFreeSize(), df_DataBlock::GetPosition(), ie_DF_INV_BLK, ivd_Error, log_DBG_m, log_FUNC_m, m_mgrWriter, df_DataBlock::Move(), NULL, Read(), and df_MgrWriter::SetError().

00039                                       {
00040     log_FUNC_m(Run);
00041 
00042     log_DBG_m(dbg_LOW, " Buffer reader thread started.");
00043 
00044     UInt32_t    blocks = 0;
00045     UInt32_t    read;
00046 
00047     try {
00048 
00049         // This loop exist when all readers finish
00050         // or end of file is reached (read == 0).
00051         do {
00052             df_DataBlock *blk = m_mgrWriter.GetFree();
00053             if (blk == NULL) {
00054                 break;
00055             }
00056 
00057             UInt8_t     *buf     = blk->GetPosition();
00058             UInt32_t    bufSize  = blk->GetFreeSize();
00059             try {
00060                 read = Read(buf, bufSize);
00061                 if (read > 0 && read < bufSize) {
00062                     ostringstream sstr;
00063                     sstr
00064                         << "Read less than requested: "
00065                         << read << " < " << bufSize << ".";
00066 
00067                     throw ivd_Error(ie_DF_INV_BLK, sstr.str(), true);
00068                 }
00069             }
00070             catch (ivd_SysError &ie) {
00071                 m_mgrWriter.SetError(
00072                     new ivd_SysError(ie.GetError(), ie.GetDescription()) );
00073                 throw;
00074             }
00075             catch (ivd_Error &ie) {
00076                 m_mgrWriter.SetError(
00077                     new ivd_Error(ie.GetError(), ie.GetDescription()) );
00078                 throw;
00079             }
00080             catch (ivd_Exception &ie) {
00081                 m_mgrWriter.SetError(
00082                     new ivd_Error(ie.GetError(), ie.GetDescription()) );
00083                 throw;
00084             }
00085 
00086             if (read > 0) {
00087                 blocks++;
00088                 blk->Move(read);
00089                 m_mgrWriter.Flush();
00090             }
00091         } while (read > 0);
00092     }
00093     catch (ivd_Error &ie) {
00094         log_DBG_m(dbg_LOW,
00095             "Problems reading from disk buffer. Thread going down." << endl <<
00096             "Error: " << ie);
00097     }
00098     catch (ivd_Exception &ie) {
00099         log_DBG_m(dbg_LOW,
00100             "Problems reading from disk buffer. Thread going down." <<
00101             "Error: " << ie);
00102     }
00103 
00104     log_DBG_m(dbg_LOW,
00105         "Read " << blocks << " blocks from buffer.");
00106 
00107     log_DBG_m(dbg_LOW,"End of data.");
00108 }

Here is the call graph for this function:

virtual UInt32_t blk_BufferReader::Read ( UInt8_t a_data,
const UInt32_t  a_size 
) [protected, pure virtual]

Implemented in blk_DiskBufferReader, blk_StdIOReader, and blk_DiskFRIReader.

Referenced by Run().

Here is the caller graph for this function:


Member Data Documentation

Definition at line 478 of file df.h.

Definition at line 479 of file df.h.

Referenced by Run().

Reimplemented from cmn_Thread.

Reimplemented in blk_DiskBufferReader, blk_StdIOReader, and blk_DiskFRIReader.

Definition at line 486 of file df.h.


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

Generated on Mon Feb 27 19:01:56 2012 for OPENARCHIVE by  doxygen 1.5.6