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

fsc_MedVolReader Class Reference
[File System Catalog]

#include <fsc_MedVolume.h>

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

List of all members.

Public Member Functions

 fsc_MedVolReader (const cmn_Path &a_fscDirectory, ivd_MediaKey_t a_mediaKey, ivd_MedVolNum_t a_medVolNum, fsc_medVolData_t *&a_buffPos, fsc_medVolData_t *&a_buffEnd, bool a_deleteAfterUse=false)
 ~fsc_MedVolReader ()
void GetNextBuff (fsc_medVolData_t *&a_begin_p, fsc_medVolData_t *&a_end_p)
 Prepare next buffer and set pointers to begin, end of buffer Pointers are NULL when no more data available.

Public Attributes

 log_CLASSID_m

Private Member Functions

void ReadNextBlock ()
 Large volumes are split in many files by block offset, so open next one.
void SortData ()
void GetFSCdata (const string &a_path)
 Read data from file to mem buffer.

Private Attributes

cmn_Path m_medVolPath
 path where this volume have its dataFiles
bool m_deleteAfterUse
 remove directory in destructor
list< string > m_volumeFiles_l
 all dataFile's names of this volume
list< string >::iterator m_currentFileIter

Detailed Description

Definition at line 108 of file fsc_MedVolume.h.


Constructor & Destructor Documentation

fsc_MedVolReader::fsc_MedVolReader ( const cmn_Path a_fscDirectory,
ivd_MediaKey_t  a_mediaKey,
ivd_MedVolNum_t  a_medVolNum,
fsc_medVolData_t *&  a_buffPos,
fsc_medVolData_t *&  a_buffEnd,
bool  a_deleteAfterUse = false 
)

Definition at line 247 of file fsc_MedVolume.cpp.

References dbg_DETAIL, dbg_NORM, fsc_MedVolFileExt_c, GetFSCdata(), fsc_MedVolume::GetMedVolFileName(), cmn_DirLst::GetNextName(), log_DBG_m, log_FUNC_A_m, log_WRN_m, fsc_MedVolume::m_buffEnd, fsc_MedVolume::m_buffPos, m_currentFileIter, fsc_MedVolume::m_mediaKey, fsc_MedVolume::m_medVolNum, m_medVolPath, m_volumeFiles_l, path, and cmn_Path::UpPath().

    :
    fsc_MedVolume(a_fscDirectory, a_mediaKey, a_medVolNum),
    m_deleteAfterUse(a_deleteAfterUse)
{
    log_FUNC_A_m(fsc_MedVolReader, "fscPath " << a_fscDirectory
                                  << " mediaKey " << a_mediaKey
                                  << " medVolNum " << a_medVolNum);

    m_currentFileIter = m_volumeFiles_l.begin();

    cmn_Path path = GetMedVolFileName(a_fscDirectory, m_mediaKey, m_medVolNum, 0);
    m_medVolPath  = path.UpPath();

    log_DBG_m(dbg_DETAIL, "Read volumes on path " << m_medVolPath << " first file " << path);

    try {
        cmn_DirLst dirList(m_medVolPath, fsc_MedVolFileExt_c);

        string name = dirList.GetNextName();
        while  (name.length() > 0) {        // get all files f
            log_DBG_m(dbg_DETAIL, "MedVolOfsFile " << name );
            m_volumeFiles_l.push_back(name); // store them to list
            name = dirList.GetNextName();
        }

        if (m_volumeFiles_l.size() > 0) {   // if already exist journal file(s)
            m_volumeFiles_l.sort();         // do a sort
        }
        else { // FSC does not contain data from this volume
            log_WRN_m("Strange! Directory is created, but no files in it."
                            << " medium: " << m_mediaKey
                            << ", vol: " << m_medVolNum
                            << ", directory: '" << m_medVolPath << "'");
            a_buffPos = NULL;
            a_buffEnd = NULL;
            return;
        }
        m_currentFileIter = m_volumeFiles_l.begin();
        GetFSCdata(m_medVolPath + *m_currentFileIter);
    }
    catch (ivd_SysError) { // no files in FSC
        log_DBG_m(dbg_NORM, "FSC does not contain data of medium: " << m_mediaKey
                            << ", vol: " << m_medVolNum
                            << ", directory: '" << m_medVolPath
                            << "' missing.");
    }
    // anounce usee object about buffer
    a_buffPos = m_buffPos;
    a_buffEnd = m_buffEnd;
}

Here is the call graph for this function:

fsc_MedVolReader::~fsc_MedVolReader (  ) 

Member Function Documentation

void fsc_MedVolReader::GetFSCdata ( const string &  a_path  )  [private]

Read data from file to mem buffer.

If no file exist then no buffer created.

Definition at line 370 of file fsc_MedVolume.cpp.

References log_FUNC_m, fsc_MedVolume::m_buffCapacity, fsc_MedVolume::m_buffSize, fsc_MedVolume::m_medVolDataBuf, NULL, cmn_File::OpenF(), cmn_File::ReadF(), cmn_File::SetFullPath(), SortData(), and cmn_File::StatF().

