Replace the datum identified by the supplied id (arg1), with the contents of the supplied hzChain (arg2). In all cases this action is a DEPRECATE of the existing datum, and an INSERT of the new.

Return TypeFunction nameArguments
hzEcodehdbBinRepos::Update(uint32_t&,hzChain&,)

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

Function Logic:

0:START 1:unknown 2:Return E_NOINIT 3:unknown 4:Return E_NOTOPEN 5:unknown 6:Return E_NOTOPEN 7:unknown 8:Return E_NOTFOUND 9:unknown 10:Return E_NODATA 11:items hdr hdr items hdr datumId m_nSize items 12:unknown 13:items rc 14:items items 15:unknown 16:items 17:unknown 18:items rc 19:items 20:unknown 21:items items 22:Return rc

Function body:

hzEcode hdbBinRepos::Update (uint32_t& datumId)hzChain& datum, 
{
   //  Replace the datum identified by the supplied id (arg1), with the contents of the supplied hzChain (arg2). In all cases this action is a DEPRECATE of the existing datum, and
   //  an INSERT of the new.
   //  
   //  Arguments: 1) datumId Datum ID - Set in the call to the original datum, set by this function to the new datum id
   //     2) datum The datum
   //  
   //  Returns: E_NOINIT The datacron is not initialized
   //     E_NOTOPEN Attempt to modify object zero
   //     E_NOTFOUND Attempt to modify non existant object
   //     E_WRITEFAIL The datacron is not open for writing
   //     E_RANGE  The requested item does not exist
   //     E_OK  The operation was successful
   _hzfunc("hdbBinRepos::Update") ;
   _datum_hd   hdr ;           //  Datum header
   hzEcode     rc = E_OK ;     //  Return code
   //  Repos not initialized?
   if (m_nInitState < 1)
       return E_NOINIT ;
   //  Repos not open?
   if (m_nInitState < 2)
       return E_NOTOPEN ;
   //  No datum id supplied?
   if (datumId == 0)
       return E_NOTOPEN ;
   //  Datum id out of range
   if (datumId > m_nSeqId)
       return E_NOTFOUND ;
   //  Empty datum?
   if (!datum.Size())
       return E_NODATA ;
   hdr.m_XDate.SysDateTime() ;
   hdr.m_Size = datum.Size() ;
   hdr.m_Prev = datumId ;
   //  rem = ((16 - datum.Size()) % 16) % 16 ;
   //  tot = datum.Size() + rem ;
   //  Write to the index
   m_LockIwr.Lock() ;
       hdr.m_Addr = m_nSize ;
       datumId = ++m_nSeqId ;
       m_nSize += datum.Size() ;
       m_WrI.write((char*) &hdr, sizeof(_datum_hd)) ;
       //  Internal write error?
       if (m_WrI.fail())
           { threadLog("Could not update index delta for datum %d\n", datumId) ; rc = E_WRITEFAIL ; }
   m_LockIwr.Unlock() ;
   m_LockDwr.Lock() ;
       //  No errors?
       if (rc == E_OK)
       {
           //  Write to the data file
           m_WrD << datum ;
           //  Internal write error?
           if (m_WrD.fail())
               { threadLog("Could not update data file for datum %d\n", datumId) ; rc = E_WRITEFAIL ; }
       }
   m_LockDwr.Unlock() ;
   //  No errors?
   if (rc == E_OK)
   {
       //  Flush index and data files
       m_WrI.flush() ;
       m_WrD.flush() ;
   }
   return rc ;
}