Overture  Version 25
GUITypes.h
Go to the documentation of this file.
1 #ifndef GUI_TYPES_H
2 #define GUI_TYPES_H
3 
4 // Define various things for Overture
5 
6 #ifdef NO_APP
7 
8 #include "GUIDefine.h"
9 #include <float.h>
10 
11 #ifndef NO_APP
12 #include "A++.h"
13 #endif
14 
15 // *wdh* 961005
16 #undef FALSE
17 #define FALSE 0
18 
19 #ifdef NO_APP
20 #undef TRUE
21 #define TRUE 1
22 
23 //#include "ArraySimple.h"
24 #include "kk_Array.hh"
25 
26 #include <math.h>
27 #endif
28 
29 namespace GUITypes {
30 
31 # ifdef LONGINT
32 # define INTEGER_MIN LONG_MIN
33 # define INTEGER_MAX LONG_MAX
34  typedef long int Integer;
35  // typedef longIntSerialArray IntegerArray; // This does not exist, so we must use intSerialArray instead.
36 # else
37 # define INTEGER_MIN INT_MIN
38 # define INTEGER_MAX INT_MAX
39  typedef int Integer;
40 # endif // LONGINT
41 
42 #ifndef NO_APP
43 typedef intSerialArray IntegerArray;
44 typedef intArray IntegerDistributedArray;
45 #else
46 typedef KK::Array<int> IntegerArray;
47 typedef KK::Array<int> IntegerDistributedArray;
48 #endif
49 
50 typedef int Logical; // this must alway match LogicalArray !!
51 
52 const Logical LogicalFalse=0,
54 
55 typedef IntegerArray LogicalArray; // There is no such thing as a boolArray!
57 typedef Integer LogicalAE; // This might not be the same as Logical.
58 
59 
60 # ifdef OV_USE_DOUBLE
61 # ifndef USE_DOUBLE
62 # define USE_DOUBLE
63 # endif // USE_DOUBLE
64 # ifdef USE_FLOAT
65 # undef USE_FLOAT
66 # endif // USE_FLOAT
67 # ifndef _REAL_H_
68  // avoid conflict with boxlib
69  typedef double Real;
70 # endif
71  typedef long double DoubleReal;
72 #ifndef NO_APP
73  typedef doubleSerialArray RealArray;
74  // typedef longDoubleSerialArray DoubleRealArray; // This does not exist, so
75  typedef doubleSerialArray DoubleRealArray; // we use doubleSerialArray.
76  typedef doubleSerialArray RealSerialArray;
77  typedef doubleSerialArray realSerialArray;
78  typedef doubleArray RealDistributedArray;
79  typedef doubleArray DoubleRealDistributedArray;
80 #else
81  typedef KK::Array<double> RealArray;
82  typedef KK::Array<double> DoubleRealArray;
83  typedef KK::Array<double> RealSerialArray;
84  typedef KK::Array<double> realSerialArray;
85  typedef KK::Array<double> RealDistributedArray;
86  typedef KK::Array<double> DoubleRealDistributedArray;
87 #endif
88 
89 // Define "real" versions of the constants in <float.h>
90 # define REAL_RADIX FLT_RADIX
91 # define REAL_ROUNDS FLT_ROUNDS
92 # define REAL_DIG DBL_DIG
93 # define REAL_EPSILON DBL_EPSILON
94 # define REAL_MANT_DIG DBL_MANT_DIG
95 # define REAL_MAX DBL_MAX
96 # define REAL_MAX_EXP DBL_MAX_EXP
97 # define REAL_MIN DBL_MIN
98 # define REAL_MIN_EXP DBL_MIN_EXP
99 
100 # else
101 
102 # ifdef USE_DOUBLE
103 # undef USE_DOUBLE
104 # endif // USE_DOUBLE
105 # ifndef USE_FLOAT
106 # define USE_FLOAT
107 # endif // USE_FLOAT
108 # ifndef _REAL_H_
109  typedef float Real;
110 # endif
111  typedef double DoubleReal;
112 #ifndef NO_APP
113  typedef floatSerialArray RealArray;
114  typedef floatSerialArray RealSerialArray;
115  typedef floatSerialArray realSerialArray;
116 
117  typedef doubleSerialArray DoubleRealArray;
118  typedef floatArray RealDistributedArray;
119  typedef doubleArray DoubleRealDistributedArray;
120 #else
121  typedef KK::Array<float> RealArray;
122  typedef KK::Array<float> RealSerialArray;
123  typedef KK::Array<float> realSerialArray;
124 
125  typedef KK::Array<double> DoubleRealArray;
126  typedef KK::Array<float> RealDistributedArray;
127  typedef KK::Array<double> DoubleRealDistributedArray;
128 #endif
129 
130 // Define "real" versions of the constants in <float.h>
131 # define REAL_RADIX FLT_RADIX
132 # define REAL_ROUNDS FLT_ROUNDS
133 # define REAL_DIG FLT_DIG
134 # define REAL_EPSILON FLT_EPSILON
135 # define REAL_MANT_DIG FLT_MANT_DIG
136 # define REAL_MAX FLT_MAX
137 # define REAL_MAX_EXP FLT_MAX_EXP
138 # define REAL_MIN FLT_MIN
139 # define REAL_MIN_EXP FLT_MIN_EXP
140 
141 # endif // DOUBLE
142 
143 typedef Real real;
146 #ifndef NO_APP
147 typedef intArray intDistributedArray;
148 typedef floatArray floatDistributedArray;
149 typedef doubleArray doubleDistributedArray;
150 #else
151 typedef KK::Array<int> intDistributedArray;
152 typedef KK::Array<float> floatDistributedArray;
153 typedef KK::Array<double> doubleDistributedArray;
154 
155 typedef KK::Array<int> intSerialArray;
156 typedef KK::Array<float> floatSerialArray;
157 typedef KK::Array<double> doubleSerialArray;
158 #endif
159 
160 enum CopyType { DEEP, SHALLOW, NOCOPY };
161 
162 // Constants for A++ array indexing.
163 /* *wdh* 030423 enum { START=0, END=1, X_AXIS=0, Y_AXIS=1, Z_AXIS=2 }; */
164 
165 // Macros used by Boxlib.
166 # undef BL_SPACEDIM
167 # define BL_SPACEDIM 3
168 # undef BL_ARCH_IEEE
169 # define BL_ARCH_IEEE
170 
171 #if ( defined(__alpha) || defined(__sgi) )
172  inline ostream& operator<<(ostream& s, const long double& x)
173  { s << (double)x; return s; }
174 #endif // ( defined(__alpha) || defined(__sgi) )
175 
176 #if !defined(OV_BOOL_DEFINED) && !defined(USE_PPP)
177  typedef int bool; // this will be the new standard for Boolean
178 #endif
179 
180 #ifdef OV_EXCEPTIONS_NOT_SUPPORTED
181  #define throw exit(1); cout <<
182 #endif
183 
184 }
185 
186 using GUITypes::RealArray;
188 using GUITypes::realArray;
189 using GUITypes::CopyType;
190 using GUITypes::intSerialArray;
191 using GUITypes::floatSerialArray;
192 using GUITypes::doubleSerialArray;
193 //using GUITypes::intArray;
194 
195 inline std::string
196 substring(const std::string & s, const int startPosition, const int endPosition )
197 // ====================================================================================
198 // Return a substring -- replacement for aString(i1,i2)
199 // ====================================================================================
200 {
201  return s.substr(startPosition,endPosition-startPosition+1);
202 }
203 
204 
205 inline int
206 matches(const std::string & s, const char *name )
207 // ================================================================================
208 // If all the characters of name match the characters of this string then
209 // return the number of characters of name, otherwise return zero.
210 // ==================================================================================
211 {
212  int lenName=strlen(name);
213  if( s.substr(0,lenName)==name )
214  return lenName;
215  else
216  return 0;
217 }
218 
219 #define getCPU KK::getcpu
220 #else
221 
222 #include "OvertureTypes.h"
223 #include <string>
224 
225 namespace GUITypes {
226 
228 
229 }
230 #endif
231 
232 inline unsigned int str_matches(std::string s, std::string m)
233 { // *wdh* 051012 return s.find(m)!=std::string::npos ? m.length() : 0;
234  return s.find(m)==0 ? m.length() : 0; // *wdh* The string must match from the start
235 }
236 
237 #endif
238 
239 
240