| Return Type | Function name | Arguments |
|---|---|---|
| hzEcode | hdbBinRepos::Insert | (unsigned int&,const hzChain&,) |
Declared in file: hzDatabase.h
Defined in file : hdbBinRepos.cpp
Function Logic:
Function body:
hzEcode hdbBinRepos::Insert (unsigned int& datumId, const hzChain& datum)
{
_hzfunc("hdbBinRepos::Insert") ;
_datum_hd hdr ;
hzEcode rc = E_OK ;
if (m_nInitState < 1) return E_NOINIT ;
if (m_nInitState < 2) return E_NOTOPEN ;
datumId = 0;
if (!datum.Size())
return E_NODATA ;
hdr.m_DTStamp.SysDateTime() ;
hdr.m_Size = datum.Size() ;
hdr.m_Prev = 0;
m_LockIwr.Lock() ;
hdr.m_Addr = m_nSize ;
datumId = ++m_nSeqId ;
m_nPopulation++ ;
m_nSize += datum.Size() ;
m_WrI.write((char*) &hdr, sizeof(_datum_hd)) ;
if (m_WrI.fail())
{ m_Error.Printf("Could not update index delta for datum %d\n", datumId) ; rc = E_WRITEFAIL ; }
m_LockIwr.Unlock() ;
m_LockDwr.Lock() ;
if (rc == E_OK)
{
m_WrD << datum ;
if (m_WrD.fail())
{ m_Error.Printf("Could not update data file for datum %d\n", datumId) ; rc = E_WRITEFAIL ; }
}
m_LockDwr.Unlock() ;
if (rc == E_OK)
{
m_WrI.flush() ;
m_WrD.flush() ;
}
return rc ;
}