Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | Friends

fsc_nsDirEntryFormattedVec Class Reference
[G_new_group]

#include <fsc_nsDirEntryFormattedVec.h>

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

List of all members.

Public Member Functions

 fsc_nsDirEntryFormattedVec ()
 fsc_nsDirEntryFormattedVec (ivd_RecordIDX_t a_nextMemberIdx)
 fsc_nsDirEntryFormattedVec (UInt8_t a_vectorSize, ivd_RecordIDX_t a_idx)
 It creates nsDirEntryVec object filled with members got from DB on index a_idx.
void Init (ivd_RecordIDX_t a_nextMemberIdx)
bool AddEntry (ivd_RecordIDX_t a_memFileID)
 If vector has free space for index then inserts it and return true otherwice return false.
bool TryToRemoveEntry (ivd_RecordIDX_t a_idxToRemove, ivd_RecordIDX_t &a_idxToReplace)
 Try to remove entry from vector and return true.
bool RemoveEntry (ivd_RecordIDX_t a_idxToRemove, ivd_RecordIDX_t a_idxToReplace)
 If a_idxToRemove is in vector then replace it with a_idxToReplace and return true, otherwice return false.
bool Write2DB (UInt8_t &a_numOfElement, ivd_RecordIDX_t &a_recordIdx, fio_Transaction &a_trans)
 If vector is changed then write2DB method perform its actions.
ivd_RecordIDX_tGetFirstMemPtr ()
void GetNextMemPtr (ivd_RecordIDX_t *&a_mem_p)
unsigned int NumOfElements () const
void Dump (ostream &os)

Public Attributes

 log_CLASSID_m

Protected Member Functions

bool Write2DB (ivd_RecordIDX_t &a_recordIdx, fio_Transaction &a_trans)
 If vector is changed then write2DB method perform its actions.
void Clear ()

Protected Attributes

bool m_allFieldsAreSet
 set if all fields in array are set to 0 or full filled
ivd_RecordIDX_t m_dirMembers [fsc_nsMaxNumElemVecSize_d]
 formatted array to store directory member indeces (FileID)
ivd_RecordIDX_tm_firstFree_p
 pointer to first free element in array
ivd_RecordIDX_tm_nextVecIdx_p
 pointer to DB index of next vector

Friends

class ut_fsc_nsDirEntryFormattedVec

Detailed Description

Definition at line 84 of file fsc_nsDirEntryFormattedVec.h.


Constructor & Destructor Documentation

fsc_nsDirEntryFormattedVec::fsc_nsDirEntryFormattedVec (  ) 

Definition at line 60 of file fsc_nsDirEntryFormattedVec.cpp.

References log_FUNC_m, and m_nextVecIdx_p.

Referenced by fsc_nsDirEntryFormattedVec().

Here is the caller graph for this function:

fsc_nsDirEntryFormattedVec::fsc_nsDirEntryFormattedVec ( ivd_RecordIDX_t  a_nextMemberIdx  ) 

Definition at line 72 of file fsc_nsDirEntryFormattedVec.cpp.

References c_maxArraySize, fsc_nsDirEntryFormattedVec(), log_FUNC_m, m_dirMembers, and m_nextVecIdx_p.

  : fio_Vector(*g_nsDirEntryRF_p),    
    m_firstFree_p(m_dirMembers),
    m_nextVecIdx_p(&m_dirMembers[c_lastVecIdx]) {
    
    log_FUNC_m(fsc_nsDirEntryFormattedVec(nextMemIdx));
    // set all array to zero, because is bind with next.
    memset(m_dirMembers, 0, c_maxArraySize * sizeof(ivd_RecordIDX_t));    
    *m_nextVecIdx_p = a_nextMemberIdx; 
    // no next vector
}

Here is the call graph for this function:

fsc_nsDirEntryFormattedVec::fsc_nsDirEntryFormattedVec ( UInt8_t  a_vectorSize,
ivd_RecordIDX_t  a_idx 
)

It creates nsDirEntryVec object filled with members got from DB on index a_idx.

if a_idx is 0 no members are generatted.

Definition at line 87 of file fsc_nsDirEntryFormattedVec.cpp.

