X-Git-Url: http://git.treefish.org/~alex/phys/latlib.git/blobdiff_plain/3c0ea1a85b09df3bb85839ba92831fca9e10a82f..e34773ccb43eefc86dc814b768af85da2873e5ef:/hypercache.h diff --git a/hypercache.h b/hypercache.h index c5f548a..199b7e7 100644 --- a/hypercache.h +++ b/hypercache.h @@ -10,14 +10,24 @@ using namespace std; class hypercache { public: + struct observable{ + configcache *c; + int lastWrittenObsEquis; + }; + static int initO(const string& cacheid, const int& nequi, const int& nskip, const string& datadir, - char **configmem, const int& configMemSize, const int& cachemode=CACHE_MODE_FULL, ostream *_log=NULL) { - Os.push_back(NULL); - initCache(&Os.back(), cacheid, nequi, nskip, datadir, configmem, configMemSize, cachemode, _log); + char **configmem, const int& configMemSize, const int& cachemode=CACHE_MODE_RW, ostream *_log=NULL) { + observable newobs; + + newobs.c = NULL; + newobs.lastWrittenObsEquis = 0; + Os.push_back(newobs); + + initCache(&Os.back().c, cacheid, nequi, nskip, datadir, configmem, configMemSize, cachemode, _log); return Os.size()-1; } static void initC(const string& cacheid, const int& nequi, const int& nskip, const string& datadir, - char **configmem, const int& configMemSize, const int& cachemode=CACHE_MODE_FULL, ostream *_log=NULL) { + char **configmem, const int& configMemSize, const int& cachemode=CACHE_MODE_RW, ostream *_log=NULL) { initCache(&C, cacheid, nequi, nskip, datadir, configmem, configMemSize, cachemode, _log); mostEquilibratedConfig.second = new char[configMemSize]; } @@ -30,8 +40,8 @@ class hypercache { static bool readC(); static void writeO(int obsid); static void writeC(); - static void writeHeaderO(int obsid, const string& headerid, char *header, long unsigned int size, int actnequi) { Os[obsid]->writeHeader(headerid, header, size, actnequi); } - static void *getHeaderO(int obsid, const string& headerid) { Os[obsid]->getHeader(headerid); } + static void writeHeaderO(int obsid, const string& headerid, char *header, long unsigned int size, int actnequi) { Os[obsid].c->writeHeader(headerid, header, size, actnequi); } + static void *getHeaderO(int obsid, const string& headerid) { Os[obsid].c->getHeader(headerid); } static void writeHeaderC(const string& headerid, char *header, long unsigned int size, int actnequi) { C->writeHeader(headerid, header, size, actnequi); } static void *getHeaderC(const string& headerid) { C->getHeader(headerid); } @@ -47,13 +57,13 @@ class hypercache { static void initCache(configcache **cache, const string& cacheid, const int& nequi, const int& nskip, const string& datadir, - char **configmem, const int& configMemSize, const int& cachemode=CACHE_MODE_FULL, ostream* _log=NULL); + char **configmem, const int& configMemSize, const int& cachemode=CACHE_MODE_RW, ostream* _log=NULL); static void initCache( configcache **cache, - const string& cacheid, char **configmem, const int& configMemSize, const int& cachemode=CACHE_MODE_FULL); + const string& cacheid, char **configmem, const int& configMemSize, const int& cachemode=CACHE_MODE_RW); static configcache *C; - static vector Os; + static vector Os; static vector delayedParaAdd; static vector delayedParaSet; @@ -68,8 +78,6 @@ class hypercache { static int nequileft; static pair mostEquilibratedConfig; - - static int lastWrittenObsEquis; }; #endif