fsc_nsDirEntryMgr Class Reference
[G_new_group]

#include <fsc_nsDirEntryMgr.h>

Collaboration diagram for fsc_nsDirEntryMgr:

Collaboration graph
[legend]

List of all members.


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 35 of file fsc_nsDirEntryMgr.h.


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

Constructor & Destructor Documentation

fsc_nsDirEntryMgr::fsc_nsDirEntryMgr (  ) 

default constructor, owner of element is not known

Definition at line 46 of file fsc_nsDirEntryMgr.cpp.

References log_FUNC_m.

00047   : m_dirMembers_p(new fsc_nsDirEntryVec()) {    
00048     
00049     log_FUNC_m(fsc_nsDirEntryMgr);
00050 }

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 36 of file fsc_nsDirEntryMgr.cpp.

References log_FUNC_m.

00038   : m_dirMembers_p(new fsc_nsDirEntryVec(a_vectorSize, a_idx)) {    
00039   
00040     log_FUNC_m(fsc_nsDirEntryMgr);
00041 }

fsc_nsDirEntryMgr::~fsc_nsDirEntryMgr ( void   ) 

Definition at line 55 of file fsc_nsDirEntryMgr.cpp.

References log_FUNC_m, m_dirMembers_p, and NULL.

00055                                           {    
00056 
00057     log_FUNC_m(~fsc_nsDirEntryMgr);    
00058     if (m_dirMembers_p != NULL) {        
00059         delete m_dirMembers_p;    
00060     }
00061 }


Member Function Documentation

void fsc_nsDirEntryMgr::AddEntry ( ivd_RecordIDX_t  a_memFileID  ) 

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

00066                                                             {
00067 
00068     log_FUNC_m(AddEntry);
00069     if (a_memFileID == 0) {        
00070         throw ivd_InternalError(ie_IMPOSSIBLE,
00071             "Can't add element to directory entry list that has FileID = 0");
00072     }    
00073     if (!m_dirMembers_p->AddEntry(a_memFileID)) { 
00074         // can't add to vector it's full
00075         if (m_unusedDirEntVec.size()) {
00076             fsc_nsDirEntryVec* nextDirEntryVecPtr = m_dirMembers_p;
00077             ivd_RecordIDX_t idx = nextDirEntryVecPtr->GetVectorIndex();
00078 
00079             m_dirMembers_p = m_unusedDirEntVec.back();
00080             m_unusedDirEntVec.pop_back();
00081             m_dirMembers_p->Init(idx, nextDirEntryVecPtr);
00082         }
00083         else {
00084             m_dirMembers_p = new fsc_nsDirEntryVec(m_dirMembers_p->GetVectorIndex(),
00085                                                    m_dirMembers_p);        
00086             }        
00087             if (!m_dirMembers_p->AddEntry(a_memFileID)) {            
00088                 throw ivd_InternalError(ie_IMPOSSIBLE,
00089                 "Second refuse to add element to directory entry list.");
00090         }    
00091     }
00092 }

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

00097                                                                  {    
00098 
00099     log_FUNC_m(RemoveEntry);    
00100     if (a_idxToRemove == 0) {        
00101         throw ivd_InternalError(ie_IMPOSSIBLE,
00102             "Can't remove element from directory entry list that has FileID = 0");
00103     }    
00104     // try to remove entry from first vector    
00105     // if not two possible scenario exist    
00106     // first vector has no more elements.    
00107     // tryToRemove method have to return a replacement fileID    
00108     // if replacement fileID is 0 then vector is empty.    
00109     
00110     ivd_RecordIDX_t idxToReplace;    
00111     if (!m_dirMembers_p->TryToRemoveEntry(a_idxToRemove, idxToReplace)) {        
00112         log_DBG_m(dbg_DETAIL,
00113         " element not found in first vector. idx to replace = "
00114         << idxToReplace);
00115         if (idxToReplace != 0) {
00116             // got one for replacement
00117             if (!m_dirMembers_p->RemoveEntryFromNextVec(a_idxToRemove, idxToReplace)) {
00118                 // return index to replaced back in list
00119                 AddEntry(idxToReplace);
00120                 return false;
00121             }
00122         }
00123         else {
00124             ostringstream sstr;
00125             sstr << "The file " << a_idxToRemove
00126                 << "is not a member of directory. It might never be inserted to this directory or was already removed.";
00127             log_MSG_m(log_WARNING, false, sstr.str());
00128             // The element is not in vector.
00129             // Therefore we can return true - it was removed already.
00130             return true;
00131         }
00132     }
00133     if (m_dirMembers_p->NumOfElements() == 0) {
00134         // check if first vector is empty
00135         fsc_nsDirEntryVec* nextDirEntryVecPtr = m_dirMembers_p->GetNextDirEntryVecPtr();
00136         if (nextDirEntryVecPtr == NULL) {
00137             // no more elements in directory
00138             return false;
00139         }
00140         m_dirMembers_p->Clear();
00141         m_unusedDirEntVec.push_back(m_dirMembers_p);
00142         m_dirMembers_p = nextDirEntryVecPtr;
00143     }
00144     return true;
00145 }

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 150 of file fsc_nsDirEntryMgr.cpp.

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

Referenced by fsc_nsDirectory::Write2DB().

00153                                                            {    
00154     log_FUNC_m(Write2DB);
00155     a_elementType = mit_MEMBERS;    
00156     bool ret = m_dirMembers_p->Write2DB(a_numOfElement, a_recordIdx, a_trans);
00157     log_DBG_m(dbg_DETAIL, "Write members. vec size " << a_numOfElement
00158                         << " idx " << a_recordIdx
00159                         << " ret: " << boolalpha << ret);
00160     // free all unused vectors    
00161     fsc_nsDirEntryVec_p_v_i iter = m_unusedDirEntVec.begin();
00162     ivd_RecordIDX_t vecIdx; 
00163     // just to pass for free unused vector    
00164     for (; iter != m_unusedDirEntVec.end(); ++iter) {        
00165         ret = true;
00166         // upcasting to base fio_Vector class        
00167         static_cast<fio_Vector*>(*iter)->Write2DB(NULL, 0, vecIdx, a_trans);    
00168     }    
00169     m_unusedDirEntVec.clear();    
00170     return ret;
00171 }

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 174 of file fsc_nsDirEntryMgr.cpp.

References fsc_nsDirEntryVec::Dump(), and m_dirMembers_p.

Referenced by fsc_nsDirectory::Dump().

00174                                         {
00175     m_dirMembers_p->Dump(os);
00176 }

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 36 of file fsc_nsDirEntryMgr.h.


Member Data Documentation

Definition at line 61 of file fsc_nsDirEntryMgr.h.

Definition at line 65 of file fsc_nsDirEntryMgr.h.

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

Definition at line 68 of file fsc_nsDirEntryMgr.h.

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


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

Generated on Mon Feb 27 19:22:31 2012 for OPENARCHIVE by  doxygen 1.5.6