Public Member Functions | Public Attributes | Private Attributes | Friends

fsc_nsDirEntryMgr Class Reference
[G_new_group]

class fsc_nsDirEntryMgr pass changes to fsc_nsDirEntryVec class. More...

#include <fsc_nsDirEntryMgr.h>

Collaboration diagram for fsc_nsDirEntryMgr:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 fsc_nsDirEntryMgr ()
 default constructor, owner of element is not known
 fsc_nsDirEntryMgr (ivd_VectorSize_t a_vectorSize, ivd_RecordIDX_t a_idx)
 If already exist some generation in DLC then fsc_nsDirEntryMgr is constructed from record from DB.
 ~fsc_nsDirEntryMgr (void)
void AddEntry (ivd_RecordIDX_t a_memFileID)
bool RemoveEntry (ivd_RecordIDX_t a_idxToRemove)
bool Write2DB (UInt8_t &a_elementType, UInt8_t &a_numOfElement, ivd_RecordIDX_t &a_recordIdx, fio_Transaction &a_trans)
void Dump (ostream &os)

Public Attributes

 log_CLASSID_m

Private Attributes

fsc_nsDirEntryVecm_dirMembers_p
fsc_nsDirEntryVec_p_v m_unusedDirEntVec

Friends

class ut_fsc_nsDirEntryMgr

Detailed Description

class fsc_nsDirEntryMgr pass changes to fsc_nsDirEntryVec class.

If first is full then new one is generatted. This new dirEntryMgr object take care of full vector, and first dirEntryMgr object is freed.

Definition at line 49 of file fsc_nsDirEntryMgr.h.


Constructor & Destructor Documentation

fsc_nsDirEntryMgr::fsc_nsDirEntryMgr (  ) 

default constructor, owner of element is not known

Definition at line 60 of file fsc_nsDirEntryMgr.cpp.

References log_FUNC_m.

fsc_nsDirEntryMgr::fsc_nsDirEntryMgr ( ivd_VectorSize_t  a_vectorSize,
ivd_RecordIDX_t  a_idx 
)

If already exist some generation in DLC then fsc_nsDirEntryMgr is constructed from record from DB.

Definition at line 50 of file fsc_nsDirEntryMgr.cpp.

References log_FUNC_m.

  : m_dirMembers_p(new fsc_nsDirEntryVec(a_vectorSize, a_idx)) {    
  
    log_FUNC_m(fsc_nsDirEntryMgr);
}

fsc_nsDirEntryMgr::~fsc_nsDirEntryMgr ( void   ) 

Definition at line 69 of file fsc_nsDirEntryMgr.cpp.

References log_FUNC_m, m_dirMembers_p, and NULL.


Member Function Documentation

void fsc_nsDirEntryMgr::AddEntry ( ivd_RecordIDX_t  a_memFileID  ) 

Definition at line 80 of file fsc_nsDirEntryMgr.cpp.

References fsc_nsDirEntryFormattedVec::AddEntry(), fio_Vector::GetVectorIndex(), ie_IMPOSSIBLE, fsc_nsDirEntryVec::Init(), log_FUNC_m, m_dirMembers_p, and m_unusedDirEntVec.