References c_dirEntryRecSize, c_maxRFVecSize, fsc_nsDirEntryFormattedVec(), log_FUNC_m, m_dirMembers, m_firstFree_p, m_nextVecIdx_p, fio_Vector::m_vectorSize, fio_Vector::ReadFromDB(), and size.

  : fio_Vector(*g_nsDirEntryRF_p,
               // if idx is not 0 and vector size is 0 then max vector exist
               (a_vectorSize == 0 && a_idx != 0) ? c_maxRFVecSize : a_vectorSize,
               a_idx,
               false),
    m_nextVecIdx_p(&m_dirMembers[c_lastVecIdx]) {    
    
    log_FUNC_m(fsc_nsDirEntryFormattedVec(size, idx));        
    //cout << " a_vector size = " << (int)a_vectorSize << endl        
    //    << " m_vectorSize = " << m_vectorSize << endl        
    //    << " idx = " << a_idx << endl;    
    if (a_idx > 0) {        
        ReadFromDB(m_dirMembers);        
        if (m_vectorSize == c_maxRFVecSize) { 
            // last element is index of next vector            
            // get it from vector and store it as member            
            ivd_RecordIDX_t *p = m_nextVecIdx_p - 2; 
            // two idx before last            
            //cout << " presizeIdx = " << c_preSizeIdx            
            //     << " presize val = " << m_dirMembers[c_preSizeIdx] << endl;            
            //cout << " size val = " << m_dirMembers[c_preSizeIdx + 1] << endl;            
            if (*p++ == 0) { 
                // befor last field contain idx of first free field                
                m_firstFree_p  = &m_dirMembers[*p];                            
            }            
            else if (*p == 0) { 
                // first free is one before last                
                m_firstFree_p  = p;            
            }            
            else { 
                // no free elements in vector                
                m_firstFree_p  = ++p;            
            }        
        }        
        else {            
            ivd_RecordIDX_t *r  = &m_dirMembers[a_vectorSize * c_dirEntryRecSize - 1];
            // check if exist free fields before, because of large record            
            while (!*r && r-- > m_dirMembers) {                
                // empty            
            }            
            m_firstFree_p   = ++r;            
            *m_nextVecIdx_p = 0; 
            //cout << " first free " << m_firstFree_p << "  array " << m_dirMembers << endl;
            // no next vector
        }    
    }    
    else {        
        m_firstFree_p   = m_dirMembers;
        *m_nextVecIdx_p = 0; 
        // no next vector    
    }
}

Here is the call graph for this function:


Member Function Documentation

bool fsc_nsDirEntryFormattedVec::AddEntry ( ivd_RecordIDX_t  a_memFileID  ) 

If vector has free space for index then inserts it and return true otherwice return false.

Definition at line 155 of file fsc_nsDirEntryFormattedVec.cpp.

References dbg_DETAIL, log_DBG_m, log_FUNC_m, fio_Vector::m_changed, m_firstFree_p, m_nextVecIdx_p, and NumOfElements().

