Geant4  10.02.p03
G4UIparameter Class Reference

#include <G4UIparameter.hh>

Collaboration diagram for G4UIparameter:

Public Member Functions

 G4UIparameter ()
 
 G4UIparameter (char theType)
 
 G4UIparameter (const char *theName, char theType, G4bool theOmittable)
 
 ~G4UIparameter ()
 
G4int operator== (const G4UIparameter &right) const
 
G4int operator!= (const G4UIparameter &right) const
 
G4int CheckNewValue (const char *newValue)
 
void List ()
 
void SetDefaultValue (const char *theDefaultValue)
 
void SetDefaultValue (G4int theDefaultValue)
 
void SetDefaultValue (G4double theDefaultValue)
 
G4String GetDefaultValue () const
 
char GetParameterType () const
 
void SetParameterRange (const char *theRange)
 
G4String GetParameterRange () const
 
void SetParameterName (const char *theName)
 
G4String GetParameterName () const
 
void SetParameterCandidates (const char *theString)
 
G4String GetParameterCandidates () const
 
void SetOmittable (G4bool om)
 
G4bool IsOmittable () const
 
void SetCurrentAsDefault (G4bool val)
 
G4bool GetCurrentAsDefault () const
 
void SetWidget (G4int theWidget)
 
const G4String GetParameterGuidance () const
 
void SetGuidance (const char *theGuidance)
 

Private Member Functions

G4int TypeCheck (const char *newValue)
 
G4int RangeCheck (const char *newValue)
 
G4int CandidateCheck (const char *newValue)
 
G4int IsInt (const char *str, short maxDigit)
 
G4int IsDouble (const char *str)
 
G4int ExpectExponent (const char *str)
 
yystype Expression (void)
 
yystype LogicalORExpression (void)
 
yystype LogicalANDExpression (void)
 
yystype EqualityExpression (void)
 
yystype RelationalExpression (void)
 
yystype AdditiveExpression (void)
 
yystype MultiplicativeExpression (void)
 
yystype UnaryExpression (void)
 
yystype PrimaryExpression (void)
 
G4int Eval2 (yystype arg1, G4int op, yystype arg2)
 
G4int CompareInt (G4int arg1, G4int op, G4int arg2)
 
G4int CompareDouble (double arg1, G4int op, double arg2)
 
tokenNum Yylex (void)
 
G4int G4UIpGetc (void)
 
G4int G4UIpUngetc (G4int c)
 
G4int Backslash (G4int c)
 
G4int Follow (G4int expect, G4int ifyes, G4int ifno)
 
G4String TokenToStr (G4int token)
 

Private Attributes

G4String parameterName
 
G4String parameterGuidance
 
G4String defaultValue
 
G4String parameterRange
 
G4String parameterCandidate
 
char parameterType
 
G4bool omittable
 
G4bool currentAsDefaultFlag
 
G4int widget
 
G4String rangeBuf
 
G4int bp
 
tokenNum token
 
yystype yylval
 
yystype newVal
 
G4int paramERR
 

Detailed Description

Definition at line 47 of file G4UIparameter.hh.

Constructor & Destructor Documentation

◆ G4UIparameter() [1/3]

G4UIparameter::G4UIparameter ( )

Definition at line 37 of file G4UIparameter.cc.

37  :paramERR(0)
38 {
39  G4String nullString;
40  parameterName = nullString;
41  parameterType = '\0';
42  omittable = false;
43  parameterGuidance = nullString;
44  defaultValue = nullString;
45  parameterRange = nullString;
46  currentAsDefaultFlag = false;
47  parameterCandidate = nullString;
48  widget = 0;
49  bp = 0;
50  token = NONE;
51 }
G4bool currentAsDefaultFlag
G4String parameterName
G4String defaultValue
G4String parameterCandidate
G4String parameterRange
G4String parameterGuidance

◆ G4UIparameter() [2/3]

G4UIparameter::G4UIparameter ( char  theType)

Definition at line 53 of file G4UIparameter.cc.

53  :paramERR(0)
54 {
55  G4String nullString;
56  parameterName = nullString;
57  parameterType = theType;
58  omittable = false;
59  parameterGuidance = nullString;
60  defaultValue = nullString;
61  parameterRange = nullString;
62  currentAsDefaultFlag = false;
63  parameterCandidate = nullString;
64  widget = 0;
65  bp = 0;
66  token = NONE;
67 }
G4bool currentAsDefaultFlag
G4String parameterName
G4String defaultValue
G4String parameterCandidate
G4String parameterRange
G4String parameterGuidance

◆ G4UIparameter() [3/3]

G4UIparameter::G4UIparameter ( const char *  theName,
char  theType,
G4bool  theOmittable 
)

Definition at line 69 of file G4UIparameter.cc.

69  :paramERR(0)
70 {
71  parameterName = theName;
72  parameterType = theType;
73  omittable = theOmittable;
74  G4String nullString;
75  parameterGuidance = nullString;
76  defaultValue = nullString;
77  parameterRange = nullString;
78  currentAsDefaultFlag = false;
79  parameterCandidate = nullString;
80  widget = 0;
81  bp = 0;
82  token = NONE;
83 }
G4bool currentAsDefaultFlag
G4String parameterName
G4String defaultValue
G4String parameterCandidate
G4String parameterRange
G4String parameterGuidance

◆ ~G4UIparameter()

G4UIparameter::~G4UIparameter ( )

