]> git.treefish.org Git - phys/latlib.git/blob - o815/o815.h
05053871c1ca302e58625c46639b10e34d8fb4c0
[phys/latlib.git] / o815 / o815.h
1 #ifndef O815_H
2 #define O815_H
3
4 #include <string>
5 #include <vector>
6 #include <stdlib.h>
7 #include <getopt.h>
8
9 #include "latlib/paraq.h"
10 #include "latlib/writeout.h"
11 #include "latlib/hypercache.h"
12
13 using namespace std;
14
15 class obs;
16
17 class o815 {
18  public:
19
20   class obs {
21   public:
22     obs(const string& _obsid, const string& _datadesc, o815 *_O815, const int& _obsmemSize, const string& _obsidpostfix="");
23     void finish();
24     void meas(bool loadedobs, const int& nthmeas);
25     void start();
26     string getDataDesc() { return datadesc; };
27     int ocid;
28     string obsid;
29     string obsidpostfix;
30   private:
31     virtual void _meas(bool loadedobs, const int& nthmeas)=0;
32     virtual void _finish()=0;
33     virtual void _start()=0;
34   protected:
35     o815 *O815;
36     char *obsMem;
37     string simid, datadesc;
38     ostream *out, *log;
39     paraq* paraQ;
40   };
41
42   class sim {
43   public:
44     sim(o815 *_O815, const int& _confmemSize);
45     void nextConfig();
46     char *confMem;
47     virtual void _newParas()=0;
48     virtual void _resetConfig()=0;
49     int nequi, nskip;
50   private:
51     virtual void _makeSweep()=0;
52   protected:
53     o815 *O815;
54     ostream *log;
55     int confmemSize;
56   };
57
58   struct {
59     int nmeas;
60     int nskip;
61     int nequi;
62     int lsize[2];
63     pair<string,int> obscache;
64     pair<string,int> confcache;
65     string outdir;
66     int idonly;
67     int showjobnum;
68     string startconfig;
69   } comargs;
70
71   struct comoption {
72     string name;
73     int has_arg;
74     int *flag;
75     int val;
76     string optdesc;
77     string argdesc;
78   };
79
80   o815(int argc, char **argv, const string& _programid, comoption specOps[]=NULL, void (*helpHeader)()=NULL);
81   void postParaInit();
82   ~o815();
83   paraq *paraQ;
84   writeout *out;
85   vector<obs*> observables;
86   sim* Sim;
87   void mainLoop();
88   string headMaster( bool hashedrange=false );
89   void addPara(const string& paraid, const double& paraDefault);
90   void addComOption(const char* name, int has_arg, int *flag, int val, const char* optdesc, const char* argdesc);
91   vector< pair<int,char*> > parsedSpecOps;
92   vector<char*> lonelyArgs;
93
94 private:
95   vector<comoption> comOptions;
96   int numprocs, rank;
97   static void listArg(int *target, int tlen, char *listarg);
98   void parseArgs(int argc, char **argv, comoption specOps[]);
99   string programid;
100   int nextParas();
101   comoption* getOptionByVal(int val);
102   static void readCacheArgs(const string& arg, string& cachedir, int& cachemode);
103   unsigned long hash(const string& str);
104 };
105
106 #endif