Complete the initialization sequence. This is a mainly a matter of calculating how member space within hdbObject will be arranged. Members are assigned space that depends on the datatype and max population, and they are given relative positions that ensure the correct byte alignment. To this end the members are first sorted by datum size ... Arguments: None

Return TypeFunction nameArguments
hzEcodehdbClass::InitDone(void)

Declared in file: hzDatabase.h
Defined in file : hdbClass.cpp

Function Logic:

0:START 1:unknown 2:Return hzerr(E_SEQUENCE,Called out of sequence (must be after InitStart() and at least one call to InitMember()) 3:nSofar 4:unknown 5:pMbr 6:unknown 7:unknown 8:items nSofar 9:unknown 10:pMbr 11:unknown 12:unknown 13:items nSofar 14:unknown 15:items nSofar 16:unknown 17:pMbr 18:unknown 19:items nSofar 20:unknown 21:unknown 22:items nSofar 23:unknown 24:pMbr 25:unknown 26:unknown 27:items nSofar 28:unknown 29:pMbr 30:unknown 31:items nSofar 32:unknown 33:pMbr 34:unknown 35:unknown 36:items 37:m_nLitmusBits m_nLitmusBits m_nLitmusSize 38:unknown 39:items 40:m_nCoreLen 41:unknown 42:pMbr items 43:items m_eClassInit 44:Return E_OK

Function body:

hzEcode hdbClass::InitDone (void)
{
   //  Complete the initialization sequence.
   //  
   //  This is a mainly a matter of calculating how member space within hdbObject will be arranged. Members are assigned space that depends on the datatype and max population, and
   //  they are given relative positions that ensure the correct byte alignment. To this end the members are first sorted by datum size ...
   //  
   //  Arguments: None
   //  
   //  Returns: E_SEQUENCE If this function is not called after a successful InitStart() and InitMember()
   //     E_OK  If this function terminates an open initialization sequence
   _hzfunc("hdbClass::InitDone") ;
   const hdbMember*    pMbr ;      //  Member pointer
   uint32_t            mbrNo ;     //  Member number
   uint32_t            nSofar ;    //  For adding up total core space needed by all members
   //  Check init sequence
   if (m_eClassInit != HDB_CLASS_INIT_PROG)
       return hzerr(E_SEQUENCE, "Called out of sequence (must be after InitStart() and at least one call to InitMember()") ;
   //  Allocate member space within hdbObject core. Start with 16-byte entities if any, then 8, then 4. Leave ENUM till last as a special case.
   nSofar = 0;
   //  m_nNonBool = 0 ;
   //  Allocate 16-byte slots
   for (mbrNo = 0; mbrNo < m_arrMembers.Count() ; mbrNo++)
   {
       pMbr = m_arrMembers[mbrNo] ;
       if (pMbr->Basetype() == BASETYPE_ENUM)
           continue ;
       if (pMbr->SizeCore() < 16)
           continue ;
       pMbr->_setOset(nSofar) ;
       nSofar += 16;
   }
   //  Allocate 8-byte slots, including the aux slot for BINARY/TXTDOC members
   for (mbrNo = 0; mbrNo < m_arrMembers.Count() ; mbrNo++)
   {
       pMbr = m_arrMembers[mbrNo] ;
       if (pMbr->Basetype() == BASETYPE_ENUM)
           continue ;
       if (pMbr->Basetype() == BASETYPE_BINARY || pMbr->Basetype() == BASETYPE_TXTDOC)
       {
           pMbr->_setAux(nSofar) ;
           nSofar += 8;
           continue ;
       }
       if (pMbr->SizeCore() != 8)
           continue ;
       pMbr->_setOset(nSofar) ;
       nSofar += 8;
   }
   //  Allocate 4-byte slots
   for (mbrNo = 0; mbrNo < m_arrMembers.Count() ; mbrNo++)
   {
       pMbr = m_arrMembers[mbrNo] ;
       if (pMbr->Basetype() == BASETYPE_BINARY || pMbr->Basetype() == BASETYPE_TXTDOC)
       {
           //  Allocate space for binary datum id
           pMbr->_setOset(nSofar) ;
           nSofar += 4;
           continue ;
       }
       if (pMbr->Basetype() == BASETYPE_ENUM)
           continue ;
       if (pMbr->SizeCore() != 4)
           continue ;
       pMbr->_setOset(nSofar) ;
       nSofar += 4;
   }
   //  2-byte allocations
   for (mbrNo = 0; mbrNo < m_arrMembers.Count() ; mbrNo++)
   {
       pMbr = m_arrMembers[mbrNo] ;
       if (pMbr->Basetype() == BASETYPE_ENUM)
           continue ;
       if (pMbr->SizeCore() != 2)
           continue ;
       pMbr->_setOset(nSofar) ;
       nSofar += 2;
   }
   //  Enums
   for (mbrNo = 0; mbrNo < m_arrMembers.Count() ; mbrNo++)
   {
       pMbr = m_arrMembers[mbrNo] ;
       if (pMbr->Basetype() != BASETYPE_ENUM)
           continue ;
       pMbr->_setOset(nSofar) ;
       nSofar += pMbr->SizeCore() ;
   }
   //  Bools
   for (mbrNo = 0; mbrNo < m_arrMembers.Count() ; mbrNo++)
   {
       pMbr = m_arrMembers[mbrNo] ;
       if (pMbr->Basetype() == BASETYPE_BOOL)
           continue ;
       if (pMbr->Basetype() == BASETYPE_TBOOL)
       {
           //  pMbr->_setOset(nSofar) ;
           //  nSofar += 1 ;
           m_nLitmusBits++ ;
           continue ;
       }
       //  m_nNonBool++ ;
   }
   //  Core len is total core size 
   m_nLitmusBits += m_arrMembers.Count() ;
   m_nLitmusSize = m_nLitmusBits/8;
   if (m_nLitmusBits%8)
       m_nLitmusSize++ ;
   m_nCoreLen = nSofar ;
   //  Report class form
   for (mbrNo = 0; mbrNo < m_arrMembers.Count() ; mbrNo++)
   {
       pMbr = m_arrMembers[mbrNo] ;
       threadLog("Mbr %u %s: Posn %u Datum %u Core %u oset %d aux %d\n", mbrNo, pMbr->txtName(), pMbr->Posn(), pMbr->SizeDatum(), pMbr->SizeCore(), pMbr->OsetStd(), pMbr->OsetAux()) ;
   }
   threadLog("Class %s complete, core len %u\n", txtName(), m_nCoreLen) ;
   //  Move to Register Class
   //  hzChain desc ;
   //  DescClass(desc, 0) ;
   //  m_Desc = desc ;
   //  Indicate that class init is complete
   m_eClassInit = HDB_CLASS_INIT_DONE ;
   return E_OK ;
}