Definition at line 85 of file G4UIparameter.cc.

86 { }

Member Function Documentation

◆ AdditiveExpression()

yystype G4UIparameter::AdditiveExpression ( void  )
private

Definition at line 461 of file G4UIparameter.cc.

462 { yystype result;
463  result = MultiplicativeExpression();
464  if( token != '+' && token != '-' ) return result;
465  G4cerr << "Parameter range: operator "
466  << (char)token
467  << " is not supported." << G4endl;
468  paramERR = 1;
469  return result;
470 }
yystype MultiplicativeExpression(void)
#define G4endl
Definition: G4ios.hh:61
G4GLOB_DLL std::ostream G4cerr
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Backslash()

G4int G4UIparameter::Backslash ( G4int  c)
private
Here is the caller graph for this function:

◆ CandidateCheck()

G4int G4UIparameter::CandidateCheck ( const char *  newValue)
private

Definition at line 151 of file G4UIparameter.cc.

151  {
152  G4Tokenizer candidateTokenizer(parameterCandidate);
153  G4String aToken;
154  G4int iToken = 0;
155  while( ! (aToken=candidateTokenizer()).isNull() )
156  {
157  iToken++;
158  if(aToken==newValue) return iToken;
159  }
160  G4cerr << "parameter value (" << newValue
161  << ") is not listed in the candidate List." << G4endl;
162  return 0;
163 }
G4String parameterCandidate
int G4int
Definition: G4Types.hh:78
#define G4endl
Definition: G4ios.hh:61
G4GLOB_DLL std::ostream G4cerr
Here is the call graph for this function:
Here is the caller graph for this function:

◆ CheckNewValue()

G4int G4UIparameter::CheckNewValue ( const char *  newValue)

Definition at line 141 of file G4UIparameter.cc.

141  {
142  if( TypeCheck(newValue) == 0) return fParameterUnreadable;
143  if( ! parameterRange.isNull() )
144  { if( RangeCheck(newValue) == 0 ) return fParameterOutOfRange; }
145  if( ! parameterCandidate.isNull() )
146  { if( CandidateCheck(newValue) == 0 ) return fParameterOutOfCandidates; }
147  return 0; // succeeded
148 }
G4int CandidateCheck(const char *newValue)
G4String parameterCandidate
G4int RangeCheck(const char *newValue)
G4String parameterRange
G4int TypeCheck(const char *newValue)
G4bool isNull() const
Here is the call graph for this function:
Here is the caller graph for this function:

◆ CompareDouble()

G4int G4UIparameter::CompareDouble ( double  arg1,
G4int  op,
double  arg2 
)
private

Definition at line 640 of file G4UIparameter.cc.

641 {
642  G4int result=-1;
643  G4String opr;
644  switch (op) {
645  case GT: result = ( arg1 > arg2); opr= ">"; break;
646  case GE: result = ( arg1 >= arg2); opr= ">="; break;
647  case LT: result = ( arg1 < arg2); opr= "<"; break;
648  case LE: result = ( arg1 <= arg2); opr= "<="; break;
649  case EQ: result = ( arg1 == arg2); opr= "=="; break;
650  case NE: result = ( arg1 != arg2); opr= "!="; break;
651  default:
652  G4cerr << "Parameter range: error at CompareDouble" << G4endl;
653  paramERR = 1;
654  }
655  #ifdef DEBUG
656  G4cerr << "CompareDouble "
657  << arg1 <<" " << opr << " "<< arg2
658  << " result: " << result
659  << G4endl;
660  #endif
661  return result;
662 }
Definition: Evaluator.cc:66
Definition: Evaluator.cc:66
Definition: Evaluator.cc:66
Definition: Evaluator.cc:66
int G4int
Definition: G4Types.hh:78
Definition: Evaluator.cc:66
Definition: Evaluator.cc:66
#define G4endl
Definition: G4ios.hh:61
G4GLOB_DLL std::ostream G4cerr
Here is the call graph for this function:
Here is the caller graph for this function:

◆ CompareInt()

G4int G4UIparameter::CompareInt ( G4int  arg1,
G4int  op,
G4int  arg2 
)
private

Definition at line 615 of file G4UIparameter.cc.

616 {
617  G4int result=-1;
618  G4String opr;
619  switch (op) {
620  case GT: result = ( arg1 > arg2); opr= ">" ; break;
621  case GE: result = ( arg1 >= arg2); opr= ">="; break;
622  case LT: result = ( arg1 < arg2); opr= "<" ; break;
623  case LE: result = ( arg1 <= arg2); opr= "<="; break;
624  case EQ: result = ( arg1 == arg2); opr= "=="; break;
625  case NE: result = ( arg1 != arg2); opr= "!="; break;
626  default:
627  G4cerr << "Parameter range: error at CompareInt" << G4endl;
628  paramERR = 1;
629  }
630  #ifdef DEBUG
631  G4cerr << "CompareInt "
632  << arg1 << " " << opr << arg2
633  << " result: " << result
634  << G4endl;
635  #endif
636  return result;
637 }
Definition: Evaluator.cc:66
Definition: Evaluator.cc:66
Definition: Evaluator.cc:66
Definition: Evaluator.cc:66
int G4int
Definition: G4Types.hh:78
Definition: Evaluator.cc:66
Definition: Evaluator.cc:66
#define G4endl
Definition: G4ios.hh:61
G4GLOB_DLL std::ostream G4cerr
Here is the call graph for this function:
Here is the caller graph for this function:

