Public Member Functions | Protected Member Functions | Protected Attributes | Private Attributes

blk_BufferWriter Class Reference
[IVD Data format.]

Base class for write buffering implementations. More...

#include <df.h>

Inheritance diagram for blk_BufferWriter:
Inheritance graph
[legend]
Collaboration diagram for blk_BufferWriter:
Collaboration graph
[legend]

List of all members.

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

Detailed Description

Base class for write buffering implementations.

Definition at line 313 of file df.h.


Constructor & Destructor Documentation

blk_BufferWriter::blk_BufferWriter ( df_BlockManager a_mgr  )  [inline]

Definition at line 316 of file df.h.

    : m_blkManager(a_mgr),
      m_mgrReader(a_mgr) {
        // Empty
    }

blk_BufferWriter::~blk_BufferWriter (  )  [virtual]

Definition at line 48 of file blk_bufferwriter.cpp.

References log_FUNC_m.


Member Function Documentation

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

Reimplemented from cmn_Thread.

Definition at line 52 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().

                                      {
    log_FUNC_m(Run);

    UInt64_t    blksFromMgr = 0;

    try {
        log_DBG_m(dbg_NORM, m_mgrReader.GetReaderIdx() << " Writer thread started.");

        const df_DataBlock *blk = NULL;
        while ( (blk = m_mgrReader.GetFull() ) != NULL) {
            blksFromMgr++;
            if (blk->IsEmpty()) {
                log_DBG_m(dbg_NORM, "Block is empty. Seek forward.");
                Seek(blk->GetBlockSize());
            }
            else {
                log_DBG_INT_m(dbg_DETAIL, m_mgrReader.GetReaderIdx() << " Got block. Writing.");

                try {
                    Write(blk->GetData(), blk->GetBlockSize());
                }
                catch (ivd_SysError &ie) {
                    m_mgrReader.SetError(
                        new ivd_SysError(ie.GetError(), ie.GetDescription()) );
                    throw;
                }
                catch (ivd_Error &ie) {
                    m_mgrReader.SetError(
                        new ivd_Error(ie.GetError(), ie.GetDescription()) );
                    throw;
                }
                catch (ivd_Exception &ie) {
                    m_mgrReader.SetError(
                        new ivd_Error(ie.GetError(), ie.GetDescription()) );
                    throw;
                }
            }
            m_mgrReader.Release();
        }
    }
    catch (ivd_Error &ie) {
        log_DBG_m(dbg_LOW,
            "Problems writing to disk buffer. Thread going down." << endl <<
            "Error: " << ie);
    }
    catch (ivd_Exception &ie) {
        log_DBG_m(dbg_LOW,
            "Problems writing to disk buffer. Thread going down." << endl <<
            "Error: " << ie);
    }
    if (m_blkManager.GetBlocksWritten() != blksFromMgr) {
        log_ERR_m(
            "Written: " << m_blkManager.GetBlocksWritten() <<
            " Read : " << blksFromMgr);
    }
    log_DBG_m(dbg_NORM,
        m_mgrReader.GetReaderIdx() <<
        " End of data. Blocks: " << blksFromMgr);

}

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 330 of file df.h.

Referenced by Run().

{};

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

Reimplemented from cmn_Thread.

Reimplemented in blk_DiskBufferWriter, blk_StdIOWriter, and blk_DiskFRIWriter.

Definition at line 334 of file df.h.

Definition at line 325 of file df.h.

Referenced by Run().

Definition at line 326 of file df.h.

Referenced by Run().


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