C++ main module for gpm Package  1.0
GPM_ExamplesRun.h
Go to the documentation of this file.
1 #ifndef GPM_ExamplesRun_H
2 #define GPM_ExamplesRun_H
3 
4 #include "CORE_Object.h"
5 #include "CORE_String.h"
6 
15 class GPM_ExamplesRun : public virtual CORE_Object {
16  SP_OBJECT(GPM_ExamplesRun);
17 
18  //attributes
19 public :
20 
21 
22 protected:
23  // CONSTRUCTORS
26  GPM_ExamplesRun(void);
27 
28  // DESTRUCTORS
31  virtual ~GPM_ExamplesRun(void);
32 
33 public:
36  inline static SP::GPM_ExamplesRun New() {
37  SP::GPM_ExamplesRun p(new GPM_ExamplesRun(),GPM_ExamplesRun::Delete());
38  p->setThis(p);
39  return p;
40  };
41 
42 
43 public :
44 
45  // MAIN Method
46 
49  virtual tBoolean run(int argc,char* argv[]) const ;
50 
53  virtual tString man() const;
54 
55 
56 
57 private:
60  map<tString,tString> readOptions(int argc,char *argv[]) const;
61 
64  tBoolean readBoolean(const tString& fn) const;
67  int readInt(const tString& fn) const;
70  tReal readReal(const tString& fn) const;
71 
74  tString readPath(const tString& path) const;
75 
78  tString readFile(const tString& path, const tString& fn) const;
79 
82  template<class T>
83  tBoolean readVector(const tString& args,T* values,const int& n) const {
84 
85  tString current(args);
86 
87  // length of the string
88  unsigned int lmax=current.length();
89 
90 
91  // find a [
92  unsigned int indexOB=current.find("[");
93  if (indexOB==0) {
94  current=current.substr(indexOB+1);
95  lmax=current.length();
96  }
97 
98 
99  // find a coma
100  unsigned int indexC=current.find(",");
101  int d=0,i=0;
102  for (i=0;i<n;i++) values[i]=0;
103  i=0;
104  while ((indexC<lmax)&& (i<n)) {
105  CORE_String::parse(current.substr(0,indexC),values[i]);
106  current=current.substr(indexC+1,lmax-indexC-1);
107  lmax=current.length();
108  indexC=current.find(",");
109  i++;
110  }
111  if (i==n) return true;
112 
113  // find a ]
114  unsigned int indexCB=current.find("]");
115  tString v=current;
116  if (indexCB<lmax) {
117  v=current.substr(0,indexCB);
118  current=current.substr(indexCB+1,lmax-indexCB-1);
119  if (current[0]==',') current=current.substr(1);
120  }
121 
122  // parse the last value
123  CORE_String::parse(v,values[i]);
124 
125  for (d=i+1;d<n;d++) {
126  values[d]=values[i];
127  }
128 
129  return true;
130  }
131 
132 
133 
134 
135 
138  tString searchPath(const tString& f) const;
139 
142  tBoolean runSnowFlake1D(const tString& path,const tString& prefix,const int& niters) const;
143 
146  tBoolean runSnowFlake2D(const tString& path,const tString& prefix,const int& niters) const;
149  tBoolean runConway(const tString& path,const tString& prefix,const int& niters,const tString& fileName,const int inPixelSize[2],const int outPixelSize[2]) const;
150 
153  tBoolean snowFlake1DTest() const;
156  tBoolean snowFlake2DTest() const;
159  tBoolean conwayTest() const;
160 
163  tBoolean test() const;
164 
165 
166 };
167 
168 
169 #endif
virtual tString man() const
return the man
Definition: GPM_ExamplesRun.cpp:28
This class is a Run class for GPM/Examples.
Definition: GPM_ExamplesRun.h:15
static SP::GPM_ExamplesRun New()
create a run class
Definition: GPM_ExamplesRun.h:36
#define tBoolean
Definition: types.h:35
DEFINE_SPTR(GPM_ExamplesRun)
static void parse(const tString &str, unsigned char &c)
parse unsigned char c in str
Definition: CORE_String.h:418
virtual ~GPM_ExamplesRun(void)
destroy
Definition: GPM_ExamplesRun.cpp:25
abstract base class for most classes.
Definition: CORE_Object.h:30
GPM_ExamplesRun(void)
create
Definition: GPM_ExamplesRun.cpp:19
#define tString
Definition: types.h:36
virtual tBoolean run(int argc, char *argv[]) const
run the progrm
Definition: GPM_ExamplesRun.cpp:824
#define tReal
Definition: types.h:18
class Free introduced for deleting a smart pointer
Definition: CORE_Object.h:106