1 #include "hypercache.h"
3 configcache *hypercache::O = NULL;
4 configcache *hypercache::C = NULL;
5 vector<hypercache::para> hypercache::delayedParaAdd;
6 vector<hypercache::para> hypercache::delayedParaSet;
8 void hypercache::initCache(configcache **cache,
9 const string& cacheid, const int& nequi, const int& nskip, const string& datadir,
10 char **configmem, const int& configMemSize, const int& cachemode, writeout *out_a) {
12 bool allInitBefore = true;
14 if (O == NULL || C == NULL)
15 allInitBefore = false;
17 *cache = new configcache(cacheid, nequi, nskip, datadir, configmem, configMemSize, cachemode, out_a);
19 if (O != NULL && C != NULL && !allInitBefore) {
20 for (vector<para>::iterator parit=delayedParaAdd.begin(); parit != delayedParaAdd.end(); ++parit) {
21 O->addPara(parit->parid, parit->val);
22 C->addPara(parit->parid, parit->val);
24 for (vector<para>::iterator parit=delayedParaSet.begin(); parit != delayedParaSet.end(); ++parit) {
25 O->setPara(parit->parid, parit->val);
26 C->setPara(parit->parid, parit->val);
31 void hypercache::addPara(const string& parid, const double& val) {
32 if (O == NULL || C == NULL) {
34 newpara.parid = parid;
36 delayedParaAdd.push_back(newpara);
39 O->addPara(parid, val);
40 C->addPara(parid, val);
44 void hypercache::setPara(const string& parid, const double& val) {
45 if (O == NULL || C == NULL) {
47 newpara.parid = parid;
49 delayedParaSet.push_back(newpara);
52 O->setPara(parid, val);
53 C->setPara(parid, val);
57 void hypercache::finalize() {