]> git.treefish.org Git - phys/latlib.git/blob - configcache.h
wrong variances\!
[phys/latlib.git] / configcache.h
1 #ifndef CONFIGCACHE_H
2 #define CONFIGCACHE_H
3
4 #include <vector>
5 #include <string>
6 #include <fstream>
7 #include <sstream>
8
9 #include <boost/iostreams/filtering_streambuf.hpp>
10 #include <boost/iostreams/stream.hpp>
11 #include <boost/iostreams/filter/bzip2.hpp>
12 #include <boost/iostreams/device/array.hpp>
13 #include <boost/iostreams/copy.hpp>
14
15 #define CACHE_MODE_DISABLED 0
16 #define CACHE_MODE_READ 1
17 #define CACHE_MODE_FULL 2
18
19 using namespace std;
20
21 struct parameter{
22   string id;
23   double val;
24 };
25
26 class configcache{
27  public:
28   ~configcache();
29   configcache(const string& cacheid, const int& nequi, const int& nskip, const string& datadir, char **configmem, const int& configMemSize, const int& cachemode=CACHE_MODE_FULL);
30   bool readConfig();
31   void writeConfig();
32   void addPara(const string& parid, const double& val=0);
33   void setPara(const string& parid, const double& value);
34   
35  private:
36   void finishOutFile();
37   int getParIndex(const string& parid);
38   int NEQUI;
39   int NSKIP;
40   string DATADIR;
41   string CACHEID;
42   int MODE;
43   string getFileId(const bool& shortid=false);
44
45   ofstream outFile;
46   ifstream inFile;
47
48   stringstream outFileName;
49
50   int readnum;
51
52   boost::iostreams::filtering_istreambuf *inBuffer;
53   boost::iostreams::filtering_ostreambuf *outBuffer;
54
55   int inSize;
56
57   int configSize;
58   char *configMem;
59   char *tmpConfig;
60
61   bool refetchDataFiles;
62
63   void fetchDataFiles();
64   
65   bool isValidInFile(const string& infile);
66
67   vector<string> inFiles;
68
69   vector<parameter> Paras;
70 };
71
72 #endif