Referenced by fsc_nsDirEntryMgr::AddEntry().

                                                                     {
    log_FUNC_m(AddEntry);

    if (m_firstFree_p != m_nextVecIdx_p) {        
        *m_firstFree_p++ = a_memFileID;         
        m_changed       = true;         
    log_DBG_m(dbg_DETAIL, "formatted vector obj " << this
                       << "Number of elements = " << NumOfElements());
        return true;    
    }    
    return false;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void fsc_nsDirEntryFormattedVec::Clear ( void   )  [protected]

pointer to index of next vector

Reimplemented in fsc_nsDirEntryVec.

Definition at line 232 of file fsc_nsDirEntryFormattedVec.cpp.

References log_FUNC_m, m_dirMembers, m_firstFree_p, and m_nextVecIdx_p.

                                       {
    log_FUNC_m(Clear);

    m_firstFree_p = m_dirMembers;
    *m_nextVecIdx_p = 0;
    // no next vector
}

void fsc_nsDirEntryFormattedVec::Dump ( ostream &  os  ) 

Reimplemented from fio_Vector.

Reimplemented in fsc_nsDirEntryVec.

Definition at line 312 of file fsc_nsDirEntryFormattedVec.cpp.

References fio_Vector::GetVectorSize(), m_dirMembers, m_firstFree_p, m_nextVecIdx_p, and fio_Vector::m_vectorIndex.

                                                 {
    ivd_RecordIDX_t *p = m_dirMembers;
    ivd_RecordIDX_t *e = m_firstFree_p;
    os << (e - p) << " members on vector idx = " << m_vectorIndex 
       << ", vector size: " << fio_Vector::GetVectorSize()
       << ", next vector idx: " << *m_nextVecIdx_p
       << endl;
    int memInLine = 8;
    while (p != e) {
        os << setw(10) << *p++;
        if(!--memInLine) {
            memInLine = 8;
            os << endl;
        }
    }    
    os << endl;
}

Here is the call graph for this function:

ivd_RecordIDX_t* fsc_nsDirEntryFormattedVec::GetFirstMemPtr (  )  [inline]

Definition at line 124 of file fsc_nsDirEntryFormattedVec.h.

References m_dirMembers, and m_firstFree_p.

Referenced by fsc_RawScan::DirTreeWalk().

                                      { 
        return m_firstFree_p > m_dirMembers
               ? &m_dirMembers[0]
               : NULL;
    };

Here is the caller graph for this function:

void fsc_nsDirEntryFormattedVec::GetNextMemPtr ( ivd_RecordIDX_t *&  a_mem_p  )  [inline]

Definition at line 130 of file fsc_nsDirEntryFormattedVec.h.

References m_firstFree_p.

Referenced by fsc_RawScan::DirTreeWalk().

                                                  { 
        if (++a_mem_p == m_firstFree_p) {
            a_mem_p = NULL;
        }
    };

Here is the caller graph for this function:

void fsc_nsDirEntryFormattedVec::Init ( ivd_RecordIDX_t  a_nextMemberIdx  ) 

Definition at line 145 of file fsc_nsDirEntryFormattedVec.cpp.

References log_FUNC_m, and m_nextVecIdx_p.

                                                                        {    
    log_FUNC_m(Init);    
    
    *m_nextVecIdx_p = a_nextMemberIdx; 
    // no next vector
}

unsigned int fsc_nsDirEntryFormattedVec::NumOfElements (  )  const [inline]

Definition at line 143 of file fsc_nsDirEntryFormattedVec.h.

References m_dirMembers, and m_firstFree_p.

Referenced by AddEntry(), fsc_nsDirEntryMgr::RemoveEntry(), TryToRemoveEntry(), and Write2DB().

{ return m_firstFree_p - m_dirMembers; };

Here is the caller graph for this function:

bool fsc_nsDirEntryFormattedVec::RemoveEntry ( ivd_RecordIDX_t  a_idxToRemove,
ivd_RecordIDX_t  a_idxToReplace 
)

If a_idxToRemove is in vector then replace it with a_idxToReplace and return true, otherwice return false.

Reimplemented in fsc_nsDirEntryVec.

Definition at line 212 of file fsc_nsDirEntryFormattedVec.cpp.

References dbg_DETAIL, log_DBG_m, log_FUNC_m, fio_Vector::m_changed, m_dirMembers, and m_firstFree_p.

Referenced by fsc_nsDirEntryVec::RemoveEntry().

                                                                             {    

    log_FUNC_m(RemoveEntry);
    log_DBG_m(dbg_DETAIL, "formatted vector obj " << this);
    ivd_RecordIDX_t *p = m_dirMembers;    
    ivd_RecordIDX_t *e = m_firstFree_p;    
    while (p != e) {        
        if (*p == a_idxToRemove) {            
            *p = a_idxToReplace;            
            m_changed = true;             
            return true;        
        }        
        ++p;    
    }    
    return false;
}

Here is the caller graph for this function:

bool fsc_nsDirEntryFormattedVec::TryToRemoveEntry ( ivd_RecordIDX_t  a_idxToRemove,
ivd_RecordIDX_t a_idxToReplace 
)

Try to remove entry from vector and return true.

If it's not found set a replacement and return false. If not even replacement found then return false.

Definition at line 171 of file fsc_nsDirEntryFormattedVec.cpp.

References dbg_DETAIL, log_DBG_m, log_FUNC_m, fio_Vector::m_changed, m_dirMembers, m_firstFree_p, and NumOfElements().

Referenced by fsc_nsDirEntryMgr::RemoveEntry().

                                                                                   {    
    
    log_FUNC_m(TryToRemoveEntry);    
    log_DBG_m(dbg_DETAIL, "a_idxToRemove: " << a_idxToRemove
                       << ", a_idxToReplace: " <<  a_idxToReplace
                       << " num of members: " << NumOfElements());
    if (m_firstFree_p == m_dirMembers) { 
        // no element to remove and to replace        
        a_idxToReplace = 0;        
        return false;     
    }    
    ivd_RecordIDX_t *e = --m_firstFree_p; 
    // last element will be removed or used as replacement    
    ivd_RecordIDX_t *p = m_dirMembers;    
    m_changed = true;     
    for (; p != e; ++p) {        
        log_DBG_m(dbg_DETAIL, "member: " << *p);
        if (*p == a_idxToRemove) {            
            *p = *e, *e = 0;
            return true;
        }
    }
    if (*p == a_idxToRemove) { 
        log_DBG_m(dbg_DETAIL, "last mem: " << *p);
        // last in vector match        
        *p = 0;        
        return true;    
    }
    else {
        log_DBG_m(dbg_DETAIL, "not found get last mem: " << *p);
        a_idxToReplace = *p;
        // set replacement
        *p = 0;
        return false;
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

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

If vector is changed then write2DB method perform its actions.

This method must be called only from fsc_nsDirEntryMgr

Reimplemented in fsc_nsDirEntryVec.

Definition at line 243 of file fsc_nsDirEntryFormattedVec.cpp.

References c_dirEntryRecSize, c_maxNumOfMember, c_maxRFVecSize, c_preSizeIdx, cmn_NumOfOctets(), dbg_DETAIL, log_DBG_m, log_FUNC_m, m_dirMembers, m_firstFree_p, m_nextVecIdx_p, NumOfElements(), and size.

Referenced by Write2DB().

                                                                    {    
    log_FUNC_m(Write2DB(numOfElement));
    log_DBG_m(dbg_DETAIL, "formatted vector obj " << this);
    
    ivd_VectorSize_t size = cmn_NumOfOctets(NumOfElements());
    if (*m_nextVecIdx_p) {
        size = c_maxRFVecSize;
    }
    if (size == c_maxRFVecSize) {
        log_DBG_m(dbg_DETAIL,
            "Number of elements = " << NumOfElements()
            << " inline calc of octets = " << size << " == " << c_maxRFVecSize);
        a_numOfElement = 0;
        // set size of vector in last array field for element
        // if field before is empty
        ivd_RecordIDX_t *beforeLast = m_nextVecIdx_p - 1; 
        // idx before last
        if (!*m_nextVecIdx_p) {
            // if array is not set to 0 set it now unset fields
            ivd_RecordIDX_t *p = m_firstFree_p;
            while (p < beforeLast) {
                *p++ = 0;
            }
        }
        
        unsigned int elements = NumOfElements();
        if (elements <= c_preSizeIdx) {
            // numbef of used elements is store in one before last filed
            *beforeLast = NumOfElements();
        }
        else if (elements < c_maxNumOfMember) {
            *beforeLast = 0;
        }
    }
    else {
        a_numOfElement = size;
        log_DBG_m(dbg_DETAIL,
            "Number of elements = " << NumOfElements()
            << " inline calc of octets = " << size);
        //cout << "Number of elements = " << NumOfElements()
        //                      << " inline calc of octets = " << size << endl;
        if (!size) { 
            // store at least one record
            size = a_numOfElement = 1;
        }
        // clear from firstFree_p up to record end if neccessary
        ivd_RecordIDX_t *e  = &m_dirMembers[size * c_dirEntryRecSize];
        ivd_RecordIDX_t *p  = m_firstFree_p;
        while (p < e) {
            *p++ = 0;
        }    
    }    
    return fio_Vector::Write2DB(m_dirMembers, size, a_recordIdx, a_trans);
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool fsc_nsDirEntryFormattedVec::Write2DB ( ivd_RecordIDX_t a_recordIdx,
fio_Transaction a_trans 
) [protected]

If vector is changed then write2DB method perform its actions.

This method must be called only from fsc_nsDirEntryVec

Reimplemented in fsc_nsDirEntryVec.

Definition at line 303 of file fsc_nsDirEntryFormattedVec.cpp.

References c_maxRFVecSize, log_FUNC_m, m_dirMembers, and Write2DB().

                                                                    {
    log_FUNC_m(Write2DB);
        
    return fio_Vector::Write2DB(m_dirMembers, c_maxRFVecSize, a_recordIdx, a_trans);
}

Here is the call graph for this function:


Friends And Related Function Documentation

friend class ut_fsc_nsDirEntryFormattedVec [friend]

Definition at line 85 of file fsc_nsDirEntryFormattedVec.h.


Member Data Documentation

Reimplemented from fio_Vector.

Reimplemented in fsc_nsDirEntryVec.

Definition at line 147 of file fsc_nsDirEntryFormattedVec.h.

set if all fields in array are set to 0 or full filled

Definition at line 151 of file fsc_nsDirEntryFormattedVec.h.

ivd_RecordIDX_t fsc_nsDirEntryFormattedVec::m_dirMembers[fsc_nsMaxNumElemVecSize_d] [protected]

formatted array to store directory member indeces (FileID)

Definition at line 155 of file fsc_nsDirEntryFormattedVec.h.

Referenced by Clear(), Dump(), fsc_nsDirEntryFormattedVec(), GetFirstMemPtr(), NumOfElements(), RemoveEntry(), TryToRemoveEntry(), and Write2DB().


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