Export the Application Delta Profile (ADP) The current ADP for any application using the HadronZoo Database Suite (HDB), will be in the standard location "/home/deltasvr/appname/appname.adps".
| Return Type | Function name | Arguments |
|---|---|---|
| hzEcode | hdbADP::ExportADP | (void) |
Declared in file: hzDatabase.h
Defined in file : hdbADP.cpp
Function Logic:
Function body:
hzEcode hdbADP::ExportADP (void)
{
// Export the Application Delta Profile (ADP)
//
// The current ADP for any application using the HadronZoo Database Suite (HDB), will be in the standard location "/home/deltasvr/appname/appname.adps".
_hzfunc("hdbADP::Export") ;
hzMapS <uint32_t,const hdbClass*> classById ; // For ordering classes by ID
hzMapS <uint32_t,const hdbObjRepos*> reposById ; // For ordering classes by ID
ofstream os ; // Output stream
ifstream is ; // Input stream for previous ADP if applicable
hzChain Z ; // For building the ADP
hzChain Y ; // Previous ADP
const hdbEnum* pEnum ; // Data enum
const hdbClass* pClass ; // Data class
const hdbObjRepos* pRepos ; // Data object repository
hzString dsDir ; // Delta server directory
hzString fname ; // Filename
hzString bkfile ; // Filename
uint32_t nC ; // Data class iterator
hzEcode rc = E_OK ; // Return code
dsDir = "/home/deltasvr/" + m_appName ;
rc = AssertDir(dsDir, 0777);
if (rc != E_OK)
return hzerr(rc, "Could not assert delta dir [%s]\n", *dsDir) ;
fname = dsDir + "/" + m_appName + ".adp" ;
bkfile = dsDir + "/" + m_appName + ".bak" ;
threadLog("Exporting ADP to %s\n", *fname) ;
if (TestFile(*fname) == E_OK)
{
is.open(*fname) ;
Y << is ;
is.close() ;
}
Z.Printf("<AppDeltaProfile app=\"%s\">\n", *m_appName) ;
// List data enums
for (nC = 0; nC < m_mapEnums.Count() ; nC++)
{
pEnum = m_mapEnums.GetObj(nC) ;
Z.Printf("\t<enum name=\"%s\"/>\n", pEnum->txtType()) ;
}
// List data classes
for (nC = 0; nC < m_mapClasses.Count() ; nC++)
{
pClass = m_mapClasses.GetObj(nC) ;
classById.Insert(pClass->ClassId(), pClass) ;
}
for (nC = 0; nC < classById.Count() ; nC++)
{
pClass = classById.GetObj(nC) ;
pClass->DescClass(Z, 1);
}
// List data object repositories
for (nC = 0; nC < m_mapObjRepos.Count() ; nC++)
{
pRepos = m_mapObjRepos.GetObj(nC) ;
reposById.Insert(pRepos->DeltaId(), pRepos) ;
}
for (nC = 0; nC < reposById.Count() ; nC++)
{
pRepos = reposById.GetObj(nC) ;
pRepos->DescRepos(Z, 1);
}
Z << "</AppDeltaProfile>\n" ;
if (Y.Size())
{
if (Y == Z)
{ threadLog("ADP is an exact match\n") ; return E_OK ; }
threadLog("Backing up ADP\n") ;
Filecopy(*bkfile, *fname) ;
}
threadLog("Exporting current ADP\n") ;
os.open(*fname) ;
os << Z ;
os.close() ;
return rc ;
}