◆ EqualityExpression()

yystype G4UIparameter::EqualityExpression ( void  )
private

Definition at line 401 of file G4UIparameter.cc.

402 {
403  yystype arg1, arg2;
404  G4int operat;
405  yystype result;
406  #ifdef DEBUG
407  G4cerr << " EqualityExpression()" <<G4endl;
408  #endif
409  result = RelationalExpression();
410  if( token==EQ || token==NE ) {
411  operat = token;
412  token = Yylex();
413  arg1 = result;
414  arg2 = RelationalExpression();
415  result.I = Eval2( arg1, operat, arg2 ); // semantic action
416  result.type = CONSTINT;
417  #ifdef DEBUG
418  G4cerr << " return code of Eval2(): " << result.I <<G4endl;
419  #endif
420  } else {
421  if (result.type != CONSTINT && result.type != CONSTDOUBLE) {
422  G4cerr << "Parameter range: error at EqualityExpression"
423  << G4endl;
424  paramERR = 1;
425  }
426  }
427  return result;
428 }
yystype RelationalExpression(void)
Definition: Evaluator.cc:66
Definition: Evaluator.cc:66
int G4int
Definition: G4Types.hh:78
G4int I
Definition: G4UItokenNum.hh:64
tokenNum type
Definition: G4UItokenNum.hh:62
G4int Eval2(yystype arg1, G4int op, yystype arg2)
#define G4endl
Definition: G4ios.hh:61
tokenNum Yylex(void)
G4GLOB_DLL std::ostream G4cerr
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Eval2()

G4int G4UIparameter::Eval2 ( yystype  arg1,
G4int  op,
yystype  arg2 
)
private

Definition at line 559 of file G4UIparameter.cc.

560 {
561  if( (arg1.type != IDENTIFIER) && (arg2.type != IDENTIFIER)) {
563  << ": meaningless comparison "
564  << G4int(arg1.type) << " " << G4int(arg2.type) << G4endl;
565  paramERR = 1;
566  }
567  char type = toupper( parameterType );
568  if( arg1.type == IDENTIFIER) {
569  switch (type) {
570  case 'I':
571  if ( arg2.type == CONSTINT ) {
572  return CompareInt( newVal.I, op, arg2.I );
573  } else {
574  G4cerr << "integer operand expected for "
575  << parameterRange << '.'
576  << G4endl;
577  }
578  break;
579  case 'D':
580  if ( arg2.type == CONSTDOUBLE ) {
581  return CompareDouble( newVal.D, op, arg2.D );
582  } else
583  if ( arg2.type == CONSTINT ) { // integral promotion
584  return CompareDouble( newVal.D, op, arg2.I );
585  } break;
586  default: ;
587  }
588  }
589  if( arg2.type == IDENTIFIER) {
590  switch (type) {
591  case 'I':
592  if ( arg1.type == CONSTINT ) {
593  return CompareInt( arg1.I, op, newVal.I );
594  } else {
595  G4cerr << "integer operand expected for "
596  << parameterRange << '.'
597  << G4endl;
598  }
599  break;
600  case 'D':
601  if ( arg1.type == CONSTDOUBLE ) {
602  return CompareDouble( arg1.D, op, newVal.D );
603  } else
604  if ( arg1.type == CONSTINT ) { // integral promotion
605  return CompareDouble( arg1.I, op, newVal.D );
606  } break;
607  default: ;
608  }
609  }
610  G4cerr << "no param name is specified at the param range."<<G4endl;
611  return 0;
612 }
G4String parameterName
int G4int
Definition: G4Types.hh:78
G4int I
Definition: G4UItokenNum.hh:64
G4int CompareDouble(double arg1, G4int op, double arg2)
G4int CompareInt(G4int arg1, G4int op, G4int arg2)
tokenNum type
Definition: G4UItokenNum.hh:62
G4String parameterRange
#define G4endl
Definition: G4ios.hh:61
G4double D
Definition: G4UItokenNum.hh:63
G4GLOB_DLL std::ostream G4cerr
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ExpectExponent()

G4int G4UIparameter::ExpectExponent ( const char *  str)
private

Definition at line 252 of file G4UIparameter.cc.

253 {
254  G4int maxExplength;
255  if( IsInt( str, maxExplength=7 )) return 1;
256  else return 0;
257 }
int G4int
Definition: G4Types.hh:78
G4int IsInt(const char *str, short maxDigit)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Expression()

yystype G4UIparameter::Expression ( void  )
private

Definition at line 319 of file G4UIparameter.cc.

320 {
321  yystype result;
322  #ifdef DEBUG
323  G4cerr << " Expression()" << G4endl;
324  #endif
325  result = LogicalORExpression();
326  return result;
327 }
#define G4endl
Definition: G4ios.hh:61
G4GLOB_DLL std::ostream G4cerr
yystype LogicalORExpression(void)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Follow()

G4int G4UIparameter::Follow ( G4int  expect,
G4int  ifyes,
G4int  ifno 
)
private

Definition at line 725 of file G4UIparameter.cc.

726 {
727  G4int c = G4UIpGetc();
728  if ( c== expect)
729  return ifyes;
730  G4UIpUngetc(c);
731  return ifno;
732 }
int G4int
Definition: G4Types.hh:78
G4int G4UIpUngetc(G4int c)
G4int G4UIpGetc(void)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ G4UIpGetc()

