X-Git-Url: http://git.treefish.org/~alex/phys/latlib.git/blobdiff_plain/b80a3fda9209144605a6306ba24ec2051d387f50..b13049b02df74e31a311cf41eb0c61f1898ce77e:/hypercache.h?ds=inline diff --git a/hypercache.h b/hypercache.h index f37bb0f..199b7e7 100644 --- a/hypercache.h +++ b/hypercache.h @@ -2,6 +2,7 @@ #define HYPERCACHE_H #include +#include #include "configcache.h" @@ -9,27 +10,44 @@ using namespace std; class hypercache { public: - static void initO(const string& cacheid, const int& nequi, const int& nskip, const string& datadir, - char **configmem, const int& configMemSize, const int& cachemode=CACHE_MODE_FULL, writeout *out_a=NULL) { - initCache(&O, cacheid, nequi, nskip, datadir, configmem, configMemSize, cachemode, out_a); + 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_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, writeout *out_a=NULL) { - initCache(&C, cacheid, nequi, nskip, datadir, configmem, configMemSize, cachemode, out_a); + 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]; } + + static int getNEquiLeft() { return nequileft; } static void addPara(const string& parid, const double& val=0); static void setPara(const string& parid, const double& value); - static bool readO(); + static void readO(int obsid, bool *readNewObsConfig, int *nequiObsLeft); static bool readC(); - static void writeO(); + static void writeO(int obsid); static void writeC(); - static void writeHeaderO(const string& headerid, char *header, long unsigned int size) { O->writeHeader(headerid, header, size); } - static void *getHeaderO(const string& headerid) { O->getHeader(headerid); } - static void writeHeaderC(const string& headerid, char *header, long unsigned int size) { C->writeHeader(headerid, header, size); } + 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); } static void finalize(); + + static int CFilesLeft() { return C->inFilesLeft(); } private: struct para{ @@ -39,21 +57,27 @@ 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, writeout *out_a=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 *O; static configcache *C; + static vector Os; static vector delayedParaAdd; static vector delayedParaSet; - static writeout *out; static string fileOfPath(const string& dressedfile); static string activeCFile; - static vector parentConfigs; - static void addParentConfig(const char* parentconfig); + static vector parentConfigs; + static void addParentConfig(const unsigned long *parentconfig); + static ostream* log; + + static int NEQUI; + static int NSKIP; + static int nequileft; + + static pair mostEquilibratedConfig; }; #endif