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 TypeFunction nameArguments
hzEcodehdbADP::ExportADP(void)

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

Function Logic:

0:START 1:/home/deltasvr/ dsDir rc 2:unknown 3:Return hzerr(rc,Could not assert delta dir [%s]\n,*dsDir) 4:m_appName 5:/ 6:dsDir 7:fname m_appName / dsDir bkfile items 8:unknown 9:items items items 10:items 11:unknown 12:pEnum items 13:unknown 14:pClass items 15:unknown 16:pClass items 17:unknown 18:pRepos items 19:unknown 20:pRepos items 21:items 22:unknown 23:unknown 24:items 25:Return E_OK 26:items items 27:items items items items 28:Return rc

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 ;
}