df_BlockReader Class Reference
[IVD Data format.]

#include <df.h>

Inheritance diagram for df_BlockReader:

Inheritance graph
[legend]
Collaboration diagram for df_BlockReader:

Collaboration graph
[legend]

List of all members.


Detailed Description

Class take care about blocks got by the df_MgrReader.

Author:
Dejan Volk Lupo, HERMES SoftLab
See also:
<reference>

Definition at line 1378 of file df.h.


Public Member Functions

 df_BlockReader (UInt32_t a_blkType, bbt_BufType_t a_bufType, UInt32_t a_blkSize)
virtual ~df_BlockReader ()
df_BlockManagerGetMgr () const
void NewFRIBuffer (const string &a_id)
void NewDiskBuffer (const string &a_id, const string &a_diskBufferFS)
void NewNetBuffer (i_DownloadAgent_ptr a_downloadAgt)
virtual void GetNextBlock ()
 get next block and check its header
virtual void GetRawNextBlock ()
 just get next block

Public Attributes

 log_CLASSID_m
 Macro to add class name member s_className.

Private Member Functions

df_DataBlockReleaseAndGetNextBlock ()
 both GetNextBlock() and GetRawNextBlock() methods use this one
void Release ()
 release current block

Private Attributes

auto_ptr< df_BlockManagerm_manager
auto_ptr< df_MgrReaderm_reader

Constructor & Destructor Documentation

df_BlockReader::df_BlockReader ( UInt32_t  a_blkType,
bbt_BufType_t  a_bufType,
UInt32_t  a_blkSize 
)

Definition at line 35 of file df_blockreader.cpp.

References bbt_DISK_BUF, bbt_DISK_FRI, bbt_DISK_FRI_RECOVERY, bbt_REMOTE_BUF, bbt_SHMEM_BUF, bbt_TAPE_READ, df_BlockManager, df_DISKBUF_BLOCKS_c, df_DISKFRI_BLOCKS_c, df_MEMBUF_BLOCKS_c, df_REMOTEBUF_BLOCKS_c, df_TAPEBUF_c, log_FUNC_m, m_manager, and m_reader.

00038     : 
00039     df_BlockProxy(a_blkType, a_bufType, a_blkSize)
00040 {
00041     log_FUNC_m(df_BlockReader);
00042 
00043     UInt32_t count(4);
00044 
00045     switch (a_bufType) {
00046         case bbt_DISK_BUF:          count = df_DISKBUF_BLOCKS_c; break;
00047         case bbt_SHMEM_BUF:         count = df_MEMBUF_BLOCKS_c; break;
00048         case bbt_REMOTE_BUF:        count = df_REMOTEBUF_BLOCKS_c; break;
00049         case bbt_DISK_FRI:          count = df_DISKFRI_BLOCKS_c; break;
00050         case bbt_DISK_FRI_RECOVERY: count = df_DISKFRI_BLOCKS_c; break;
00051         case bbt_TAPE_READ:         count = df_TAPEBUF_c; break;
00052     };
00053 
00054     m_manager.reset( new df_BlockManager(a_blkSize, count) );
00055     m_reader.reset( new df_MgrReader( *m_manager.get() ) );
00056 }

df_BlockReader::~df_BlockReader (  )  [virtual]

Definition at line 60 of file df_blockreader.cpp.

References dbg_LOW, log_DBG_m, log_FUNC_m, and Release().

00060                                 {
00061     log_FUNC_m(~df_BlockReader);
00062     try {
00063         Release();
00064     }
00065     catch (...) {
00066         log_DBG_m(dbg_LOW, "Caught exception in destructor. Ignore it.");
00067     }
00068 }

Here is the call graph for this function:


Member Function Documentation

df_BlockManager& df_BlockReader::GetMgr (  )  const [inline]

Definition at line 1394 of file df.h.

Referenced by i_FSC_i::CheckWithMedVolume(), and bea_FRI::CreateFRI().

01394                                     {
01395         return *(m_manager.get());
01396     };

Here is the caller graph for this function:

void df_BlockReader::NewFRIBuffer ( const string &  a_id  ) 

Definition at line 139 of file df_blockreader.cpp.

References log_FUNC_A_m, m_manager, and cmn_Thread::Start().

00139                                                       {
00140 
00141     log_FUNC_A_m(NewFRIBuffer, "id: " << a_id);
00142 
00143     blk_DiskFRIReader *fri_p =
00144         new blk_DiskFRIReader(*m_manager.get(), a_id);
00145     fri_p->Start();
00146 }

Here is the call graph for this function:

void df_BlockReader::NewDiskBuffer ( const string &  a_id,
const string &  a_diskBufferFS 
)

Definition at line 148 of file df_blockreader.cpp.

References log_FUNC_A_m, m_manager, and cmn_Thread::Start().

Referenced by i_HSM_i::EfficientRecall(), and i_HSM_i::Recall().

00148                                                                                    {
00149     log_FUNC_A_m(NewDiskBuffer, "file: " << a_diskBufferFS << ", bufferID "<< a_id);
00150 
00151     blk_DiskBufferReader *db_p =
00152         new blk_DiskBufferReader(*m_manager.get(), a_diskBufferFS, a_id);
00153     db_p->Start();
00154 }