G4int G4UIparameter::G4UIpGetc ( void  )
private

Definition at line 736 of file G4UIparameter.cc.

736  { // emulation of getc()
737  G4int length = parameterRange.length();
738  if( bp < length)
739  return parameterRange(bp++);
740  else
741  return EOF;
742 }
int G4int
Definition: G4Types.hh:78
G4String parameterRange
Here is the call graph for this function:
Here is the caller graph for this function:

◆ G4UIpUngetc()

G4int G4UIparameter::G4UIpUngetc ( G4int  c)
private

Definition at line 744 of file G4UIparameter.cc.

744  { // emulation of ungetc()
745  if (c<0) return -1;
746  if (bp >0 && c == parameterRange(bp-1)) {
747  --bp;
748  } else {
749  G4cerr << "G4UIpUngetc() failed." << G4endl;
750  G4cerr << "bp="<<bp <<" c="<<c
751  << " pR(bp-1)=" << parameterRange(bp-1)
752  << G4endl;
753  paramERR = 1;
754  return -1;
755  }
756  return 0;
757 }
G4String parameterRange
#define G4endl
Definition: G4ios.hh:61
G4GLOB_DLL std::ostream G4cerr
Here is the caller graph for this function:

◆ GetCurrentAsDefault()

G4bool G4UIparameter::GetCurrentAsDefault ( ) const
inline

Definition at line 130 of file G4UIparameter.hh.

131  { return currentAsDefaultFlag; }
G4bool currentAsDefaultFlag
Here is the caller graph for this function:

◆ GetDefaultValue()

G4String G4UIparameter::GetDefaultValue ( ) const
inline

Definition at line 89 of file G4UIparameter.hh.

90  { return defaultValue; }
G4String defaultValue
Here is the caller graph for this function:

◆ GetParameterCandidates()

G4String G4UIparameter::GetParameterCandidates ( ) const
inline

Definition at line 118 of file G4UIparameter.hh.

119  { return parameterCandidate; }
G4String parameterCandidate
Here is the caller graph for this function:

◆ GetParameterGuidance()

const G4String G4UIparameter::GetParameterGuidance ( ) const
inline

Definition at line 136 of file G4UIparameter.hh.

137  { return parameterGuidance; }
G4String parameterGuidance
Here is the caller graph for this function:

◆ GetParameterName()

G4String G4UIparameter::GetParameterName ( ) const
inline

Definition at line 109 of file G4UIparameter.hh.

110  { return parameterName; }
G4String parameterName
Here is the caller graph for this function:

◆ GetParameterRange()

G4String G4UIparameter::GetParameterRange ( ) const
inline

Definition at line 103 of file G4UIparameter.hh.

104  { return parameterRange; }
G4String parameterRange
Here is the caller graph for this function:

◆ GetParameterType()

char G4UIparameter::GetParameterType ( ) const
inline

Definition at line 91 of file G4UIparameter.hh.

92  { return parameterType; }
Here is the caller graph for this function:

◆ IsDouble()

G4int G4UIparameter::IsDouble ( const char *  str)
private

Definition at line 260 of file G4UIparameter.cc.

261 {
262  const char* p= buf;
263  switch( *p) {
264  case '+': case '-': ++p;
265  if( isdigit(*p) ) {
266  while( isdigit( (G4int)(*p) )) { ++p; }
267  switch ( *p ) {
268  case '\0': return 1; //break;
269  case 'E': case 'e':
270  return ExpectExponent(++p ); //break;
271  case '.': ++p;
272  if( *p == '\0' ) return 1;
273  if( *p == 'e' || *p =='E' ) return ExpectExponent(++p );
274  if( isdigit(*p) ) {
275  while( isdigit( (G4int)(*p) )) { ++p; }
276  if( *p == '\0' ) return 1;
277  if( *p == 'e' || *p =='E') return ExpectExponent(++p);
278  } else return 0; break;
279  default: return 0;
280  }
281  }
282  if( *p == '.' ) { ++p;
283  if( isdigit(*p) ) {
284  while( isdigit( (G4int)(*p) )) { ++p; }
285  if( *p == '\0' ) return 1;
286  if( *p == 'e' || *p =='E') return ExpectExponent(++p);
287  }
288  }
289  break;
290  case '.': ++p;
291  if( isdigit(*p) ) {
292  while( isdigit( (G4int)(*p) )) { ++p; }
293  if( *p == '\0' ) return 1;
294  if( *p == 'e' || *p =='E' ) return ExpectExponent(++p);
295  } break;
296  default: // digit is expected
297  if( isdigit(*p) ) {
298  while( isdigit( (G4int)(*p) )) { ++p; }
299  if( *p == '\0' ) return 1;
300  if( *p == 'e' || *p =='E') return ExpectExponent(++p);
301  if( *p == '.' ) { ++p;
302  if( *p == '\0' ) return 1;
303  if( *p == 'e' || *p =='E') return ExpectExponent(++p);
304  if( isdigit(*p) ) {
305  while( isdigit( (G4int)(*p) )) { ++p; }
306  if( *p == '\0' ) return 1;
307  if( *p == 'e' || *p =='E') return ExpectExponent(++p);
308  }
309  }
310  }
311  }
312  return 0;
313 }
int G4int
Definition: G4Types.hh:78
G4int ExpectExponent(const char *str)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ IsInt()

G4int G4UIparameter::IsInt ( const char *  str,
short  maxDigit 
)
private

