]> git.treefish.org Git - phys/latlib.git/blob - configcache.h
...2
[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 using namespace std;
16
17 struct parameter{
18   string id;
19   double val;
20 };
21
22 class configcache{
23  public:
24   ~configcache();
25   configcache(const string& cacheid, const int& nequi, const int& nskip, const string& datadir, char **configmem, const int& configMemSize);
26   bool readConfig();
27   void writeConfig();
28   void addPara(const string& parid, const double& val=0);
29   void setPara(const string& parid, const double& value);
30   
31  private:
32   void finishOutFile();
33   int getParIndex(const string& parid);
34   int NEQUI;
35   int NSKIP;
36   string DATADIR;
37   string CACHEID;
38   string getFileId(const bool& shortid=false);
39
40   ofstream outFile;
41   ifstream inFile;
42
43   stringstream outFileName;
44
45   int readnum;
46
47   boost::iostreams::filtering_istreambuf *inBuffer;
48   boost::iostreams::filtering_ostreambuf *outBuffer;
49
50   int inSize;
51
52   int configSize;
53   char *configMem;
54   char *tmpConfig;
55
56   bool refetchDataFiles;
57
58   void fetchDataFiles();
59   
60   bool isValidInFile(const string& infile);
61
62   vector<string> inFiles;
63
64   vector<parameter> Paras;
65 };
66
67 #endif