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

blk_BufferReader Class Reference
[IVD Data format.]

Base class for read buffering implementations. More...

#include <df.h>

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

List of all members.

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

Detailed Description

Base class for read buffering implementations.

Definition at line 482 of file df.h.


Constructor & Destructor Documentation

blk_BufferReader::blk_BufferReader ( df_BlockManager a_mgr  )  [inline]

Definition at line 484 of file df.h.

    : m_blkManager(a_mgr),
      m_mgrWriter(a_mgr) {
        // Empty
    };

blk_BufferReader::~blk_BufferReader (  )  [virtual]

Definition at line 48 of file blk_bufferreader.cpp.

References log_FUNC_m.

                                    {
    log_FUNC_m(~blk_DiskBuffer);

}


Member Function Documentation

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:

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

Reimplemented from cmn_Thread.

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

                                      {
    log_FUNC_m(Run);

    log_DBG_m(dbg_LOW, " Buffer reader thread started.");

    UInt32_t    blocks = 0;
    UInt32_t    read;

    try {

        // This loop exist when all readers finish
        // or end of file is reached (read == 0).
        do {
            df_DataBlock *blk = m_mgrWriter.GetFree();
            if (blk == NULL) {
                break;
            }

            UInt8_t     *buf     = blk->GetPosition();
            UInt32_t    bufSize  = blk->GetFreeSize();
            try {
                read = Read(buf, bufSize);
                if (read > 0 && read < bufSize) {
                    ostringstream sstr;
                    sstr
                        << "Read less than requested: "
                        << read << " < " << bufSize << ".";

                    throw ivd_Error(ie_DF_INV_BLK, sstr.str(), true);
                }
            }
            catch (ivd_SysError &ie) {
                m_mgrWriter.SetError(
                    new ivd_SysError(ie.GetError(), ie.GetDescription()) );
                throw;
            }
            catch (ivd_Error &ie) {
                m_mgrWriter.SetError(
                    new ivd_Error(ie.GetError(), ie.GetDescription()) );
                throw;
            }
            catch (ivd_Exception &ie) {
                m_mgrWriter.SetError(
                    new ivd_Error(ie.GetError(), ie.GetDescription()) );
                throw;
            }

            if (read > 0) {
                blocks++;
                blk->Move(read);
                m_mgrWriter.Flush();
            }
        } while (read > 0);
    }
    catch (ivd_Error &ie) {
        log_DBG_m(dbg_LOW,
            "Problems reading from disk buffer. Thread going down." << endl <<
            "Error: " << ie);
    }
    catch (ivd_Exception &ie) {
        log_DBG_m(dbg_LOW,
            "Problems reading from disk buffer. Thread going down." <<
            "Error: " << ie);
    }

    log_DBG_m(dbg_LOW,
        "Read " << blocks << " blocks from buffer.");

    log_DBG_m(dbg_LOW,"End of data.");
}

Here is the call graph for this function:


Member Data Documentation

Reimplemented from cmn_Thread.

Reimplemented in blk_DiskBufferReader, blk_StdIOReader, and blk_DiskFRIReader.

Definition at line 500 of file df.h.

Definition at line 492 of file df.h.

Definition at line 493 of file df.h.

Referenced by Run().


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