Definition at line 228 of file G4UIparameter.cc.

229 {
230  const char* p= buf;
231  G4int length=0;
232  if( *p == '+' || *p == '-') { ++p; }
233  if( isdigit( (G4int)(*p) )) {
234  while( isdigit( (G4int)(*p) )) { ++p; ++length; }
235  if( *p == '\0' ) {
236  if( length > maxDigits) {
237  G4cerr <<"digit length exceeds"<<G4endl;
238  return 0;
239  }
240  return 1;
241  } else {
242  // G4cerr <<"illegal character after int:"<<buf<<G4endl;
243  }
244  } else {
245  // G4cerr <<"illegal int:"<<buf<<G4endl;
246  }
247  return 0;
248 }
int G4int
Definition: G4Types.hh:78
#define G4endl
Definition: G4ios.hh:61
G4GLOB_DLL std::ostream G4cerr
Here is the call graph for this function:
Here is the caller graph for this function:

◆ IsOmittable()

G4bool G4UIparameter::IsOmittable ( ) const
inline

Definition at line 124 of file G4UIparameter.hh.

125  { return omittable; }
Here is the caller graph for this function:

◆ List()

void G4UIparameter::List ( )

Definition at line 98 of file G4UIparameter.cc.

99 {
100  G4cout << G4endl << "Parameter : " << parameterName << G4endl;
101  if( ! parameterGuidance.isNull() )
102  G4cout << parameterGuidance << G4endl ;
103  G4cout << " Parameter type : " << parameterType << G4endl;
104  if(omittable)
105  { G4cout << " Omittable : True" << G4endl; }
106  else
107  { G4cout << " Omittable : False" << G4endl; }
109  { G4cout << " Default value : taken from the current value" << G4endl; }
110  else if( ! defaultValue.isNull() )
111  { G4cout << " Default value : " << defaultValue << G4endl; }
112  if( ! parameterRange.isNull() )
113  G4cout << " Parameter range : " << parameterRange << G4endl;
114  if( ! parameterCandidate.isNull() )
115  G4cout << " Candidates : " << parameterCandidate << G4endl;
116 }
G4bool currentAsDefaultFlag
G4String parameterName
G4String defaultValue
G4String parameterCandidate
G4GLOB_DLL std::ostream G4cout
G4String parameterRange
#define G4endl
Definition: G4ios.hh:61
G4String parameterGuidance
G4bool isNull() const
Here is the call graph for this function:
Here is the caller graph for this function:

◆ LogicalANDExpression()

yystype G4UIparameter::LogicalANDExpression ( void  )
private

Definition at line 365 of file G4UIparameter.cc.

366 {
367  yystype result;
368  yystype p;
369  p = EqualityExpression();
370  if( token != LOGICALAND) return p;
371  if( p.type == CONSTSTRING || p.type == IDENTIFIER ) {
372  G4cerr << "Parameter range: illegal type at '&&'" << G4endl;
373  paramERR = 1;
374  }
375  result.I = p.I;
376  while (token == LOGICALAND)
377  {
378  token = Yylex();
379  p = EqualityExpression();
380  if( p.type == CONSTSTRING || p.type == IDENTIFIER ) {
381  G4cerr << "Parameter range: illegal type at '&&'" << G4endl;
382  paramERR = 1;
383  }
384  switch (p.type) {
385  case CONSTINT:
386  result.I *= p.I;
387  result.type = CONSTINT; break;
388  case CONSTDOUBLE:
389  result.I *= (p.D != 0.0);
390  result.type = CONSTINT; break;
391  default:
392  G4cerr << "Parameter range: unknown type."<< G4endl;
393  paramERR = 1;
394  }
395  }
396  return result;
397 }
G4int I
Definition: G4UItokenNum.hh:64
tokenNum type
Definition: G4UItokenNum.hh:62
#define G4endl
Definition: G4ios.hh:61
G4double D
Definition: G4UItokenNum.hh:63
tokenNum Yylex(void)
yystype EqualityExpression(void)
G4GLOB_DLL std::ostream G4cerr
Here is the call graph for this function:
Here is the caller graph for this function:

◆ LogicalORExpression()

yystype G4UIparameter::LogicalORExpression ( void  )
private

Definition at line 330 of file G4UIparameter.cc.

331 {
332  yystype result;
333  yystype p;
334  p = LogicalANDExpression();
335  if( token != LOGICALOR) return p;
336  if( p.type == CONSTSTRING || p.type == IDENTIFIER ) {
337  G4cerr << "Parameter range: illegal type at '||'" << G4endl;
338  paramERR = 1;
339  }
340  result.I = p.I;
341  while (token == LOGICALOR)
342  {
343  token = Yylex();
344  p = LogicalANDExpression();
345  if( p.type == CONSTSTRING || p.type == IDENTIFIER ) {
346  G4cerr << "Parameter range: illegal type at '||'" <<G4endl;
347  paramERR = 1;
348  }
349  switch (p.type) {
350  case CONSTINT:
351  result.I += p.I;
352  result.type = CONSTINT; break;
353  case CONSTDOUBLE:
354  result.I += (p.D != 0.0);
355  result.type = CONSTINT; break;
356  default:
357  G4cerr << "Parameter range: unknown type"<<G4endl;
358  paramERR = 1;
359  }
360  }
361  return result;
362 }
yystype LogicalANDExpression(void)
G4int I
Definition: G4UItokenNum.hh:64
tokenNum type
Definition: G4UItokenNum.hh:62
#define G4endl
Definition: G4ios.hh:61
G4double D
Definition: G4UItokenNum.hh:63
tokenNum Yylex(void)
G4GLOB_DLL std::ostream G4cerr
Here is the call graph for this function:
Here is the caller graph for this function:

