X-Git-Url: http://git.treefish.org/~alex/phys/latlib.git/blobdiff_plain/fbbe6f07bc8720030541b7319acb02c9233cd622..7a385d92335a4707d5b0aae66e4850d137c1fe7d:/hypercache.h?ds=inline diff --git a/hypercache.h b/hypercache.h index 53e0f67..a30e28e 100644 --- a/hypercache.h +++ b/hypercache.h @@ -2,6 +2,7 @@ #define HYPERCACHE_H #include +#include #include "configcache.h" @@ -9,57 +10,56 @@ 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+"/o", configmem, configMemSize, cachemode, out_a); + 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); + 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+"/c", configmem, configMemSize, cachemode, out_a); - } - - static void initO(const string& cacheid, char **configmem, const int& configMemSize, const int& cachemode=CACHE_MODE_FULL) { - initCache(O, "o", cacheid, configmem, configMemSize, cachemode); - } - static void initC(const string& cacheid, char **configmem, const int& configMemSize, const int& cachemode=CACHE_MODE_FULL) { - initCache(C, "c", cacheid, configmem, configMemSize, cachemode); + char **configmem, const int& configMemSize, const int& cachemode=CACHE_MODE_FULL, ostream *_log=NULL) { + initCache(&C, cacheid, nequi, nskip, datadir, configmem, configMemSize, cachemode, _log); } static void addPara(const string& parid, const double& val=0); static void setPara(const string& parid, const double& value); - static bool readO() { return O->readConfig(); } - static bool readC() { return C->readConfig(); } - static void writeO() { O->writeConfig(); } - static void writeC() { C->writeConfig(); } - 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 int readO(int obsid); + static int readC(); + static void writeO(int obsid); + static void writeC(); + static void writeHeaderO(int obsid, const string& headerid, char *header, long unsigned int size) { Os[obsid]->writeHeader(headerid, header, size); } + static void *getHeaderO(int obsid, const string& headerid) { Os[obsid]->getHeader(headerid); } static void writeHeaderC(const string& headerid, char *header, long unsigned int size) { C->writeHeader(headerid, header, size); } static void *getHeaderC(const string& headerid) { C->getHeader(headerid); } + + static void finalize(); + + static int read1CForEqui(); + static int CFilesLeft() { return C->inFilesLeft(); } private: - struct defaults{ - int nequi; - int nskip; - string datadir; - writeout *out; - }; struct para{ string parid; double val; }; - static void initCache(configcache *cache, + 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_FULL, ostream* _log=NULL); - static void initCache( configcache *cache, const string& subdir, + static void initCache( configcache **cache, const string& cacheid, char **configmem, const int& configMemSize, const int& cachemode=CACHE_MODE_FULL); - - static configcache *O; + static configcache *C; - static defaults *Defaults; + static vector Os; static vector delayedParaAdd; static vector delayedParaSet; + + static string fileOfPath(const string& dressedfile); + static string activeCFile; + static vector parentConfigs; + static void addParentConfig(const unsigned long *parentconfig); + static ostream* log; }; #endif