Here is the call graph for this function:

Here is the caller graph for this function:

void df_BlockReader::NewNetBuffer ( i_DownloadAgent_ptr  a_downloadAgt  ) 

Definition at line 156 of file df_blockreader.cpp.

References log_FUNC_A_m, m_manager, and cmn_Thread::Start().

Referenced by i_HSM_i::EfficientRecall(), and i_HSM_i::Recall().

00156                                                                    {
00157     log_FUNC_A_m(NewNetBuffer, "uloadAgt: " << a_downloadAgt);
00158 
00159     blk_NetReader *nw_p =
00160         new blk_NetReader(*m_manager.get(), a_downloadAgt);
00161     nw_p->Start();
00162 }

Here is the call graph for this function:

Here is the caller graph for this function:

void df_BlockReader::GetNextBlock (  )  [virtual]

get next block and check its header

Reimplemented from df_BlockProxy.

Definition at line 72 of file df_blockreader.cpp.

References dbg_LOW, df_DataBlock::GetBlockID(), df_DataBlock::GetData(), log_DBG_m, log_FUNC_m, df_BlockProxy::m_curBlock_p, NULL, ReleaseAndGetNextBlock(), and df_BlockProxy::SetPtrToDataBlock().

00072                                  {
00073     log_FUNC_m(GetNextBlock);
00074 
00075     df_DataBlock *dataBlock_p = ReleaseAndGetNextBlock();
00076     
00077     if (dataBlock_p == NULL) {
00078         m_curBlock_p = NULL;
00079         log_DBG_m(dbg_LOW, "NULL block pointer -> No more blocks.");
00080         return;
00081     }
00082 
00083     // actualy is already set but has to be verified too.
00084     SetPtrToDataBlock(dataBlock_p->GetData(), dataBlock_p->GetBlockID());
00085 }

Here is the call graph for this function:

void df_BlockReader::GetRawNextBlock (  )  [virtual]

just get next block

Reimplemented from df_BlockProxy.

Definition at line 89 of file df_blockreader.cpp.

References dbg_LOW, df_DataBlock::GetBlockID(), df_DataBlock::GetData(), log_DBG_m, log_FUNC_m, df_BlockProxy::m_blkNum, NULL, ReleaseAndGetNextBlock(), and df_BlockProxy::SetPtrToDataBlock().

00089                                     {
00090     df_DataBlock *dataBlock_p = ReleaseAndGetNextBlock();
00091     if (dataBlock_p == NULL) {
00092         log_FUNC_m(GetRawNextBlock);
00093         log_DBG_m(dbg_LOW, "NULL RAW block pointer -> No more blocks.");
00094         return;
00095     }
00096     
00097     SetPtrToDataBlock(dataBlock_p->GetData(), dataBlock_p->GetBlockID(), true);
00098     m_blkNum++; // RAW block does not have seqNum, but it is counted
00099 }

Here is the call graph for this function:

df_DataBlock * df_BlockReader::ReleaseAndGetNextBlock (  )  [private]

both GetNextBlock() and GetRawNextBlock() methods use this one

Definition at line 103 of file df_blockreader.cpp.

References ivd_BaseException::GetError(), ie_DF_EOD, df_DataBlock::IsEmpty(), log_FUNC_m, log_WRN_m, m_reader, NULL, and Release().

Referenced by GetNextBlock(), and GetRawNextBlock().

00103                                                      {
00104     log_FUNC_m(ReleaseAndGetNextBlock);
00105     df_DataBlock *dataBlock_p = NULL;
00106     Release();
00107     try {
00108         dataBlock_p = m_reader->GetFull();
00109         if (dataBlock_p != NULL && dataBlock_p->IsEmpty()) {
00110             log_WRN_m("Strange: Empty block in the middle of the input stream.");
00111         }
00112     }
00113     catch (ivd_Error &ie) {
00114         if (ie.GetError() == ie_DF_EOD) {
00115             dataBlock_p = NULL;
00116         }
00117         else {
00118             throw;
00119         }
00120     }
00121     return dataBlock_p;
00122 }

Here is the call graph for this function:

Here is the caller graph for this function:

void df_BlockReader::Release (  )  [private]

release current block

Definition at line 126 of file df_blockreader.cpp.

References df_BlockProxy::m_curBlock_p, m_reader, and NULL.

Referenced by ReleaseAndGetNextBlock(), and ~df_BlockReader().

00126                             {
00127     if (m_curBlock_p != NULL) {
00128         m_reader.get()->Release();
00129         m_curBlock_p = NULL;
00130     }
00131 }

Here is the caller graph for this function:


Member Data Documentation

Macro to add class name member s_className.

Reimplemented from df_BlockProxy.

Definition at line 1387 of file df.h.

Definition at line 1390 of file df.h.

Referenced by df_BlockReader(), NewDiskBuffer(), NewFRIBuffer(), and NewNetBuffer().

Definition at line 1391 of file df.h.

Referenced by df_BlockReader(), Release(), and ReleaseAndGetNextBlock().


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

Generated on Mon Feb 27 19:11:43 2012 for OPENARCHIVE by  doxygen 1.5.6