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.


Detailed Description

Definition at line 494 of file df.h.


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

Constructor & Destructor Documentation

blk_NetReader::blk_NetReader ( df_BlockManager a_mgr,
i_DownloadAgent_ptr  a_downloadAgt 
)

Definition at line 34 of file blk_netreader.cpp.

00036   : m_blkManager(a_mgr),
00037     m_mgrWriter(a_mgr),
00038     m_downloadAgent( i_DownloadAgent::_duplicate(a_downloadAgt) ) {
00039       // Empty
00040 }

blk_NetReader::~blk_NetReader (  )  [virtual]

Definition at line 43 of file blk_netreader.cpp.

References log_FUNC_m.

00043                               {
00044     log_FUNC_m(~blk_NetReader);
00045 }


Member Function Documentation

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

Reimplemented from cmn_Thread.

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

00047                                    {
00048     log_FUNC_m(Run);
00049 
00050     log_DBG_m(dbg_LOW, " Buffer reader thread started.");
00051 
00052     UInt32_t    blocks = 0;
00053     UInt32_t    read;
00054 
00055     try {
00056 
00057         // This loop exist when all readers go down
00058         // or end of file is reached (read == 0).
00059         do {
00060             df_DataBlock *blk = m_mgrWriter.GetFree();
00061             if (blk == NULL) {
00062                 break;
00063             }
00064 
00065             UInt8_t*     buf     = blk->GetPosition();
00066             i_BlkSize_t  bufSize = blk->GetFreeSize();
00067             try {
00068                 i_DataBlock_t_var data;
00069                 ipc_EXEC_m(
00070                     m_downloadAgent->Read(
00071                         data,
00072                         bufSize
00073                     );
00074                 );
00075 
00076                 read = data->length();
00077                 
00078                 memcpy(buf, data->get_buffer(), data->length());
00079             }
00080             catch (ivd_SysError &ie) {
00081                 m_mgrWriter.SetError(
00082                     new ivd_SysError(ie.GetError(), ie.GetDescription()) );
00083                 throw;
00084             }
00085             catch (ivd_Error &ie) {
00086                 m_mgrWriter.SetError(
00087                     new ivd_Error(ie.GetError(), ie.GetDescription()) );
00088                 throw;
00089             }
00090             catch (ivd_Exception &ie) {
00091                 m_mgrWriter.SetError(
00092                     new ivd_Error(ie.GetError(), ie.GetDescription()) );
00093                 throw;
00094             };
00095 
00096             if (read > 0) {
00097                 blocks++;
00098                 blk->Move(read);
00099                 m_mgrWriter.Flush();
00100             }
00101         } while (read > 0);
00102     }
00103     catch (ivd_Error &ie) {
00104         log_DBG_m(dbg_LOW,
00105             "Problems reading from net. Thread going down." << endl <<
00106             "Error: " << ie);
00107     }
00108     catch (ivd_Exception &ie) {
00109         log_DBG_m(dbg_LOW,
00110             "Problems reading from net. Thread going down." <<
00111             "Error: " << ie);
00112     }
00113 
00114     log_DBG_m(dbg_LOW,
00115         "Read " << blocks << " blocks over net.");
00116 
00117     log_DBG_m(dbg_LOW,"End of data.");
00118 }

Here is the call graph for this function:


Member Data Documentation

Definition at line 500 of file df.h.

Definition at line 501 of file df.h.

Referenced by Run().

i_DownloadAgent_var blk_NetReader::m_downloadAgent [protected]

Definition at line 502 of file df.h.

Referenced by Run().

Reimplemented from cmn_Thread.

Definition at line 507 of file df.h.


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

Generated on Mon Feb 27 19:02:10 2012 for OPENARCHIVE by  doxygen 1.5.6