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

df_BlockReader Class Reference
[IVD Data format.]

Class take care about blocks got by the df_MgrReader. More...

#include <df.h>

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

List of all members.

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

Detailed Description

Class take care about blocks got by the df_MgrReader.

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

Definition at line 1392 of file df.h.


Constructor & Destructor Documentation

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

Definition at line 49 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.

    : 
    df_BlockProxy(a_blkType, a_bufType, a_blkSize)
{
    log_FUNC_m(df_BlockReader);

    UInt32_t count(4);

    switch (a_bufType) {
        case bbt_DISK_BUF:          count = df_DISKBUF_BLOCKS_c; break;
        case bbt_SHMEM_BUF:         count = df_MEMBUF_BLOCKS_c; break;
        case bbt_REMOTE_BUF:        count = df_REMOTEBUF_BLOCKS_c; break;
        case bbt_DISK_FRI:          count = df_DISKFRI_BLOCKS_c; break;
        case bbt_DISK_FRI_RECOVERY: count = df_DISKFRI_BLOCKS_c; break;
        case bbt_TAPE_READ:         count = df_TAPEBUF_c; break;
    };

    m_manager.reset( new df_BlockManager(a_blkSize, count) );
    m_reader.reset( new df_MgrReader( *m_manager.get() ) );
}

df_BlockReader::~df_BlockReader (  )  [virtual]

Definition at line 74 of file df_blockreader.cpp.

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

                                {
    log_FUNC_m(~df_BlockReader);
    try {
        Release();
    }
    catch (...) {
        log_DBG_m(dbg_LOW, "Caught exception in destructor. Ignore it.");
    }
}

Here is the call graph for this function:


Member Function Documentation

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

Definition at line 1408 of file df.h.

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

                                    {
        return *(m_manager.get());
    };

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 86 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().

                                 {
    log_FUNC_m(GetNextBlock);

    df_DataBlock *dataBlock_p = ReleaseAndGetNextBlock();
    
    if (dataBlock_p == NULL) {
        m_curBlock_p = NULL;
        log_DBG_m(dbg_LOW, "NULL block pointer -> No more blocks.");
        return;
    }

    // actualy is already set but has to be verified too.
    SetPtrToDataBlock(dataBlock_p->GetData(), dataBlock_p->GetBlockID());
}

Here is the call graph for this function:

void df_BlockReader::GetRawNextBlock (  )  [virtual]

just get next block

Reimplemented from df_BlockProxy.

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

                                    {
    df_DataBlock *dataBlock_p = ReleaseAndGetNextBlock();
    if (dataBlock_p == NULL) {
        log_FUNC_m(GetRawNextBlock);
        log_DBG_m(dbg_LOW, "NULL RAW block pointer -> No more blocks.");
        return;
    }
    
    SetPtrToDataBlock(dataBlock_p->GetData(), dataBlock_p->GetBlockID(), true);
    m_blkNum++; // RAW block does not have seqNum, but it is counted
}

Here is the call graph for this function:

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

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

                                                                                   {
    log_FUNC_A_m(NewDiskBuffer, "file: " << a_diskBufferFS << ", bufferID "<< a_id);

    blk_DiskBufferReader *db_p =
        new blk_DiskBufferReader(*m_manager.get(), a_diskBufferFS, a_id);
    db_p->Start();
}

Here is the call graph for this function:

Here is the caller graph for this function:

void df_BlockReader::NewFRIBuffer ( const string &  a_id  ) 

Definition at line 153 of file df_blockreader.cpp.

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

                                                      {

    log_FUNC_A_m(NewFRIBuffer, "id: " << a_id);

    blk_DiskFRIReader *fri_p =
        new blk_DiskFRIReader(*m_manager.get(), a_id);
    fri_p->Start();
}

Here is the call graph for this function:

void df_BlockReader::NewNetBuffer ( i_DownloadAgent_ptr  a_downloadAgt  ) 

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

                                                                   {
    log_FUNC_A_m(NewNetBuffer, "uloadAgt: " << a_downloadAgt);

    blk_NetReader *nw_p =
        new blk_NetReader(*m_manager.get(), a_downloadAgt);
    nw_p->Start();
}

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 140 of file df_blockreader.cpp.

References df_BlockProxy::m_curBlock_p, m_reader, and NULL.

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

                            {
    if (m_curBlock_p != NULL) {
        m_reader.get()->Release();
        m_curBlock_p = NULL;
    }
}

Here is the caller graph for this function:

df_DataBlock * df_BlockReader::ReleaseAndGetNextBlock (  )  [private]

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

Definition at line 117 of file df_blockreader.cpp.

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

Referenced by GetNextBlock(), and GetRawNextBlock().

                                                     {
    log_FUNC_m(ReleaseAndGetNextBlock);
    df_DataBlock *dataBlock_p = NULL;
    Release();
    try {
        dataBlock_p = m_reader->GetFull();
        if (dataBlock_p != NULL && dataBlock_p->IsEmpty()) {
            log_WRN_m("Strange: Empty block in the middle of the input stream.");
        }
    }
    catch (ivd_Error &ie) {
        if (ie.GetError() == ie_DF_EOD) {
            dataBlock_p = NULL;
        }
        else {
            throw;
        }
    }
    return dataBlock_p;
}

Here is the call graph for this function:

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

Definition at line 1404 of file df.h.

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

Definition at line 1405 of file df.h.

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


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