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

blk_NetReader Class Reference
[IVD Data format.]

#include <df.h>

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

List of all members.

Public Member Functions

 blk_NetReader (df_BlockManager &a_mgr, i_DownloadAgent_ptr a_downloadAgt)
virtual ~blk_NetReader ()

Protected Member Functions

virtual void Run (void *a_arg)

Protected Attributes

df_BlockManagerm_blkManager
df_MgrWriter m_mgrWriter
i_DownloadAgent_var m_downloadAgent

Private Attributes

 log_CLASSID_m

Detailed Description

Definition at line 508 of file df.h.


Constructor & Destructor Documentation

blk_NetReader::blk_NetReader ( df_BlockManager a_mgr,
i_DownloadAgent_ptr  a_downloadAgt 
)

Definition at line 48 of file blk_netreader.cpp.

  : m_blkManager(a_mgr),
    m_mgrWriter(a_mgr),
    m_downloadAgent( i_DownloadAgent::_duplicate(a_downloadAgt) ) {
      // Empty
}

blk_NetReader::~blk_NetReader (  )  [virtual]

Definition at line 57 of file blk_netreader.cpp.

References log_FUNC_m.


Member Function Documentation

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

Reimplemented from cmn_Thread.

Definition at line 61 of file blk_netreader.cpp.

References dbg_LOW, df_MgrWriter::Flush(), ivd_BaseException::GetDescription(), ivd_BaseException::GetError(), df_MgrWriter::GetFree(), df_DataBlock::GetFreeSize(), df_DataBlock::GetPosition(), ipc_EXEC_m, ivd_Error, log_DBG_m, log_FUNC_m, m_downloadAgent, m_mgrWriter, df_DataBlock::Move(), NULL, 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 go down
        // or end of file is reached (read == 0).
        do {
            df_DataBlock *blk = m_mgrWriter.GetFree();
            if (blk == NULL) {
                break;
            }

            UInt8_t*     buf     = blk->GetPosition();
            i_BlkSize_t  bufSize = blk->GetFreeSize();
            try {
                i_DataBlock_t_var data;
                ipc_EXEC_m(
                    m_downloadAgent->Read(
                        data,
                        bufSize
                    );
                );

                read = data->length();
                
                memcpy(buf, data->get_buffer(), data->length());
            }
            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 net. Thread going down." << endl <<
            "Error: " << ie);
    }
    catch (ivd_Exception &ie) {
        log_DBG_m(dbg_LOW,
            "Problems reading from net. Thread going down." <<
            "Error: " << ie);
    }

    log_DBG_m(dbg_LOW,
        "Read " << blocks << " blocks over net.");

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

Here is the call graph for this function:


Member Data Documentation

Reimplemented from cmn_Thread.

Definition at line 521 of file df.h.

Definition at line 514 of file df.h.

i_DownloadAgent_var blk_NetReader::m_downloadAgent [protected]

Definition at line 516 of file df.h.

Referenced by Run().

Definition at line 515 of file df.h.

Referenced by Run().


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