◆ MultiplicativeExpression()

yystype G4UIparameter::MultiplicativeExpression ( void  )
private

Definition at line 473 of file G4UIparameter.cc.

474 { yystype result;
475  result = UnaryExpression();
476  if( token != '*' && token != '/' && token != '%' ) return result;
477  G4cerr << "Parameter range: operator "
478  << (char)token
479  << " is not supported." << G4endl;
480  paramERR = 1;
481  return result;
482 }
yystype UnaryExpression(void)
#define G4endl
Definition: G4ios.hh:61
G4GLOB_DLL std::ostream G4cerr
Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator!=()

G4int G4UIparameter::operator!= ( const G4UIparameter right) const

Definition at line 93 of file G4UIparameter.cc.

94 {
95  return ( this != &right );
96 }

◆ operator==()

G4int G4UIparameter::operator== ( const G4UIparameter right) const

Definition at line 88 of file G4UIparameter.cc.

89 {
90  return ( this == &right );
91 }

◆ PrimaryExpression()

yystype G4UIparameter::PrimaryExpression ( void  )
private

Definition at line 522 of file G4UIparameter.cc.

523 {
524  yystype result;
525  #ifdef DEBUG
526  G4cerr <<" PrimaryExpression" << G4endl;
527  #endif
528  switch (token) {
529  case IDENTIFIER:
530  result.S = yylval.S;
531  result.type = token;
532  token = Yylex(); break;
533  case CONSTINT:
534  result.I = yylval.I;
535  result.type = token;
536  token= Yylex(); break;
537  case CONSTDOUBLE:
538  result.D = yylval.D;
539  result.type = token;
540  token = Yylex(); break;
541  case '(' :
542  token= Yylex();
543  result = Expression();
544  if( token != ')' ) {
545  G4cerr << " ')' expected" << G4endl;
546  paramERR = 1;
547  }
548  token = Yylex();
549  break;
550  default:
551  return result;
552  }
553  return result; // never executed
554 }
G4String S
Definition: G4UItokenNum.hh:66
G4int I
Definition: G4UItokenNum.hh:64
tokenNum type
Definition: G4UItokenNum.hh:62
yystype Expression(void)
#define G4endl
Definition: G4ios.hh:61
G4double D
Definition: G4UItokenNum.hh:63
tokenNum Yylex(void)
G4GLOB_DLL std::ostream G4cerr
Here is the call graph for this function:
Here is the caller graph for this function:

◆ RangeCheck()

G4int G4UIparameter::RangeCheck ( const char *  newValue)
private

Definition at line 166 of file G4UIparameter.cc.

166  {
167  yystype result;
168  bp = 0; // reset buffer pointer for G4UIpGetc()
169  std::istringstream is(newValue);
170  char type = toupper( parameterType );
171  switch (type) {
172  case 'D': { is >> newVal.D; } break;
173  case 'I': { is >> newVal.I; } break;
174  default: ;
175  }
176  // PrintToken(); // Print tokens (consumes all tokens)
177  token= Yylex();
178  result = Expression();
179  if( paramERR == 1 ) return 0;
180  if( result.type != CONSTINT) {
181  G4cerr << "Illegal Expression in parameter range." << G4endl;
182  return 0;
183  }
184  if ( result.I ) return 1;
185  G4cerr << "parameter out of range: "<< parameterRange << G4endl;
186  return 0;
187 }
G4int I
Definition: G4UItokenNum.hh:64
tokenNum type
Definition: G4UItokenNum.hh:62
yystype Expression(void)
G4String parameterRange
#define G4endl
Definition: G4ios.hh:61
G4double D
Definition: G4UItokenNum.hh:63
tokenNum Yylex(void)
G4GLOB_DLL std::ostream G4cerr
Here is the call graph for this function:
Here is the caller graph for this function:

◆ RelationalExpression()

yystype G4UIparameter::RelationalExpression ( void  )
private

Definition at line 432 of file G4UIparameter.cc.

433 {
434  yystype arg1, arg2;
435  G4int operat;
436  yystype result;
437  #ifdef DEBUG
438  G4cerr << " RelationalExpression()" <<G4endl;
439  #endif
440 
441  arg1 = AdditiveExpression();
442  if( token==GT || token==GE || token==LT || token==LE ) {
443  operat = token;
444  token = Yylex();
445  arg2 = AdditiveExpression();
446  result.I = Eval2( arg1, operat, arg2 ); // semantic action
447  result.type = CONSTINT;
448  #ifdef DEBUG
449  G4cerr << " return Eval2(): " << G4endl;
450  #endif
451  } else {
452  result = arg1;
453  }
454  #ifdef DEBUG
455  G4cerr <<" return RelationalExpression()" <<G4endl;
456  #endif
457  return result;
458 }
yystype AdditiveExpression(void)
Definition: Evaluator.cc:66
Definition: Evaluator.cc:66
int G4int
Definition: G4Types.hh:78
G4int I
Definition: G4UItokenNum.hh:64
Definition: Evaluator.cc:66
tokenNum type
Definition: G4UItokenNum.hh:62
Definition: Evaluator.cc:66
G4int Eval2(yystype arg1, G4int op, yystype arg2)
#define G4endl
Definition: G4ios.hh:61
tokenNum Yylex(void)
G4GLOB_DLL std::ostream G4cerr
Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetCurrentAsDefault()