Referenced by fsc_MedVolReader(), and GetNextBuff().

                                                      {
    log_FUNC_m(GetFSCdata);

    if (m_medVolDataBuf != NULL) { // remove previous buffer
        delete [] m_medVolDataBuf;
        m_medVolDataBuf = NULL;
    }
    try {
        SetFullPath(a_path);
        OpenF();

        ivd_FileInfo_t fileInfo;
        StatF(fileInfo);

        m_buffCapacity = fileInfo.size / sizeof(fsc_medVolData_t);
        m_medVolDataBuf = new  fsc_medVolData_t[m_buffCapacity];
        m_buffSize = sizeof(fsc_medVolData_t) * m_buffCapacity;
        ReadF(m_medVolDataBuf, m_buffSize);

        SortData();
    }
    catch (ivd_SysError) {
        m_buffCapacity = 0;
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void fsc_MedVolReader::GetNextBuff ( fsc_medVolData_t *&  a_begin_p,
fsc_medVolData_t *&  a_end_p 
)

Prepare next buffer and set pointers to begin, end of buffer Pointers are NULL when no more data available.

Definition at line 319 of file fsc_MedVolume.cpp.

References cmn_File::CloseF(), dbg_LOW, GetFSCdata(), log_DBG_m, log_FUNC_m, fsc_MedVolume::m_buffEnd, fsc_MedVolume::m_buffPos, m_currentFileIter, m_medVolPath, and m_volumeFiles_l.

Referenced by fsc_VolumeCheck::GetNextOfsSubBlock().

                                                               {
    log_FUNC_m(GetNextBuff);
    if (    (m_currentFileIter) != m_volumeFiles_l.end()
       && (++m_currentFileIter) != m_volumeFiles_l.end()) {
        CloseF();
        log_DBG_m(dbg_LOW, "Open next MedVolOfsFile " << *m_currentFileIter );
        GetFSCdata(m_medVolPath + *m_currentFileIter);
    }
    else {
        m_buffPos = m_buffEnd = NULL;
    }
    a_begin_p = m_buffPos;
    a_end_p   = m_buffEnd;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void fsc_MedVolReader::ReadNextBlock (  )  [private]

Large volumes are split in many files by block offset, so open next one.

When no more files then buffPos = buffEnd = NULL

void fsc_MedVolReader::SortData (  )  [private]

Definition at line 337 of file fsc_MedVolume.cpp.

References fsc_medVolData_t::Compare(), dbg_DETAIL, fsc_medVolData_t::DumpHdr(), cmn_File::GetFullPathRef(), log_DBG_m, log_FUNC_m, fsc_MedVolume::m_buffCapacity, fsc_MedVolume::m_buffEnd, fsc_MedVolume::m_buffPos, and fsc_MedVolume::m_medVolDataBuf.

Referenced by GetFSCdata().

                                {
    log_FUNC_m(ReadAndSortData);

    m_buffPos  = m_medVolDataBuf;
    m_buffEnd  = m_medVolDataBuf + m_buffCapacity;
    log_DBG_m(dbg_DETAIL, GetFullPathRef() << " bufCap = " << m_buffCapacity
                          <<  " buff_p =" << hex << m_buffPos
                          <<  " buffEnd_p =" << hex << m_buffEnd << dec);

    log_DBG_m(dbg_DETAIL, "Split-Info before SORT");
    log_DBG_m(dbg_DETAIL, fsc_medVolData_t::DumpHdr());
    for (fsc_medVolData_t * p = m_medVolDataBuf;
         p != m_buffEnd;
         p++) {
         log_DBG_m(dbg_DETAIL,  p->Dump());
    }
    log_DBG_m(dbg_DETAIL, "Start QSort for file " << GetFullPathRef());
    // sort
    qsort(m_medVolDataBuf,
          m_buffCapacity,
          sizeof(fsc_medVolData_t),
          fsc_medVolData_t::Compare);

    log_DBG_m(dbg_DETAIL, "End QSort");
    log_DBG_m(dbg_DETAIL, fsc_medVolData_t::DumpHdr());
    for (fsc_medVolData_t * p = m_medVolDataBuf;
         p != m_buffEnd;
         p++) {
         log_DBG_m(dbg_DETAIL,  p->Dump());
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Reimplemented from fsc_MedVolume.

Definition at line 123 of file fsc_MedVolume.h.

list<string>::iterator fsc_MedVolReader::m_currentFileIter [private]

Definition at line 135 of file fsc_MedVolume.h.

Referenced by fsc_MedVolReader(), and GetNextBuff().

remove directory in destructor

Definition at line 130 of file fsc_MedVolume.h.

Referenced by ~fsc_MedVolReader().

path where this volume have its dataFiles

Definition at line 127 of file fsc_MedVolume.h.

Referenced by fsc_MedVolReader(), GetNextBuff(), and ~fsc_MedVolReader().

list<string> fsc_MedVolReader::m_volumeFiles_l [private]

all dataFile's names of this volume

Definition at line 133 of file fsc_MedVolume.h.

Referenced by fsc_MedVolReader(), and GetNextBuff().


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