blk_BufferWriter Class Reference
[IVD Data format.]

#include <df.h>

Inheritance diagram for blk_BufferWriter:

Inheritance graph
[legend]
Collaboration diagram for blk_BufferWriter:

Collaboration graph
[legend]

List of all members.


Detailed Description

Base class for write buffering implementations.

Definition at line 299 of file df.h.


Public Member Functions

 blk_BufferWriter (df_BlockManager &a_mgr)
virtual ~blk_BufferWriter ()

Protected Member Functions

virtual void Run (void *a_arg)
virtual void Seek (const UInt32_t a_offset)
virtual void Write (const UInt8_t *a_data, const UInt32_t a_size)=0

Protected Attributes

df_BlockManagerm_blkManager
df_MgrReader m_mgrReader

Private Attributes

 log_CLASSID_m

Constructor & Destructor Documentation

blk_BufferWriter::blk_BufferWriter ( df_BlockManager a_mgr  )  [inline]

Definition at line 302 of file df.h.

00303     : m_blkManager(a_mgr),
00304       m_mgrReader(a_mgr) {
00305         // Empty
00306     }

blk_BufferWriter::~blk_BufferWriter (  )  [virtual]

Definition at line 34 of file blk_bufferwriter.cpp.

References log_FUNC_m.

00034                                     {
00035     log_FUNC_m(~blk_BufferWriter);
00036 }


Member Function Documentation

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

Reimplemented from cmn_Thread.

Definition at line 38 of file blk_bufferwriter.cpp.

References dbg_DETAIL, dbg_LOW, dbg_NORM, df_BlockManager::GetBlocksWritten(), ivd_BaseException::GetDescription(), ivd_BaseException::GetError(), df_MgrReader::GetFull(), df_MgrReader::GetReaderIdx(), ivd_Error, log_DBG_INT_m, log_DBG_m, log_ERR_m, log_FUNC_m, m_blkManager, m_mgrReader, NULL, df_MgrReader::Release(), Seek(), df_MgrReader::SetError(), and Write().

00038                                       {
00039     log_FUNC_m(Run);
00040 
00041     UInt64_t    blksFromMgr = 0;
00042 
00043     try {
00044         log_DBG_m(dbg_NORM, m_mgrReader.GetReaderIdx() << " Writer thread started.");
00045 
00046         const df_DataBlock *blk = NULL;
00047         while ( (blk = m_mgrReader.GetFull() ) != NULL) {
00048             blksFromMgr++;
00049             if (blk->IsEmpty()) {
00050                 log_DBG_m(dbg_NORM, "Block is empty. Seek forward.");
00051                 Seek(blk->GetBlockSize());
00052             }
00053             else {
00054                 log_DBG_INT_m(dbg_DETAIL, m_mgrReader.GetReaderIdx() << " Got block. Writing.");
00055 
00056                 try {
00057                     Write(blk->GetData(), blk->GetBlockSize());
00058                 }
00059                 catch (ivd_SysError &ie) {
00060                     m_mgrReader.SetError(
00061                         new ivd_SysError(ie.GetError(), ie.GetDescription()) );
00062                     throw;
00063                 }
00064                 catch (ivd_Error &ie) {
00065                     m_mgrReader.SetError(
00066                         new ivd_Error(ie.GetError(), ie.GetDescription()) );
00067                     throw;
00068                 }
00069                 catch (ivd_Exception &ie) {
00070                     m_mgrReader.SetError(
00071                         new ivd_Error(ie.GetError(), ie.GetDescription()) );
00072                     throw;
00073                 }
00074             }
00075             m_mgrReader.Release();
00076         }
00077     }
00078     catch (ivd_Error &ie) {
00079         log_DBG_m(dbg_LOW,
00080             "Problems writing to disk buffer. Thread going down." << endl <<
00081             "Error: " << ie);
00082     }
00083     catch (ivd_Exception &ie) {
00084         log_DBG_m(dbg_LOW,
00085             "Problems writing to disk buffer. Thread going down." << endl <<
00086             "Error: " << ie);
00087     }
00088     if (m_blkManager.GetBlocksWritten() != blksFromMgr) {
00089         log_ERR_m(
00090             "Written: " << m_blkManager.GetBlocksWritten() <<
00091             " Read : " << blksFromMgr);
00092     }
00093     log_DBG_m(dbg_NORM,
00094         m_mgrReader.GetReaderIdx() <<
00095         " End of data. Blocks: " << blksFromMgr);
00096 
00097 }

Here is the call graph for this function:

virtual void blk_BufferWriter::Seek ( const UInt32_t  a_offset  )  [inline, protected, virtual]

Reimplemented in blk_DiskBufferWriter, and blk_StdIOWriter.

Definition at line 316 of file df.h.

Referenced by Run().

00316 {};

Here is the caller graph for this function:

virtual void blk_BufferWriter::Write ( const UInt8_t a_data,
const UInt32_t  a_size 
) [protected, pure virtual]

Implemented in blk_DiskBufferWriter, blk_StdIOWriter, and blk_DiskFRIWriter.

Referenced by Run().

Here is the caller graph for this function:


Member Data Documentation

Definition at line 311 of file df.h.

Referenced by Run().

Definition at line 312 of file df.h.

Referenced by Run().

Reimplemented from cmn_Thread.

Reimplemented in blk_DiskBufferWriter, blk_StdIOWriter, and blk_DiskFRIWriter.

Definition at line 320 of file df.h.


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

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