void G4UIparameter::SetCurrentAsDefault ( G4bool  val)
inline

Definition at line 128 of file G4UIparameter.hh.

129  { currentAsDefaultFlag = val; }
G4bool currentAsDefaultFlag
Here is the caller graph for this function:

◆ SetDefaultValue() [1/3]

void G4UIparameter::SetDefaultValue ( const char *  theDefaultValue)
inline

Definition at line 83 of file G4UIparameter.hh.

84  { defaultValue = theDefaultValue; }
G4String defaultValue

◆ SetDefaultValue() [2/3]

void G4UIparameter::SetDefaultValue ( G4int  theDefaultValue)

Definition at line 118 of file G4UIparameter.cc.

119 {
120  std::ostringstream os;
121  os << theDefaultValue;
122  defaultValue = os.str();
123 }
G4String defaultValue

◆ SetDefaultValue() [3/3]

void G4UIparameter::SetDefaultValue ( G4double  theDefaultValue)

Definition at line 125 of file G4UIparameter.cc.

126 {
127  std::ostringstream os;
128  os << theDefaultValue;
129  defaultValue = os.str();
130 }
G4String defaultValue
Here is the call graph for this function:

◆ SetGuidance()

void G4UIparameter::SetGuidance ( const char *  theGuidance)
inline

Definition at line 138 of file G4UIparameter.hh.

139  { parameterGuidance = theGuidance; }
G4String parameterGuidance
Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetOmittable()

void G4UIparameter::SetOmittable ( G4bool  om)
inline

Definition at line 122 of file G4UIparameter.hh.

Here is the caller graph for this function:

◆ SetParameterCandidates()

void G4UIparameter::SetParameterCandidates ( const char *  theString)
inline

Definition at line 113 of file G4UIparameter.hh.

114  { parameterCandidate = theString; }
G4String parameterCandidate
Here is the caller graph for this function:

◆ SetParameterName()

void G4UIparameter::SetParameterName ( const char *  theName)
inline

Definition at line 107 of file G4UIparameter.hh.

108  { parameterName = theName; }
G4String parameterName
Here is the caller graph for this function:

◆ SetParameterRange()

void G4UIparameter::SetParameterRange ( const char *  theRange)
inline

Definition at line 95 of file G4UIparameter.hh.

96  { parameterRange = theRange; }
G4String parameterRange
Here is the caller graph for this function:

◆ SetWidget()

void G4UIparameter::SetWidget ( G4int  theWidget)
inline

Definition at line 134 of file G4UIparameter.hh.

135  { widget = theWidget; }

◆ TokenToStr()

G4String G4UIparameter::TokenToStr ( G4int  token)
private
Here is the caller graph for this function:

◆ TypeCheck()

G4int G4UIparameter::TypeCheck ( const char *  newValue)
private

Definition at line 191 of file G4UIparameter.cc.

192 {
193  G4String newValueString(newValue);
194  char type = toupper( parameterType );
195  switch(type) {
196  case 'D':
197  if( IsDouble(newValueString.data())== 0) {
198  G4cerr<<newValue<<": double value expected."
199  << G4endl;
200  return 0;
201  } break;
202  case 'I':
203  if( IsInt(newValueString.data(),20)== 0) {
204  G4cerr<<newValue<<": integer expected."
205  << G4endl;
206  return 0;
207  } break;
208  case 'S': break;
209  case 'B':
210  newValueString.toUpper();
211  if ( newValueString == "Y" || newValueString == "N"
212  ||newValueString == "YES" || newValueString == "NO"
213  ||newValueString == "1" || newValueString == "0"
214  ||newValueString == "T" || newValueString == "F"
215  ||newValueString == "TRUE" || newValueString == "FALSE")
216  return 1;
217  else {
218  G4cerr<<newValue<<": bool expected." << G4endl;
219  return 0;
220  }
221  default: ;
222  }
223  return 1;
224 }
G4int IsDouble(const char *str)
#define G4endl
Definition: G4ios.hh:61
G4int IsInt(const char *str, short maxDigit)
G4GLOB_DLL std::ostream G4cerr
Here is the call graph for this function:
Here is the caller graph for this function:

◆ UnaryExpression()

yystype G4UIparameter::UnaryExpression ( void  )
private

Definition at line 485 of file G4UIparameter.cc.

486 {
487  yystype result;
488  yystype p;
489  #ifdef DEBUG
490  G4cerr <<" UnaryExpression"<< G4endl;
491  #endif
492  switch(token) {
493  case '-':
494  token = Yylex();
495  p = UnaryExpression();
496  if (p.type == CONSTINT) {
497  result.I = - p.I;
498  result.type = CONSTINT;
499  }
500  if (p.type == CONSTDOUBLE) {
501  result.D = - p.D;
502  result.type = CONSTDOUBLE;
503  } break;
504  case '+':
505  token = Yylex();
506  result = UnaryExpression(); break;
507  case '!':
508  token = Yylex();
509  G4cerr << "Parameter range error: "
510  << "operator '!' is not supported (sorry)."
511  << G4endl;
512  paramERR = 1;
513  result = UnaryExpression(); break;
514  default:
515  result = PrimaryExpression();
516  }
517  return result;
518 }
yystype UnaryExpression(void)
G4int I
Definition: G4UItokenNum.hh:64
tokenNum type
Definition: G4UItokenNum.hh:62
yystype PrimaryExpression(void)
#define G4endl
Definition: G4ios.hh:61
G4double D
Definition: G4UItokenNum.hh:63
tokenNum Yylex(void)
G4GLOB_DLL std::ostream G4cerr
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Yylex()

