Fetch populates the supplied object recipticle (hdbObject instance) with the object identified by the supplied object id. The supplied recepticle is cleared by this function. If the supplied object id is invalid, the recepticle is left blank

Return TypeFunction nameArguments
hzEcodehdbObjRepos::Fetch(hdbObject&,uint32_t,)

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

Function Logic:

0:START 1:items 2:unknown 3:items 4:items 5:unknown 6:unknown 7:Return hzerr(E_NOTFOUND,Beyond Range %u\n,m_nSeqId) 8:rc 9:unknown 10:items 11:Return rc 12:rc 13:unknown 14:items 15:Return rc 16:rc 17:unknown 18:items 19:unknown 20:items 21:items items items 22:Return rc 23:rc 24:unknown 25:rc 26:Return rc

Function body:

hzEcode hdbObjRepos::Fetch (hdbObject& obj)uint32_t objId, 
{
   //  Fetch populates the supplied object recipticle (hdbObject instance) with the object identified by the supplied object id.
   //  
   //  The supplied recepticle is cleared by this function. If the supplied object id is invalid, the recepticle is left blank
   //  
   //  Arguments: 1) obj  The object
   //     2) objId The object id to fetch
   //  
   //  Returns: E_NOTFOUND The requested object does not exist or has been deleted
   //     E_OK  Operation success
   _hzfunc("hdbObjRepos::Fetch") ;
   hzChain     edo ;           //  EDO fetched from repos and passed to object
   hzChain     don ;           //  Object in HDON format (whole object delta)
   hzEcode     rc = E_OK ;     //  Return code
   //  Check init state and that supplied object is of the same class as the cache
   _hdb_ck_initstate(m_Name, m_eReposInit, HDB_REPOS_OPEN) ;
   //  Wrong data class?
   if (obj.Class() != m_pClass)
       hzexit(E_TYPE, "Repository %s is of class %s. Supplied object is of class %s", *m_Name, Classname(), obj.Classname()) ;
   //  Clear target object
   obj.Clear() ;
   //  Fetch data object
   if (m_eMode & HDB_REPOS_CACHE)
   {
       //  Object id out of range?
       if (objId > m_nSeqId)
           return hzerr(E_NOTFOUND, "Beyond Range %u\n", m_nSeqId) ;
       //  Fetch EDO
       //  rc = m_pMain->FetchEDO(edo, objId) ;
       rc = FetchEDO(edo, objId) ;
       if (rc != E_OK)
       {
           threadLog("FetchEDO failed\n") ;
           return rc ;
       }
       rc = obj.ImportEDO(edo) ;
       if (rc != E_OK)
       {
           threadLog("ImportEDO failed\n") ;
           return rc ;
       }
       rc = obj.Integrity() ;
       if (rc != E_OK)
       {
           hzChain     err ;       //  Error
           chIter      ei ;        //  EDO iterator
           err << "EDO is [ " ;
           for (ei = edo ; !ei.eof() ; ei++)
           {
               err.Printf("%02x ", (uchar) *ei) ;
           }
           err << "]\n" ;
           threadLog(err) ;
           threadLog("Integrity check failed err=%s\n", Err2Txt(rc)) ;
       }
       return rc ;
   }
   //  Fetch data object as whole object delta
   //  No cache so check dead index and if not dead, fetch message from m_pBR_Delta
   rc = m_pBR_Delta->Fetch(don, objId) ;
   if (rc == E_OK)
       rc = obj.ImportDelta(don) ;
   return rc ;
}