Referenced by fsc_nsDirectory::AddEntry(), and RemoveEntry().

                                                            {

    log_FUNC_m(AddEntry);
    if (a_memFileID == 0) {        
        throw ivd_InternalError(ie_IMPOSSIBLE,
            "Can't add element to directory entry list that has FileID = 0");
    }    
    if (!m_dirMembers_p->AddEntry(a_memFileID)) { 
        // can't add to vector it's full
        if (m_unusedDirEntVec.size()) {
            fsc_nsDirEntryVec* nextDirEntryVecPtr = m_dirMembers_p;
            ivd_RecordIDX_t idx = nextDirEntryVecPtr->GetVectorIndex();

            m_dirMembers_p = m_unusedDirEntVec.back();
            m_unusedDirEntVec.pop_back();
            m_dirMembers_p->Init(idx, nextDirEntryVecPtr);
        }
        else {
            m_dirMembers_p = new fsc_nsDirEntryVec(m_dirMembers_p->GetVectorIndex(),
                                                   m_dirMembers_p);        
            }        
            if (!m_dirMembers_p->AddEntry(a_memFileID)) {            
                throw ivd_InternalError(ie_IMPOSSIBLE,
                "Second refuse to add element to directory entry list.");
        }    
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void fsc_nsDirEntryMgr::Dump ( ostream &  os  ) 

Definition at line 188 of file fsc_nsDirEntryMgr.cpp.

References fsc_nsDirEntryVec::Dump(), and m_dirMembers_p.

Referenced by fsc_nsDirectory::Dump().

                                        {
    m_dirMembers_p->Dump(os);
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool fsc_nsDirEntryMgr::RemoveEntry ( ivd_RecordIDX_t  a_idxToRemove  ) 

Definition at line 111 of file fsc_nsDirEntryMgr.cpp.

References AddEntry(), fsc_nsDirEntryVec::Clear(), dbg_DETAIL, fsc_nsDirEntryVec::GetNextDirEntryVecPtr(), ie_IMPOSSIBLE, log_DBG_m, log_FUNC_m, log_MSG_m, log_WARNING, m_dirMembers_p, m_unusedDirEntVec, NULL, fsc_nsDirEntryFormattedVec::NumOfElements(), fsc_nsDirEntryVec::RemoveEntryFromNextVec(), and fsc_nsDirEntryFormattedVec::TryToRemoveEntry().

Referenced by fsc_nsDirectory::RemoveEntry().

                                                                 {    

    log_FUNC_m(RemoveEntry);    
    if (a_idxToRemove == 0) {        
        throw ivd_InternalError(ie_IMPOSSIBLE,
            "Can't remove element from directory entry list that has FileID = 0");
    }    
    // try to remove entry from first vector    
    // if not two possible scenario exist    
    // first vector has no more elements.    
    // tryToRemove method have to return a replacement fileID    
    // if replacement fileID is 0 then vector is empty.    
    
    ivd_RecordIDX_t idxToReplace;    
    if (!m_dirMembers_p->TryToRemoveEntry(a_idxToRemove, idxToReplace)) {        
        log_DBG_m(dbg_DETAIL,
        " element not found in first vector. idx to replace = "
        << idxToReplace);
        if (idxToReplace != 0) {
            // got one for replacement
            if (!m_dirMembers_p->RemoveEntryFromNextVec(a_idxToRemove, idxToReplace)) {
                // return index to replaced back in list
                AddEntry(idxToReplace);
                return false;
            }
        }
        else {
            ostringstream sstr;
            sstr << "The file " << a_idxToRemove
                << "is not a member of directory. It might never be inserted to this directory or was already removed.";
            log_MSG_m(log_WARNING, false, sstr.str());
            // The element is not in vector.
            // Therefore we can return true - it was removed already.
            return true;
        }
    }
    if (m_dirMembers_p->NumOfElements() == 0) {
        // check if first vector is empty
        fsc_nsDirEntryVec* nextDirEntryVecPtr = m_dirMembers_p->GetNextDirEntryVecPtr();
        if (nextDirEntryVecPtr == NULL) {
            // no more elements in directory
            return false;
        }
        m_dirMembers_p->Clear();
        m_unusedDirEntVec.push_back(m_dirMembers_p);
        m_dirMembers_p = nextDirEntryVecPtr;
    }
    return true;
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool fsc_nsDirEntryMgr::Write2DB ( UInt8_t a_elementType,
UInt8_t a_numOfElement,
ivd_RecordIDX_t a_recordIdx,
fio_Transaction a_trans 
)

Definition at line 164 of file fsc_nsDirEntryMgr.cpp.

References dbg_DETAIL, log_DBG_m, log_FUNC_m, m_dirMembers_p, m_unusedDirEntVec, NULL, and fsc_nsDirEntryVec::Write2DB().

Referenced by fsc_nsDirectory::Write2DB().

                                                           {    
    log_FUNC_m(Write2DB);
    a_elementType = mit_MEMBERS;    
    bool ret = m_dirMembers_p->Write2DB(a_numOfElement, a_recordIdx, a_trans);
    log_DBG_m(dbg_DETAIL, "Write members. vec size " << a_numOfElement
                        << " idx " << a_recordIdx
                        << " ret: " << boolalpha << ret);
    // free all unused vectors    
    fsc_nsDirEntryVec_p_v_i iter = m_unusedDirEntVec.begin();
    ivd_RecordIDX_t vecIdx; 
    // just to pass for free unused vector    
    for (; iter != m_unusedDirEntVec.end(); ++iter) {        
        ret = true;
        // upcasting to base fio_Vector class        
        static_cast<fio_Vector*>(*iter)->Write2DB(NULL, 0, vecIdx, a_trans);    
    }    
    m_unusedDirEntVec.clear();    
    return ret;
}

Here is the call graph for this function:

Here is the caller graph for this function:


Friends And Related Function Documentation

friend class ut_fsc_nsDirEntryMgr [friend]

Definition at line 50 of file fsc_nsDirEntryMgr.h.


Member Data Documentation

Definition at line 75 of file fsc_nsDirEntryMgr.h.

Definition at line 79 of file fsc_nsDirEntryMgr.h.

Referenced by AddEntry(), Dump(), RemoveEntry(), Write2DB(), and ~fsc_nsDirEntryMgr().

Definition at line 82 of file fsc_nsDirEntryMgr.h.

Referenced by AddEntry(), RemoveEntry(), and Write2DB().


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