Open the data object repository, i.e. ready it for data operations. Depending on repository configuration, this action will do the following:- Open the binary repository for Whole Object Deltas. This is done in all cases. This action restores RAM Primacy components to the last known data state. Now deal with files if the working directory has been supplied. If a file of the cache's name exists in the working directory, this is assumed to be the data file and will be read in to populate the cache. The file must begin with a header which must match the class definition so this is checked before loading the remaining data. If a file of the cache's name does not exist in the working directory, it will be created and a header will be written. If a backup directory has been specified and a file of the cache's name exists in this directory, the header will be checked and assuming this is OK, the length of the file will aslo be checked (should match with that in the work directory) Arguments: None
| Return Type | Function name | Arguments |
|---|---|---|
| hzEcode | hdbObjRepos::Open | (void) |
Declared in file: hzDatabase.h
Defined in file : hdbObjRepos.cpp
Function Logic:
Function body:
hzEcode hdbObjRepos::Open (void)
{
// Open the data object repository, i.e. ready it for data operations. Depending on repository configuration, this action will do the following:-
//
// Open the binary repository for Whole Object Deltas. This is done in all cases.
// This action restores RAM Primacy components to the last known data state.
//
// Now deal with files if the working directory has been supplied. If a file of the cache's name exists in the working directory, this is assumed
// to be the data file and will be read in to populate the cache. The file must begin with a header which must match the class definition so this
// is checked before loading the remaining data. If a file of the cache's name does not exist in the working directory, it will be created and a
// header will be written.
//
// If a backup directory has been specified and a file of the cache's name exists in this directory, the header will be checked and assuming this
// is OK, the length of the file will aslo be checked (should match with that in the work directory)
//
// Arguments: None
_hzfunc("hdbObjRepos::Open") ;
hzEcode rc ; // Return code
if (!this)
Fatal("No instance") ;
_hdb_ck_initstate(m_Name, m_eReposInit, HDB_REPOS_INIT_DONE) ;
// if (!m_Workdir)
// return hzerr(E_NOINIT, "No workdir") ;
if (m_pBR_Datum)
{
// Only if native class has BINARY/TXTDOC members
rc = m_pBR_Datum->Open() ;
if (rc != E_OK)
return hzerr(E_NOINIT, "Could not open mbr datum binary repos") ;
}
if (m_pBR_Delta)
{
rc = m_pBR_Delta->Open() ;
if (rc != E_OK)
return hzerr(E_NOINIT, "Could not open delta binary repos") ;
rc = _loadCache() ;
threadLog("Whole Object Deltas loaded - Status %s\n", Err2Txt(rc)) ;
}
rc = _loadDeltas() ;
threadLog("Deltas loaded\n") ;
// Now open file for writing
if (rc == E_OK)
{
m_osDelta.open(*m_pathCD, ios::app) ;
if (m_osDelta.fail())
return hzerr(E_WRITEFAIL, "Class %s Cannot open data file %s in write mode", *m_Name, *m_pathCD) ;
m_eReposInit = HDB_REPOS_OPEN ;
}
threadLog("Population of objects in repos %s is %d. Delta file %s. Status %s\n", txtName(), Count(), *m_pathCD, Err2Txt(rc)) ;
// threadLog("Repos %s: Pop %d\n", *m_Name, Count()) ;
return rc ;
}