]> git.treefish.org Git - phys/latlib.git/blobdiff - hypercache.cpp
implemented partial virtual equilibration.
[phys/latlib.git] / hypercache.cpp
index 16de2a2dcc62db7b86a2bff5dcb000fc1703fdbe..2d38b2168b1ec70d162fdb1cb767da8dfad46a30 100644 (file)
@@ -5,7 +5,7 @@ configcache *hypercache::C = NULL;
 vector<hypercache::para> hypercache::delayedParaAdd;
 vector<hypercache::para> hypercache::delayedParaSet;
 string hypercache::activeCFile = "";
 vector<hypercache::para> hypercache::delayedParaAdd;
 vector<hypercache::para> hypercache::delayedParaSet;
 string hypercache::activeCFile = "";
-vector<string> hypercache::parentConfigs;
+vector<unsigned long> hypercache::parentConfigs;
 writeout *hypercache::out = NULL;
 
 void hypercache::initCache(configcache **cache,
 writeout *hypercache::out = NULL;
 
 void hypercache::initCache(configcache **cache,
@@ -71,10 +71,12 @@ string hypercache::fileOfPath(const string& dressedfile) {
   return dressedfile.substr(dressedfile.find_last_of("\\/")+1);
 }
 
   return dressedfile.substr(dressedfile.find_last_of("\\/")+1);
 }
 
-bool hypercache::readC() { 
-  bool readret;
+int hypercache::readC() { 
+  int readret;
 
 
-  if ( readret = C->readConfig(&parentConfigs) )
+  readret = C->readConfig(&parentConfigs);
+
+  if ( readret == -1 )
     activeCFile = fileOfPath(C->getInFileName());
   else
     activeCFile = "";
     activeCFile = fileOfPath(C->getInFileName());
   else
     activeCFile = "";
@@ -88,28 +90,32 @@ void hypercache::writeC() {
 }
 
 void hypercache::writeO() {
 }
 
 void hypercache::writeO() {
-  if ( activeCFile != "" )
-    O->writeHeader("concurrent_cfile", activeCFile.c_str(), (activeCFile.length()+1)*sizeof(char));
+  if ( activeCFile != "" ) {
+    unsigned long afilehash = configcache::hash(activeCFile);
+    O->writeHeader("concurrent_cfile", (char*)(&afilehash), sizeof(unsigned long));
+  }
 
   O->writeConfig(); 
 }
 
 
   O->writeConfig(); 
 }
 
-bool hypercache::readO() {
-  bool readret;
+int hypercache::readO() {
+  int readret;
+
+  readret = O->readConfig();
 
 
-  if ( readret = O->readConfig() ) {
-    char *parentconfig = (char*)O->getHeader("concurrent_cfile");
+  if ( readret == -1 ) {
+    unsigned long *parentconfig = (unsigned long*)O->getHeader("concurrent_cfile");
     if ( parentconfig != NULL )
       addParentConfig(parentconfig);
   }
     if ( parentconfig != NULL )
       addParentConfig(parentconfig);
   }
-
+  
   return readret;
 }
 
   return readret;
 }
 
-void hypercache::addParentConfig(const char* parentconfig) {
-  for (vector<string>::iterator parit = parentConfigs.begin(); parit != parentConfigs.end(); ++parit)
-    if ( *parit == parentconfig )
+void hypercache::addParentConfig(const unsigned long *parentconfig) {
+  for (vector<unsigned long>::iterator parit = parentConfigs.begin(); parit != parentConfigs.end(); ++parit)
+    if ( *parit == *parentconfig )
       return;
 
       return;
 
-  parentConfigs.push_back(parentconfig);
+  parentConfigs.push_back(*parentconfig);
 }
 }