tokenNum G4UIparameter::Yylex ( void  )
private

Definition at line 667 of file G4UIparameter.cc.

668 { // (returns EOF)
669  G4int c;
670  G4String buf;
671 
672  while(( c= G4UIpGetc())==' '|| c=='\t' || c== '\n' )
673  ;
674  if (c== EOF)
675  return (tokenNum)EOF; // KR488
676  buf= "";
677  if (isdigit(c) || c== '.') { // I or D
678  do {
679  buf += G4String((unsigned char)c);
680  c=G4UIpGetc();
681  } while (c=='.' || isdigit(c) ||
682  c=='e' || c=='E' || c=='+' || c=='-');
683  G4UIpUngetc(c);
684  const char* t = buf;
685  std::istringstream is(t);
686  if ( IsInt(buf.data(),20) ) {
687  is >> yylval.I;
688  return CONSTINT;
689  } else
690  if ( IsDouble(buf.data()) ) {
691  is >> yylval.D;
692  return CONSTDOUBLE;
693  } else {
694  G4cerr << buf<<": numeric format error."<<G4endl;
695  }
696  }
697  buf="";
698  if (isalpha(c)|| c=='_') { // IDENTIFIER
699  do {
700  buf += G4String((unsigned char)c);
701  } while ((c=G4UIpGetc()) != EOF && (isalnum(c) || c=='_'));
702  G4UIpUngetc(c);
703  if( buf == parameterName ) {
704  yylval.S =buf;
705  return IDENTIFIER;
706  } else {
707  G4cerr << buf << " is not a parameter name."<< G4endl;
708  paramERR = 1;
709  }
710  }
711  switch (c) {
712  case '>': return (tokenNum) Follow('=', GE, GT);
713  case '<': return (tokenNum) Follow('=', LE, LT);
714  case '=': return (tokenNum) Follow('=', EQ, '=');
715  case '!': return (tokenNum) Follow('=', NE, '!');
716  case '|': return (tokenNum) Follow('|', LOGICALOR, '|');
717  case '&': return (tokenNum) Follow('&', LOGICALAND, '&');
718  default:
719  return (tokenNum) c;
720  }
721 }
tokenNum
Definition: G4UItokenNum.hh:36
G4int IsDouble(const char *str)
const char * data() const
Definition: Evaluator.cc:66
Definition: Evaluator.cc:66
G4String S
Definition: G4UItokenNum.hh:66
G4int Follow(G4int expect, G4int ifyes, G4int ifno)
G4String parameterName
Definition: Evaluator.cc:66
Definition: Evaluator.cc:66
int G4int
Definition: G4Types.hh:78
G4int G4UIpUngetc(G4int c)
G4int I
Definition: G4UItokenNum.hh:64
Definition: Evaluator.cc:66
G4int G4UIpGetc(void)
Definition: Evaluator.cc:66
#define G4endl
Definition: G4ios.hh:61
G4double D
Definition: G4UItokenNum.hh:63
G4int IsInt(const char *str, short maxDigit)
G4GLOB_DLL std::ostream G4cerr
Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ bp

G4int G4UIparameter::bp
private

Definition at line 173 of file G4UIparameter.hh.

◆ currentAsDefaultFlag

G4bool G4UIparameter::currentAsDefaultFlag
private

Definition at line 79 of file G4UIparameter.hh.

◆ defaultValue

G4String G4UIparameter::defaultValue
private

Definition at line 74 of file G4UIparameter.hh.

◆ newVal

yystype G4UIparameter::newVal
private

Definition at line 176 of file G4UIparameter.hh.

◆ omittable

G4bool G4UIparameter::omittable
private

Definition at line 78 of file G4UIparameter.hh.

◆ paramERR

G4int G4UIparameter::paramERR
private

Definition at line 177 of file G4UIparameter.hh.

◆ parameterCandidate

G4String G4UIparameter::parameterCandidate
private

Definition at line 76 of file G4UIparameter.hh.

◆ parameterGuidance

G4String G4UIparameter::parameterGuidance
private

Definition at line 73 of file G4UIparameter.hh.

◆ parameterName

G4String G4UIparameter::parameterName
private

Definition at line 72 of file G4UIparameter.hh.

◆ parameterRange

G4String G4UIparameter::parameterRange
private

Definition at line 75 of file G4UIparameter.hh.

◆ parameterType

char G4UIparameter::parameterType
private

Definition at line 77 of file G4UIparameter.hh.

◆ rangeBuf

G4String G4UIparameter::rangeBuf
private

Definition at line 172 of file G4UIparameter.hh.

◆ token

tokenNum G4UIparameter::token
private

Definition at line 174 of file G4UIparameter.hh.

◆ widget

G4int G4UIparameter::widget
private

Definition at line 80 of file G4UIparameter.hh.

◆ yylval

yystype G4UIparameter::yylval
private

Definition at line 175 of file G4UIparameter.hh.


The documentation for this class was generated from the following files: