Geant4  10.02.p03
G4UIcommand Class Reference

#include <G4UIcommand.hh>

Inheritance diagram for G4UIcommand:
Collaboration diagram for G4UIcommand:

Public Member Functions

 G4UIcommand ()
 
 G4UIcommand (const char *theCommandPath, G4UImessenger *theMessenger, G4bool tBB=true)
 
virtual ~G4UIcommand ()
 
G4int operator== (const G4UIcommand &right) const
 
G4int operator!= (const G4UIcommand &right) const
 
virtual G4int DoIt (G4String parameterList)
 
G4String GetCurrentValue ()
 
void AvailableForStates (G4ApplicationState s1)
 
void AvailableForStates (G4ApplicationState s1, G4ApplicationState s2)
 
void AvailableForStates (G4ApplicationState s1, G4ApplicationState s2, G4ApplicationState s3)
 
void AvailableForStates (G4ApplicationState s1, G4ApplicationState s2, G4ApplicationState s3, G4ApplicationState s4)
 
void AvailableForStates (G4ApplicationState s1, G4ApplicationState s2, G4ApplicationState s3, G4ApplicationState s4, G4ApplicationState s5)
 
G4bool IsAvailable ()
 
virtual void List ()
 
void SetRange (const char *rs)
 
const G4StringGetRange () const
 
G4int GetGuidanceEntries () const
 
const G4StringGetGuidanceLine (G4int i) const
 
const G4StringGetCommandPath () const
 
const G4StringGetCommandName () const
 
G4int GetParameterEntries () const
 
G4UIparameterGetParameter (G4int i) const
 
std::vector< G4ApplicationState > * GetStateList ()
 
G4UImessengerGetMessenger () const
 
void SetParameter (G4UIparameter *const newParameter)
 
void SetGuidance (const char *aGuidance)
 
const G4String GetTitle () const
 
void SetToBeBroadcasted (G4bool val)
 
G4bool ToBeBroadcasted () const
 
void SetToBeFlushed (G4bool val)
 
G4bool ToBeFlushed () const
 
void SetWorkerThreadOnly (G4bool val=true)
 
G4bool IsWorkerThreadOnly () const
 

Static Public Member Functions

static G4String ConvertToString (G4bool boolVal)
 
static G4String ConvertToString (G4int intValue)
 
static G4String ConvertToString (G4double doubleValue)
 
static G4String ConvertToString (G4double doubleValue, const char *unitName)
 
static G4String ConvertToString (G4ThreeVector vec)
 
static G4String ConvertToString (G4ThreeVector vec, const char *unitName)
 
static G4bool ConvertToBool (const char *st)
 
static G4int ConvertToInt (const char *st)
 
static G4double ConvertToDouble (const char *st)
 
static G4double ConvertToDimensionedDouble (const char *st)
 
static G4ThreeVector ConvertTo3Vector (const char *st)
 
static G4ThreeVector ConvertToDimensioned3Vector (const char *st)
 
static G4double ValueOf (const char *unitName)
 
static G4String CategoryOf (const char *unitName)
 
static G4String UnitsList (const char *unitCategory)
 

Protected Member Functions

G4int CheckNewValue (const char *newValue)
 

Protected Attributes

G4bool toBeBroadcasted
 
G4bool toBeFlushed
 
G4bool workerThreadOnly
 

Private Member Functions

void G4UIcommandCommonConstructorCode (const char *theCommandPath)
 
G4int TypeCheck (const char *t)
 
G4int RangeCheck (const char *t)
 
G4int IsInt (const char *str, short maxLength)
 
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 (G4double arg1, G4int op, G4double arg2)
 
tokenNum Yylex (void)
 
unsigned IndexOf (const char *)
 
unsigned IsParameter (const char *)
 
G4int G4UIpGetc (void)
 
G4int G4UIpUngetc (G4int c)
 
G4int Backslash (G4int c)
 
G4int Follow (G4int expect, G4int ifyes, G4int ifno)
 
G4String TokenToStr (G4int token)
 
void PrintToken (void)
 

Private Attributes

G4UImessengermessenger
 
G4String commandPath
 
G4String commandName
 
G4String rangeString
 
std::vector< G4UIparameter * > parameter
 
std::vector< G4StringcommandGuidance
 
std::vector< G4ApplicationStateavailabelStateList
 
G4String rangeBuf
 
G4int bp
 
tokenNum token
 
yystype yylval
 
std::vector< yystypenewVal
 
G4int paramERR
 

Detailed Description

Definition at line 51 of file G4UIcommand.hh.

Constructor & Destructor Documentation

◆ G4UIcommand() [1/2]

G4UIcommand::G4UIcommand ( )

Definition at line 41 of file G4UIcommand.cc.

42  : messenger(0), toBeBroadcasted(false), toBeFlushed(false), workerThreadOnly(false),
43  bp(0), token(IDENTIFIER), paramERR(0)
44 {
45 }
G4UImessenger * messenger
Definition: G4UIcommand.hh:116
G4bool toBeFlushed
Definition: G4UIcommand.hh:180
G4int paramERR
Definition: G4UIcommand.hh:237
tokenNum token
Definition: G4UIcommand.hh:234
G4bool workerThreadOnly
Definition: G4UIcommand.hh:181
G4bool toBeBroadcasted
Definition: G4UIcommand.hh:179

◆ G4UIcommand() [2/2]

G4UIcommand::G4UIcommand ( const char *  theCommandPath,
G4UImessenger theMessenger,
G4bool  tBB = true 
)

Definition at line 47 of file G4UIcommand.cc.

49 :messenger(theMessenger),toBeBroadcasted(tBB),toBeFlushed(false), workerThreadOnly(false),
51 {
52  G4String comStr = theCommandPath;
53  if(!theMessenger)
54  { // this must be a directory
55  if(comStr(comStr.length()-1)!='/')
56  {
57  G4cerr << "G4UIcommand Warning : " << G4endl;
58  G4cerr << " <" << theCommandPath << "> must be a directory." << G4endl;
59  G4cerr << " '/' is appended." << G4endl;
60  comStr += "/";
61  }
62  }
64  G4String nullString;
65  availabelStateList.clear();
72 }
G4UImessenger * messenger
Definition: G4UIcommand.hh:116
G4bool toBeFlushed
Definition: G4UIcommand.hh:180
std::vector< G4ApplicationState > availabelStateList
Definition: G4UIcommand.hh:122
G4int paramERR
Definition: G4UIcommand.hh:237
tokenNum token
Definition: G4UIcommand.hh:234
G4bool workerThreadOnly
Definition: G4UIcommand.hh:181
void G4UIcommandCommonConstructorCode(const char *theCommandPath)
Definition: G4UIcommand.cc:79
G4bool toBeBroadcasted
Definition: G4UIcommand.hh:179
#define G4endl
Definition: G4ios.hh:61
G4GLOB_DLL std::ostream G4cerr
Here is the call graph for this function:

◆ ~G4UIcommand()

G4UIcommand::~G4UIcommand ( )
virtual

Definition at line 99 of file G4UIcommand.cc.

100 {
101  G4UImanager* fUImanager = G4UImanager::GetUIpointer();
102  if(fUImanager) fUImanager->RemoveCommand(this);
103 
104  G4int n_parameterEntry = parameter.size();
105  for( G4int i_thParameter=0; i_thParameter < n_parameterEntry; i_thParameter++ )
106  { delete parameter[i_thParameter]; }
107  parameter.clear();
108 }
int G4int
Definition: G4Types.hh:78
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:58
void RemoveCommand(G4UIcommand *aCommand)
Definition: G4UImanager.cc:280
std::vector< G4UIparameter * > parameter
Definition: G4UIcommand.hh:120
Here is the call graph for this function:

Member Function Documentation

◆ AdditiveExpression()

yystype G4UIcommand::AdditiveExpression ( void  )
private

Definition at line 815 of file G4UIcommand.cc.

816 { yystype result;
817  result = MultiplicativeExpression();
818  if( token != '+' && token != '-' ) return result;
819  G4cerr << "Parameter range: operator "
820  << (char)token
821  << " is not supported." << G4endl;
822  paramERR = 1;
823  return result;
824 }
yystype MultiplicativeExpression(void)
Definition: G4UIcommand.cc:827
G4int paramERR
Definition: G4UIcommand.hh:237
tokenNum token
Definition: G4UIcommand.hh:234
#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:

◆ AvailableForStates() [1/5]

void G4UIcommand::AvailableForStates ( G4ApplicationState  s1)

Definition at line 239 of file G4UIcommand.cc.

240 {
241  availabelStateList.clear();
242  availabelStateList.push_back(s1);
243 }
std::vector< G4ApplicationState > availabelStateList
Definition: G4UIcommand.hh:122

◆ AvailableForStates() [2/5]

void G4UIcommand::AvailableForStates ( G4ApplicationState  s1,
G4ApplicationState  s2 
)

Definition at line 245 of file G4UIcommand.cc.

247 {
248  availabelStateList.clear();
249  availabelStateList.push_back(s1);
250  availabelStateList.push_back(s2);
251 }
std::vector< G4ApplicationState > availabelStateList
Definition: G4UIcommand.hh:122

◆ AvailableForStates() [3/5]

void G4UIcommand::AvailableForStates ( G4ApplicationState  s1,
G4ApplicationState  s2,
G4ApplicationState  s3 
)

Definition at line 253 of file G4UIcommand.cc.

256 {
257  availabelStateList.clear();
258  availabelStateList.push_back(s1);
259  availabelStateList.push_back(s2);
260  availabelStateList.push_back(s3);
261 }
std::vector< G4ApplicationState > availabelStateList
Definition: G4UIcommand.hh:122

◆ AvailableForStates() [4/5]

void G4UIcommand::AvailableForStates ( G4ApplicationState  s1,
G4ApplicationState  s2,
G4ApplicationState  s3,
G4ApplicationState  s4 
)

Definition at line 263 of file G4UIcommand.cc.

267 {
268  availabelStateList.clear();
269  availabelStateList.push_back(s1);
270  availabelStateList.push_back(s2);
271  availabelStateList.push_back(s3);
272  availabelStateList.push_back(s4);
273 }
std::vector< G4ApplicationState > availabelStateList
Definition: G4UIcommand.hh:122

◆ AvailableForStates() [5/5]

void G4UIcommand::AvailableForStates ( G4ApplicationState  s1,
G4ApplicationState  s2,
G4ApplicationState  s3,
G4ApplicationState  s4,
G4ApplicationState  s5 
)

Definition at line 275 of file G4UIcommand.cc.

280 {
281  availabelStateList.clear();
282  availabelStateList.push_back(s1);
283  availabelStateList.push_back(s2);
284  availabelStateList.push_back(s3);
285  availabelStateList.push_back(s4);
286  availabelStateList.push_back(s5);
287 }
std::vector< G4ApplicationState > availabelStateList
Definition: G4UIcommand.hh:122

◆ Backslash()

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

◆ CategoryOf()

G4String G4UIcommand::CategoryOf ( const char *  unitName)
static

Definition at line 315 of file G4UIcommand.cc.

316 {
317  return G4UnitDefinition::GetCategory(unitName);
318 }
static G4String GetCategory(const G4String &)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ CheckNewValue()

G4int G4UIcommand::CheckNewValue ( const char *  newValue)
protected

Definition at line 496 of file G4UIcommand.cc.

497 {
498  yystype result;
499  // if( TypeCheck(newValue) == 0 ) return 1;
500  if( ! rangeString.isNull() )
501  { if( RangeCheck(newValue) == 0 ) return fParameterOutOfRange; }
502  return 0; // succeeded
503 }
G4String rangeString
Definition: G4UIcommand.hh:119
G4int RangeCheck(const char *t)
Definition: G4UIcommand.cc:642
G4bool isNull() const
Here is the call graph for this function:
Here is the caller graph for this function:

◆ CompareDouble()

G4int G4UIcommand::CompareDouble ( G4double  arg1,
G4int  op,
G4double  arg2 
)
private

Definition at line 996 of file G4UIcommand.cc.

997 {
998  G4int result=-1;
999  G4String opr;
1000  switch (op) {
1001  case GT: result = ( arg1 > arg2); opr= ">"; break;
1002  case GE: result = ( arg1 >= arg2); opr= ">="; break;
1003  case LT: result = ( arg1 < arg2); opr= "<"; break;
1004  case LE: result = ( arg1 <= arg2); opr= "<="; break;
1005  case EQ: result = ( arg1 == arg2); opr= "=="; break;
1006  case NE: result = ( arg1 != arg2); opr= "!="; break;
1007  default:
1008  G4cerr << "Parameter range: error at CompareDouble"
1009  << G4endl;
1010  paramERR = 1;
1011  }
1012  #ifdef DEBUG
1013  G4cerr << "CompareDouble "
1014  << arg1 <<" " << opr << " "<< arg2
1015  << " result: " << result
1016  << G4endl;
1017  #endif
1018  return result;
1019 }
Definition: Evaluator.cc:66
Definition: Evaluator.cc:66
Definition: Evaluator.cc:66
Definition: Evaluator.cc:66
int G4int
Definition: G4Types.hh:78
G4int paramERR
Definition: G4UIcommand.hh:237
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 G4UIcommand::CompareInt ( G4int  arg1,
G4int  op,
G4int  arg2 
)
private

Definition at line 971 of file G4UIcommand.cc.

972 {
973  G4int result=-1;
974  G4String opr;
975  switch (op) {
976  case GT: result = ( arg1 > arg2); opr= ">" ; break;
977  case GE: result = ( arg1 >= arg2); opr= ">="; break;
978  case LT: result = ( arg1 < arg2); opr= "<" ; break;
979  case LE: result = ( arg1 <= arg2); opr= "<="; break;
980  case EQ: result = ( arg1 == arg2); opr= "=="; break;
981  case NE: result = ( arg1 != arg2); opr= "!="; break;
982  default:
983  G4cerr << "Parameter range: error at CompareInt" << G4endl;
984  paramERR = 1;
985  }
986  #ifdef DEBUG
987  G4cerr << "CompareInt "
988  << arg1 << " " << opr << arg2
989  << " result: " << result
990  << G4endl;
991  #endif
992  return result;
993 }
Definition: Evaluator.cc:66
Definition: Evaluator.cc:66
Definition: Evaluator.cc:66
Definition: Evaluator.cc:66
int G4int
Definition: G4Types.hh:78
G4int paramERR
Definition: G4UIcommand.hh:237
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:

◆ ConvertTo3Vector()

G4ThreeVector G4UIcommand::ConvertTo3Vector ( const char *  st)
static

Definition at line 463 of file G4UIcommand.cc.

464 {
465  G4double vx;
466  G4double vy;
467  G4double vz;
468  std::istringstream is(st);
469  is >> vx >> vy >> vz;
470  return G4ThreeVector(vx,vy,vz);
471 }
CLHEP::Hep3Vector G4ThreeVector
double G4double
Definition: G4Types.hh:76
Here is the caller graph for this function:

◆ ConvertToBool()

G4bool G4UIcommand::ConvertToBool ( const char *  st)
static

Definition at line 425 of file G4UIcommand.cc.

426 {
427  G4String v = st;
428  v.toUpper();
429  G4bool vl = false;
430  if( v=="Y" || v=="YES" || v=="1" || v=="T" || v=="TRUE" )
431  { vl = true; }
432  return vl;
433 }
void toUpper()
bool G4bool
Definition: G4Types.hh:79
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ConvertToDimensioned3Vector()

G4ThreeVector G4UIcommand::ConvertToDimensioned3Vector ( const char *  st)
static

Definition at line 473 of file G4UIcommand.cc.

474 {
475  G4double vx;
476  G4double vy;
477  G4double vz;
478  char unts[30];
479  std::istringstream is(st);
480  is >> vx >> vy >> vz >> unts;
481  G4String unt = unts;
482  G4double uv = ValueOf(unt);
483  return G4ThreeVector(vx*uv,vy*uv,vz*uv);
484 }
CLHEP::Hep3Vector G4ThreeVector
static G4double ValueOf(const char *unitName)
Definition: G4UIcommand.cc:308
double G4double
Definition: G4Types.hh:76
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ConvertToDimensionedDouble()

G4double G4UIcommand::ConvertToDimensionedDouble ( const char *  st)
static

Definition at line 451 of file G4UIcommand.cc.

452 {
453  G4double vl;
454  char unts[30];
455 
456  std::istringstream is(st);
457  is >> vl >> unts;
458  G4String unt = unts;
459 
460  return (vl*ValueOf(unt));
461 }
static G4double ValueOf(const char *unitName)
Definition: G4UIcommand.cc:308
double G4double
Definition: G4Types.hh:76
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ConvertToDouble()

G4double G4UIcommand::ConvertToDouble ( const char *  st)
static

Definition at line 443 of file G4UIcommand.cc.

444 {
445  G4double vl;
446  std::istringstream is(st);
447  is >> vl;
448  return vl;
449 }
double G4double
Definition: G4Types.hh:76
Here is the caller graph for this function:

◆ ConvertToInt()

G4int G4UIcommand::ConvertToInt ( const char *  st)
static

Definition at line 435 of file G4UIcommand.cc.

436 {
437  G4int vl;
438  std::istringstream is(st);
439  is >> vl;
440  return vl;
441 }
int G4int
Definition: G4Types.hh:78
Here is the caller graph for this function:

◆ ConvertToString() [1/6]

G4String G4UIcommand::ConvertToString ( G4bool  boolVal)
static

Definition at line 371 of file G4UIcommand.cc.

372 {
373  G4String vl = "0";
374  if(boolVal) vl = "1";
375  return vl;
376 }

◆ ConvertToString() [2/6]

G4String G4UIcommand::ConvertToString ( G4int  intValue)
static

Definition at line 378 of file G4UIcommand.cc.

379 {
380  std::ostringstream os;
381  os << intValue;
382  G4String vl = os.str();
383  return vl;
384 }

◆ ConvertToString() [3/6]

G4String G4UIcommand::ConvertToString ( G4double  doubleValue)
static

Definition at line 386 of file G4UIcommand.cc.

387 {
388  std::ostringstream os;
389  os << doubleValue;
390  G4String vl = os.str();
391  return vl;
392 }

◆ ConvertToString() [4/6]

G4String G4UIcommand::ConvertToString ( G4double  doubleValue,
const char *  unitName 
)
static

Definition at line 394 of file G4UIcommand.cc.

395 {
396  G4String unt = unitName;
397  G4double uv = ValueOf(unitName);
398 
399  std::ostringstream os;
400  os << doubleValue/uv << " " << unitName;
401  G4String vl = os.str();
402  return vl;
403 }
static G4double ValueOf(const char *unitName)
Definition: G4UIcommand.cc:308
double G4double
Definition: G4Types.hh:76
Here is the call graph for this function:

◆ ConvertToString() [5/6]

G4String G4UIcommand::ConvertToString ( G4ThreeVector  vec)
static

Definition at line 405 of file G4UIcommand.cc.

406 {
407  std::ostringstream os;
408  os << vec.x() << " " << vec.y() << " " << vec.z();
409  G4String vl = os.str();
410  return vl;
411 }
double x() const
double y() const
double z() const
Here is the call graph for this function:

◆ ConvertToString() [6/6]

G4String G4UIcommand::ConvertToString ( G4ThreeVector  vec,
const char *  unitName 
)
static

Definition at line 413 of file G4UIcommand.cc.

414 {
415  G4String unt = unitName;
416  G4double uv = ValueOf(unitName);
417 
418  std::ostringstream os;
419  os << vec.x()/uv << " " << vec.y()/uv << " " << vec.z()/uv
420  << " " << unitName;
421  G4String vl = os.str();
422  return vl;
423 }
double x() const
double y() const
static G4double ValueOf(const char *unitName)
Definition: G4UIcommand.cc:308
double z() const
double G4double
Definition: G4Types.hh:76
Here is the call graph for this function:

◆ DoIt()

G4int G4UIcommand::DoIt ( G4String  parameterList)
virtual

Reimplemented in G4UIcmdWith3VectorAndUnit, and G4UIcmdWithADoubleAndUnit.

Definition at line 122 of file G4UIcommand.cc.

123 {
124  G4String correctParameters;
125  G4int n_parameterEntry = parameter.size();
126  if( n_parameterEntry != 0 )
127  {
128  G4String aToken;
129  G4String correctToken;
130  G4Tokenizer parameterToken( parameterList );
131  for( G4int i_thParameter=0; i_thParameter<n_parameterEntry; i_thParameter++ )
132  {
133  if(i_thParameter > 0)
134  {
135  correctParameters.append(" ");
136  }
137  aToken = parameterToken();
138  if( aToken.length()>0 && aToken(0)=='"' )
139  {
140  while( aToken(aToken.length()-1) != '"'
141  || ( aToken.length()==1 && aToken(0)=='"' ))
142  {
143  G4String additionalToken = parameterToken();
144  if( additionalToken.isNull() )
145  { return fParameterUnreadable+i_thParameter; }
146  aToken += " ";
147  aToken += additionalToken;
148  }
149  }
150  else if(i_thParameter==n_parameterEntry-1 && parameter[i_thParameter]->GetParameterType()=='s')
151  {
152  G4String anotherToken;
153  while(!((anotherToken=parameterToken()).isNull()))
154  {
155  G4int idxs = anotherToken.index("#");
156  if(idxs==G4int(std::string::npos))
157  {
158  aToken += " ";
159  aToken += anotherToken;
160  }
161  else if(idxs>0)
162  {
163  aToken += " ";
164  aToken += anotherToken(0,idxs);
165  break;
166  }
167  else
168  { break; }
169  }
170  }
171 
172  if( aToken.isNull() || aToken == "!" )
173  {
174  if(parameter[i_thParameter]->IsOmittable())
175  {
176  if(parameter[i_thParameter]->GetCurrentAsDefault())
177  {
179  G4String parVal;
180  for(G4int ii=0;ii<i_thParameter;ii++)
181  {
182  parVal = cvSt();
183  if (parVal(0)=='"')
184  {
185  while( parVal(parVal.length()-1) != '"' )
186  {
187  G4String additionalToken = cvSt();
188  if( additionalToken.isNull() )
189  { return fParameterUnreadable+i_thParameter; }
190  parVal += " ";
191  parVal += additionalToken;
192  }
193  }
194  }
195  G4String aCVToken = cvSt();
196  if (aCVToken(0)=='"')
197  {
198  while( aCVToken(aCVToken.length()-1) != '"' )
199  {
200  G4String additionalToken = cvSt();
201  if( additionalToken.isNull() )
202  { return fParameterUnreadable+i_thParameter; }
203  aCVToken += " ";
204  aCVToken += additionalToken;
205  }
206  // aCVToken.strip(G4String::both,'"');
207  }
208  correctParameters.append(aCVToken);
209  }
210  else
211  { correctParameters.append(parameter[i_thParameter]->GetDefaultValue()); }
212  }
213  else
214  { return fParameterUnreadable+i_thParameter; }
215  }
216  else
217  {
218  G4int stat = parameter[i_thParameter]->CheckNewValue( aToken );
219  if(stat) return stat+i_thParameter;
220  correctParameters.append(aToken);
221  }
222  }
223  }
224 
225  if(CheckNewValue( correctParameters ))
226  { return fParameterOutOfRange+99; }
227 
229 
230  messenger->SetNewValue( this, correctParameters );
231  return 0;
232 }
G4UImessenger * messenger
Definition: G4UIcommand.hh:116
virtual G4String GetCurrentValue(G4UIcommand *command)
virtual void SetNewValue(G4UIcommand *command, G4String newValue)
str_size index(const char *, G4int pos=0) const
int G4int
Definition: G4Types.hh:78
G4bool workerThreadOnly
Definition: G4UIcommand.hh:181
G4int CheckNewValue(const char *newValue)
Definition: G4UIcommand.cc:496
G4String & append(const G4String &)
G4bool IsMasterThread()
Definition: G4Threading.cc:136
std::vector< G4UIparameter * > parameter
Definition: G4UIcommand.hh:120
G4bool isNull() const
Here is the call graph for this function:
Here is the caller graph for this function:

◆ EqualityExpression()

yystype G4UIcommand::EqualityExpression ( void  )
private

Definition at line 755 of file G4UIcommand.cc.

756 {
757  yystype arg1, arg2;
758  G4int operat;
759  yystype result;
760  #ifdef DEBUG
761  G4cerr << " EqualityExpression()" <<G4endl;
762  #endif
763  result = RelationalExpression();
764  if( token==EQ || token==NE ) {
765  operat = token;
766  token = Yylex();
767  arg1 = result;
768  arg2 = RelationalExpression();
769  result.I = Eval2( arg1, operat, arg2 ); // semantic action
770  result.type = CONSTINT;
771  #ifdef DEBUG
772  G4cerr << " return code of Eval2(): " << result.I <<G4endl;
773  #endif
774  } else {
775  if (result.type != CONSTINT && result.type != CONSTDOUBLE) {
776  G4cerr << "Parameter range: error at EqualityExpression"
777  << G4endl;
778  paramERR = 1;
779  }
780  }
781  return result;
782 }
G4int Eval2(yystype arg1, G4int op, yystype arg2)
Definition: G4UIcommand.cc:913
Definition: Evaluator.cc:66
tokenNum Yylex(void)
Definition: Evaluator.cc:66
int G4int
Definition: G4Types.hh:78
G4int paramERR
Definition: G4UIcommand.hh:237
tokenNum token
Definition: G4UIcommand.hh:234
G4int I
Definition: G4UItokenNum.hh:64
tokenNum type
Definition: G4UItokenNum.hh:62
yystype RelationalExpression(void)
Definition: G4UIcommand.cc:786
#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:

◆ Eval2()

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

Definition at line 913 of file G4UIcommand.cc.

914 {
915  char newValtype;
916  if( (arg1.type != IDENTIFIER) && (arg2.type != IDENTIFIER)) {
918  << ": meaningless comparison"
919  << G4endl;
920  paramERR = 1;
921  }
922 
923  if( arg1.type == IDENTIFIER) {
924  unsigned i = IndexOf( arg1.S );
925  newValtype = toupper(parameter[i]->GetParameterType());
926  switch ( newValtype ) {
927  case 'I':
928  if( arg2.type == CONSTINT ) {
929  return CompareInt( newVal[i].I, op, arg2.I );
930  } else {
931  G4cerr << "integer operand expected for "
932  << rangeString
933  << '.' << G4endl;
934  } break;
935  case 'D':
936  if( arg2.type == CONSTDOUBLE ) {
937  return CompareDouble( newVal[i].D, op, arg2.D );
938  } else
939  if ( arg2.type == CONSTINT ) { // integral promotion
940  return CompareDouble( newVal[i].D, op, arg2.I );
941  } break;
942  default: ;
943  }
944  }
945  if( arg2.type == IDENTIFIER) {
946  unsigned i = IndexOf( arg2.S );
947  newValtype = toupper(parameter[i]->GetParameterType());
948  switch ( newValtype ) {
949  case 'I':
950  if( arg1.type == CONSTINT ) {
951  return CompareInt( arg1.I, op, newVal[i].I );
952  } else {
953  G4cerr << "integer operand expected for "
954  << rangeString
955  << '.' << G4endl;
956  } break;
957  case 'D':
958  if( arg1.type == CONSTDOUBLE ) {
959  return CompareDouble( arg1.D, op, newVal[i].D );
960  } else
961  if ( arg1.type == CONSTINT ) { // integral promotion
962  return CompareDouble( arg1.I, op, newVal[i].D );
963  } break;
964  default: ;
965  }
966  }
967  return 0;
968 }
std::vector< yystype > newVal
Definition: G4UIcommand.hh:236
G4String commandName
Definition: G4UIcommand.hh:118
G4String S
Definition: G4UItokenNum.hh:66
unsigned IndexOf(const char *)
G4int CompareDouble(G4double arg1, G4int op, G4double arg2)
Definition: G4UIcommand.cc:996
G4String rangeString
Definition: G4UIcommand.hh:119
G4int paramERR
Definition: G4UIcommand.hh:237
G4int I
Definition: G4UItokenNum.hh:64
tokenNum type
Definition: G4UItokenNum.hh:62
double D(double temp)
#define G4endl
Definition: G4ios.hh:61
G4double D
Definition: G4UItokenNum.hh:63
std::vector< G4UIparameter * > parameter
Definition: G4UIcommand.hh:120
G4int CompareInt(G4int arg1, G4int op, G4int arg2)
Definition: G4UIcommand.cc:971
G4GLOB_DLL std::ostream G4cerr
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ExpectExponent()

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

Definition at line 573 of file G4UIcommand.cc.

574 {
575  G4int maxExplength;
576  if( IsInt( str, maxExplength=7 )) return 1;
577  else return 0;
578 }
G4int IsInt(const char *str, short maxLength)
Definition: G4UIcommand.cc:549
int G4int
Definition: G4Types.hh:78
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Expression()

yystype G4UIcommand::Expression ( void  )
private

Definition at line 673 of file G4UIcommand.cc.

674 {
675  yystype result;
676  #ifdef DEBUG
677  G4cerr << " Expression()" << G4endl;
678  #endif
679  result = LogicalORExpression();
680  return result;
681 }
yystype LogicalORExpression(void)
Definition: G4UIcommand.cc:684
#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:

◆ Follow()

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

Definition at line 1113 of file G4UIcommand.cc.

1114 {
1115  G4int c = G4UIpGetc();
1116  if ( c== expect)
1117  return ifyes;
1118  G4UIpUngetc(c);
1119  return ifno;
1120 }
G4int G4UIpGetc(void)
int G4int
Definition: G4Types.hh:78
G4int G4UIpUngetc(G4int c)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ G4UIcommandCommonConstructorCode()

void G4UIcommand::G4UIcommandCommonConstructorCode ( const char *  theCommandPath)
private

Definition at line 79 of file G4UIcommand.cc.

80 {
81  commandPath = theCommandPath;
82  commandName = theCommandPath;
83  G4int commandNameIndex = commandName.last('/');
84  commandName.remove(0,commandNameIndex+1);
85 #ifdef G4MULTITHREADED
88  {
89  toBeBroadcasted = false;
91  }
92  else
94 #else
96 #endif
97 }
G4UImessenger * messenger
Definition: G4UIcommand.hh:116
G4String commandName
Definition: G4UIcommand.hh:118
static G4UImanager * GetMasterUIpointer()
Definition: G4UImanager.cc:71
G4String & remove(str_size)
int G4int
Definition: G4Types.hh:78
G4bool CommandsShouldBeInMaster() const
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:58
G4bool toBeBroadcasted
Definition: G4UIcommand.hh:179
G4bool IsWorkerThread()
Definition: G4Threading.cc:135
void AddNewCommand(G4UIcommand *newCommand)
Definition: G4UImanager.cc:268
G4String commandPath
Definition: G4UIcommand.hh:117
G4int last(char) const
Here is the call graph for this function:
Here is the caller graph for this function:

◆ G4UIpGetc()

G4int G4UIcommand::G4UIpGetc ( void  )
private

Definition at line 1124 of file G4UIcommand.cc.

1124  { // emulation of getc()
1125  G4int length = rangeString.length();
1126  if( bp < length)
1127  return rangeString(bp++);
1128  else
1129  return EOF;
1130 }
G4String rangeString
Definition: G4UIcommand.hh:119
int G4int
Definition: G4Types.hh:78
Here is the call graph for this function:
Here is the caller graph for this function:

◆ G4UIpUngetc()

G4int G4UIcommand::G4UIpUngetc ( G4int  c)
private

Definition at line 1132 of file G4UIcommand.cc.

1132  { // emulation of ungetc()
1133  if (c<0) return -1;
1134  if (bp >0 && c == rangeString(bp-1)) {
1135  --bp;
1136  } else {
1137  G4cerr << "G4UIpUngetc() failed." << G4endl;
1138  G4cerr << "bp="<<bp <<" c="<<c
1139  << " pR(bp-1)=" << rangeString(bp-1)
1140  << G4endl;
1141  paramERR = 1;
1142  return -1;
1143  }
1144  return 0;
1145 }
G4String rangeString
Definition: G4UIcommand.hh:119
G4int paramERR
Definition: G4UIcommand.hh:237
#define G4endl
Definition: G4ios.hh:61
G4GLOB_DLL std::ostream G4cerr
Here is the caller graph for this function:

◆ GetCommandName()

const G4String& G4UIcommand::GetCommandName ( ) const
inline

Definition at line 141 of file G4UIcommand.hh.

142  { return commandName; }
G4String commandName
Definition: G4UIcommand.hh:118
Here is the caller graph for this function:

◆ GetCommandPath()

const G4String& G4UIcommand::GetCommandPath ( ) const
inline

Definition at line 139 of file G4UIcommand.hh.

140  { return commandPath; }
G4String commandPath
Definition: G4UIcommand.hh:117
Here is the caller graph for this function:

◆ GetCurrentValue()

G4String G4UIcommand::GetCurrentValue ( )

Definition at line 234 of file G4UIcommand.cc.

235 {
236  return messenger->GetCurrentValue(this);
237 }
G4UImessenger * messenger
Definition: G4UIcommand.hh:116
virtual G4String GetCurrentValue(G4UIcommand *command)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetGuidanceEntries()

G4int G4UIcommand::GetGuidanceEntries ( ) const
inline

Definition at line 135 of file G4UIcommand.hh.

136  { return commandGuidance.size(); }
std::vector< G4String > commandGuidance
Definition: G4UIcommand.hh:121
Here is the caller graph for this function:

◆ GetGuidanceLine()

const G4String& G4UIcommand::GetGuidanceLine ( G4int  i) const
inline

Definition at line 137 of file G4UIcommand.hh.

138  { return commandGuidance[i]; }
std::vector< G4String > commandGuidance
Definition: G4UIcommand.hh:121
Here is the caller graph for this function:

◆ GetMessenger()

G4UImessenger* G4UIcommand::GetMessenger ( ) const
inline

Definition at line 149 of file G4UIcommand.hh.

150  { return messenger; }
G4UImessenger * messenger
Definition: G4UIcommand.hh:116

◆ GetParameter()

G4UIparameter* G4UIcommand::GetParameter ( G4int  i) const
inline

Definition at line 145 of file G4UIcommand.hh.

146  { return parameter[i]; }
std::vector< G4UIparameter * > parameter
Definition: G4UIcommand.hh:120
Here is the caller graph for this function:

◆ GetParameterEntries()

G4int G4UIcommand::GetParameterEntries ( ) const
inline

Definition at line 143 of file G4UIcommand.hh.

144  { return parameter.size(); }
std::vector< G4UIparameter * > parameter
Definition: G4UIcommand.hh:120
Here is the caller graph for this function:

◆ GetRange()

const G4String& G4UIcommand::GetRange ( ) const
inline

Definition at line 133 of file G4UIcommand.hh.

134  { return rangeString; };
G4String rangeString
Definition: G4UIcommand.hh:119
Here is the caller graph for this function:

◆ GetStateList()

std::vector<G4ApplicationState>* G4UIcommand::GetStateList ( )
inline

Definition at line 147 of file G4UIcommand.hh.

148  { return &availabelStateList; }
std::vector< G4ApplicationState > availabelStateList
Definition: G4UIcommand.hh:122
Here is the caller graph for this function:

◆ GetTitle()

const G4String G4UIcommand::GetTitle ( ) const
inline

Definition at line 170 of file G4UIcommand.hh.

171  {
172  if(commandGuidance.size() == 0)
173  { return G4String("...Title not available..."); }
174  else
175  { return commandGuidance[0]; }
176  }
std::vector< G4String > commandGuidance
Definition: G4UIcommand.hh:121
Here is the caller graph for this function:

◆ IndexOf()

unsigned G4UIcommand::IndexOf ( const char *  nam)
private

Definition at line 1022 of file G4UIcommand.cc.

1023 {
1024  unsigned i;
1025  G4String pname;
1026  for( i=0; i<parameter.size(); i++)
1027  {
1028  pname = parameter[i]-> GetParameterName();
1029  if( pname == nam ) {
1030  return i;
1031  }
1032  }
1033  paramERR = 1;
1034  G4cerr << "parameter name:"<<nam<<" not found."<< G4endl;
1035  return 0;
1036 }
G4int paramERR
Definition: G4UIcommand.hh:237
string pname
Definition: eplot.py:33
#define G4endl
Definition: G4ios.hh:61
std::vector< G4UIparameter * > parameter
Definition: G4UIcommand.hh:120
G4GLOB_DLL std::ostream G4cerr
Here is the call graph for this function:
Here is the caller graph for this function:

◆ IsAvailable()

G4bool G4UIcommand::IsAvailable ( )

Definition at line 289 of file G4UIcommand.cc.

290 {
291  G4bool av = false;
292  G4ApplicationState currentState
294 
295  G4int nState = availabelStateList.size();
296  for(G4int i=0;i<nState;i++)
297  {
298  if(availabelStateList[i]==currentState)
299  {
300  av = true;
301  break;
302  }
303  }
304 
305  return av;
306 }
std::vector< G4ApplicationState > availabelStateList
Definition: G4UIcommand.hh:122
int G4int
Definition: G4Types.hh:78
static G4StateManager * GetStateManager()
bool G4bool
Definition: G4Types.hh:79
G4ApplicationState GetCurrentState() const
G4ApplicationState
Here is the call graph for this function:
Here is the caller graph for this function:

◆ IsDouble()

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

Definition at line 582 of file G4UIcommand.cc.

583 {
584  const char* p= buf;
585  switch( *p) {
586  case '+': case '-': ++p;
587  if( isdigit(*p) ) {
588  while( isdigit( (G4int)(*p) )) { ++p; }
589  switch ( *p ) {
590  case '\0': return 1;
591  // break;
592  case 'E': case 'e':
593  return ExpectExponent(++p );
594  // break;
595  case '.': ++p;
596  if( *p == '\0' ) return 1;
597  if( *p == 'e' || *p =='E' ) return ExpectExponent(++p );
598  if( isdigit(*p) ) {
599  while( isdigit( (G4int)(*p) )) { ++p; }
600  if( *p == '\0' ) return 1;
601  if( *p == 'e' || *p =='E') return ExpectExponent(++p);
602  } else return 0; break;
603  default: return 0;
604  }
605  }
606  if( *p == '.' ) { ++p;
607  if( isdigit(*p) ) {
608  while( isdigit( (G4int)(*p) )) { ++p; }
609  if( *p == '\0' ) return 1;
610  if( *p == 'e' || *p =='E') return ExpectExponent(++p);
611  }
612  }
613  break;
614  case '.': ++p;
615  if( isdigit(*p) ) {
616  while( isdigit( (G4int)(*p) )) { ++p; }
617  if( *p == '\0' ) return 1;
618  if( *p == 'e' || *p =='E' ) return ExpectExponent(++p);
619  } break;
620  default: // digit is expected
621  if( isdigit(*p) ) {
622  while( isdigit( (G4int)(*p) )) { ++p; }
623  if( *p == '\0' ) return 1;
624  if( *p == 'e' || *p =='E') return ExpectExponent(++p);
625  if( *p == '.' ) { ++p;
626  if( *p == '\0' ) return 1;
627  if( *p == 'e' || *p =='E') return ExpectExponent(++p);
628  if( isdigit(*p) ) {
629  while( isdigit( (G4int)(*p) )) { ++p; }
630  if( *p == '\0' ) return 1;
631  if( *p == 'e' || *p =='E') return ExpectExponent(++p);
632  }
633  }
634  }
635  }
636  return 0;
637 }
int G4int
Definition: G4Types.hh:78
G4int ExpectExponent(const char *str)
Definition: G4UIcommand.cc:573
Here is the call graph for this function:
Here is the caller graph for this function:

◆ IsInt()

G4int G4UIcommand::IsInt ( const char *  str,
short  maxLength 
)
private

Definition at line 549 of file G4UIcommand.cc.

550 {
551  const char* p= buf;
552  G4int length=0;
553  if( *p == '+' || *p == '-') { ++p; }
554  if( isdigit( (G4int)(*p) )) {
555  while( isdigit( (G4int)(*p) )) { ++p; ++length; }
556  if( *p == '\0' ) {
557  if( length > maxDigits) {
558  G4cerr <<"digit length exceeds"<<G4endl;
559  return 0;
560  }
561  return 1;
562  } else {
563  // G4cerr <<"illegal character after int:"<<buf<<G4endl;
564  }
565  } else {
566  // G4cerr <<"illegal int:"<<buf<<G4endl;
567  }
568  return 0;
569 }
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:

◆ IsParameter()

unsigned G4UIcommand::IsParameter ( const char *  nam)
private

Definition at line 1040 of file G4UIcommand.cc.

1041 {
1042  G4String pname;
1043  for(unsigned i=0; i<parameter.size(); i++)
1044  {
1045  pname = parameter[i]-> GetParameterName();
1046  if( pname == nam ) return 1;
1047  }
1048  return 0;
1049 }
string pname
Definition: eplot.py:33
std::vector< G4UIparameter * > parameter
Definition: G4UIcommand.hh:120
Here is the call graph for this function:
Here is the caller graph for this function:

◆ IsWorkerThreadOnly()

G4bool G4UIcommand::IsWorkerThreadOnly ( ) const
inline

Definition at line 194 of file G4UIcommand.hh.

195  { return workerThreadOnly; }
G4bool workerThreadOnly
Definition: G4UIcommand.hh:181
Here is the call graph for this function:
Here is the caller graph for this function:

◆ List()

void G4UIcommand::List ( )
virtual

Definition at line 348 of file G4UIcommand.cc.

349 {
350  G4cout << G4endl;
351  G4cout << G4endl;
352  if(commandPath(commandPath.length()-1)!='/')
353  { G4cout << "Command " << commandPath << G4endl; }
354  if(workerThreadOnly)
355  { G4cout << " ---- available only in worker thread" << G4endl; }
356  G4cout << "Guidance :" << G4endl;
357  G4int n_guidanceEntry = commandGuidance.size();
358  for( G4int i_thGuidance=0; i_thGuidance < n_guidanceEntry; i_thGuidance++ )
359  { G4cout << commandGuidance[i_thGuidance] << G4endl; }
360  if( ! rangeString.isNull() )
361  { G4cout << " Range of parameters : " << rangeString << G4endl; }
362  G4int n_parameterEntry = parameter.size();
363  if( n_parameterEntry > 0 )
364  {
365  for( G4int i_thParameter=0; i_thParameter<n_parameterEntry; i_thParameter++ )
366  { parameter[i_thParameter]->List(); }
367  }
368  G4cout << G4endl;
369 }
G4String rangeString
Definition: G4UIcommand.hh:119
int G4int
Definition: G4Types.hh:78
G4GLOB_DLL std::ostream G4cout
G4bool workerThreadOnly
Definition: G4UIcommand.hh:181
#define G4endl
Definition: G4ios.hh:61
G4String commandPath
Definition: G4UIcommand.hh:117
std::vector< G4String > commandGuidance
Definition: G4UIcommand.hh:121
std::vector< G4UIparameter * > parameter
Definition: G4UIcommand.hh:120
G4bool isNull() const
Here is the call graph for this function:
Here is the caller graph for this function:

◆ LogicalANDExpression()

yystype G4UIcommand::LogicalANDExpression ( void  )
private

Definition at line 719 of file G4UIcommand.cc.

720 {
721  yystype result;
722  yystype p;
723  p = EqualityExpression();
724  if( token != LOGICALAND) return p;
725  if( p.type == CONSTSTRING || p.type == IDENTIFIER ) {
726  G4cerr << "Parameter range: illegal type at '&&'" << G4endl;
727  paramERR = 1;
728  }
729  result.I = p.I;
730  while (token == LOGICALAND)
731  {
732  token = Yylex();
733  p = EqualityExpression();
734  if( p.type == CONSTSTRING || p.type == IDENTIFIER ) {
735  G4cerr << "Parameter range: illegal type at '&&'" << G4endl;
736  paramERR = 1;
737  }
738  switch (p.type) {
739  case CONSTINT:
740  result.I *= p.I;
741  result.type = CONSTINT; break;
742  case CONSTDOUBLE:
743  result.I *= (p.D != 0.0);
744  result.type = CONSTINT; break;
745  default:
746  G4cerr << "Parameter range: unknown type."<< G4endl;
747  paramERR = 1;
748  }
749  }
750  return result;
751 }
tokenNum Yylex(void)
G4int paramERR
Definition: G4UIcommand.hh:237
tokenNum token
Definition: G4UIcommand.hh:234
G4int I
Definition: G4UItokenNum.hh:64
tokenNum type
Definition: G4UItokenNum.hh:62
yystype EqualityExpression(void)
Definition: G4UIcommand.cc:755
#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:

◆ LogicalORExpression()

yystype G4UIcommand::LogicalORExpression ( void  )
private

Definition at line 684 of file G4UIcommand.cc.

685 {
686  yystype result;
687  yystype p;
688  p = LogicalANDExpression();
689  if( token != LOGICALOR) return p;
690  if( p.type == CONSTSTRING || p.type == IDENTIFIER ) {
691  G4cerr << "Parameter range: illegal type at '||'" << G4endl;
692  paramERR = 1;
693  }
694  result.I = p.I;
695  while (token == LOGICALOR)
696  {
697  token = Yylex();
698  p = LogicalANDExpression();
699  if( p.type == CONSTSTRING || p.type == IDENTIFIER ) {
700  G4cerr << "Parameter range: illegal type at '||'" <<G4endl;
701  paramERR = 1;
702  }
703  switch (p.type) {
704  case CONSTINT:
705  result.I += p.I;
706  result.type = CONSTINT; break;
707  case CONSTDOUBLE:
708  result.I += (p.D != 0.0);
709  result.type = CONSTINT; break;
710  default:
711  G4cerr << "Parameter range: unknown type"<<G4endl;
712  paramERR = 1;
713  }
714  }
715  return result;
716 }
tokenNum Yylex(void)
G4int paramERR
Definition: G4UIcommand.hh:237
tokenNum token
Definition: G4UIcommand.hh:234
yystype LogicalANDExpression(void)
Definition: G4UIcommand.cc:719
G4int I
Definition: G4UItokenNum.hh:64
tokenNum type
Definition: G4UItokenNum.hh:62
#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:

◆ MultiplicativeExpression()

yystype G4UIcommand::MultiplicativeExpression ( void  )
private

Definition at line 827 of file G4UIcommand.cc.

828 { yystype result;
829  result = UnaryExpression();
830  if( token != '*' && token != '/' && token != '%' ) return result;
831  G4cerr << "Parameter range: operator "
832  << (char)token
833  << " is not supported." << G4endl;
834  paramERR = 1;
835  return result;
836 }
yystype UnaryExpression(void)
Definition: G4UIcommand.cc:839
G4int paramERR
Definition: G4UIcommand.hh:237
tokenNum token
Definition: G4UIcommand.hh:234
#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 G4UIcommand::operator!= ( const G4UIcommand right) const

Definition at line 115 of file G4UIcommand.cc.

116 {
117  return ( commandPath != right.GetCommandPath() );
118 }
const G4String & GetCommandPath() const
Definition: G4UIcommand.hh:139
G4String commandPath
Definition: G4UIcommand.hh:117
Here is the call graph for this function:

◆ operator==()

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

Definition at line 110 of file G4UIcommand.cc.

111 {
112  return ( commandPath == right.GetCommandPath() );
113 }
const G4String & GetCommandPath() const
Definition: G4UIcommand.hh:139
G4String commandPath
Definition: G4UIcommand.hh:117
Here is the call graph for this function:

◆ PrimaryExpression()

yystype G4UIcommand::PrimaryExpression ( void  )
private

Definition at line 876 of file G4UIcommand.cc.

877 {
878  yystype result;
879  #ifdef DEBUG
880  G4cerr <<" primary_exp"<<G4endl;
881  #endif
882  switch (token) {
883  case IDENTIFIER:
884  result.S = yylval.S;
885  result.type = token;
886  token = Yylex(); break;
887  case CONSTINT:
888  result.I = yylval.I;
889  result.type = token;
890  token= Yylex(); break;
891  case CONSTDOUBLE:
892  result.D = yylval.D;
893  result.type = token;
894  token = Yylex(); break;
895  case '(' :
896  token= Yylex();
897  result = Expression();
898  if( token != ')' ) {
899  G4cerr << " ')' expected" << G4endl;
900  paramERR = 1;
901  }
902  token = Yylex();
903  break;
904  default:
905  return result;
906  }
907  return result; // never executed
908 }
G4String S
Definition: G4UItokenNum.hh:66
tokenNum Yylex(void)
G4int paramERR
Definition: G4UIcommand.hh:237
tokenNum token
Definition: G4UIcommand.hh:234
G4int I
Definition: G4UItokenNum.hh:64
yystype Expression(void)
Definition: G4UIcommand.cc:673
tokenNum type
Definition: G4UItokenNum.hh:62
yystype yylval
Definition: G4UIcommand.hh:235
#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:

◆ PrintToken()

void G4UIcommand::PrintToken ( void  )
private
Here is the caller graph for this function:

◆ RangeCheck()

G4int G4UIcommand::RangeCheck ( const char *  t)
private

Definition at line 642 of file G4UIcommand.cc.

642  {
643  yystype result;
644  char type;
645  bp = 0; // reset buffer pointer for G4UIpGetc()
646  std::istringstream is(t);
647  for (unsigned i=0; i< parameter.size(); i++) {
648  type= toupper(parameter[i]->GetParameterType());
649  switch ( type ) {
650  case 'D': is >> newVal[i].D; break;
651  case 'I': is >> newVal[i].I; break;
652  case 'S':
653  case 'B':
654  default: ;
655  }
656  }
657  // PrintToken(); // Print tokens (consumes all tokens)
658  token= Yylex();
659  result = Expression();
660 
661  if( paramERR == 1 ) return 0;
662  if( result.type != CONSTINT) {
663  G4cerr << "Illegal Expression in parameter range." << G4endl;
664  return 0;
665  }
666  if ( result.I ) return 1;
667  G4cerr << "parameter out of range: "<< rangeString << G4endl;
668  return 0;
669 }
std::vector< yystype > newVal
Definition: G4UIcommand.hh:236
tokenNum Yylex(void)
G4String rangeString
Definition: G4UIcommand.hh:119
G4int paramERR
Definition: G4UIcommand.hh:237
tokenNum token
Definition: G4UIcommand.hh:234
G4int I
Definition: G4UItokenNum.hh:64
yystype Expression(void)
Definition: G4UIcommand.cc:673
tokenNum type
Definition: G4UItokenNum.hh:62
#define G4endl
Definition: G4ios.hh:61
std::vector< G4UIparameter * > parameter
Definition: G4UIcommand.hh:120
G4GLOB_DLL std::ostream G4cerr
Here is the call graph for this function:
Here is the caller graph for this function:

◆ RelationalExpression()

yystype G4UIcommand::RelationalExpression ( void  )
private

Definition at line 786 of file G4UIcommand.cc.

787 {
788  yystype arg1, arg2;
789  G4int operat;
790  yystype result;
791  #ifdef DEBUG
792  G4cerr << " RelationalExpression()" <<G4endl;
793  #endif
794 
795  arg1 = AdditiveExpression();
796  if( token==GT || token==GE || token==LT || token==LE ) {
797  operat = token;
798  token = Yylex();
799  arg2 = AdditiveExpression();
800  result.I = Eval2( arg1, operat, arg2 ); // semantic action
801  result.type = CONSTINT;
802  #ifdef DEBUG
803  G4cerr << " return code of Eval2(): " << result.I << G4endl;
804  #endif
805  } else {
806  result = arg1;
807  }
808  #ifdef DEBUG
809  G4cerr <<" return RelationalExpression()"<< G4endl;
810  #endif
811  return result;
812 }
G4int Eval2(yystype arg1, G4int op, yystype arg2)
Definition: G4UIcommand.cc:913
Definition: Evaluator.cc:66
Definition: Evaluator.cc:66
tokenNum Yylex(void)
int G4int
Definition: G4Types.hh:78
tokenNum token
Definition: G4UIcommand.hh:234
G4int I
Definition: G4UItokenNum.hh:64
Definition: Evaluator.cc:66
tokenNum type
Definition: G4UItokenNum.hh:62
yystype AdditiveExpression(void)
Definition: G4UIcommand.cc:815
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:

◆ SetGuidance()

void G4UIcommand::SetGuidance ( const char *  aGuidance)
inline

Definition at line 161 of file G4UIcommand.hh.

162  {
163  commandGuidance.push_back( G4String( aGuidance ) );
164  }
std::vector< G4String > commandGuidance
Definition: G4UIcommand.hh:121

◆ SetParameter()

void G4UIcommand::SetParameter ( G4UIparameter *const  newParameter)
inline

Definition at line 152 of file G4UIcommand.hh.

153  {
154  parameter.push_back( newParameter );
155  newVal.resize( parameter.size() );
156  }
std::vector< yystype > newVal
Definition: G4UIcommand.hh:236
std::vector< G4UIparameter * > parameter
Definition: G4UIcommand.hh:120

◆ SetRange()

void G4UIcommand::SetRange ( const char *  rs)
inline

Definition at line 125 of file G4UIcommand.hh.

126  { rangeString = rs; }
G4String rangeString
Definition: G4UIcommand.hh:119

◆ SetToBeBroadcasted()

void G4UIcommand::SetToBeBroadcasted ( G4bool  val)
inline

Definition at line 184 of file G4UIcommand.hh.

185  { toBeBroadcasted = val; }
G4bool toBeBroadcasted
Definition: G4UIcommand.hh:179
Here is the caller graph for this function:

◆ SetToBeFlushed()

void G4UIcommand::SetToBeFlushed ( G4bool  val)
inline

Definition at line 188 of file G4UIcommand.hh.

189  { toBeFlushed = val; }
G4bool toBeFlushed
Definition: G4UIcommand.hh:180
Here is the caller graph for this function:

◆ SetWorkerThreadOnly()

void G4UIcommand::SetWorkerThreadOnly ( G4bool  val = true)
inline

Definition at line 192 of file G4UIcommand.hh.

193  { workerThreadOnly = val; }
G4bool workerThreadOnly
Definition: G4UIcommand.hh:181
Here is the caller graph for this function:

◆ ToBeBroadcasted()

G4bool G4UIcommand::ToBeBroadcasted ( ) const
inline

Definition at line 186 of file G4UIcommand.hh.

187  { return toBeBroadcasted; }
G4bool toBeBroadcasted
Definition: G4UIcommand.hh:179
Here is the caller graph for this function:

◆ ToBeFlushed()

G4bool G4UIcommand::ToBeFlushed ( ) const
inline

Definition at line 190 of file G4UIcommand.hh.

191  { return toBeFlushed; }
G4bool toBeFlushed
Definition: G4UIcommand.hh:180

◆ TokenToStr()

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

◆ TypeCheck()

G4int G4UIcommand::TypeCheck ( const char *  t)
private

Definition at line 508 of file G4UIcommand.cc.

509 {
510  G4String aNewValue;
511  char type;
512  std::istringstream is(t);
513  for (unsigned i=0; i< parameter.size(); i++) {
514  is >> aNewValue;
515  type = toupper(parameter[i]->GetParameterType());
516  switch ( type ) {
517  case 'D':
518  if( IsDouble(aNewValue)==0 ){
519  G4cerr << aNewValue << ": double value expected."
520  << G4endl;
521  return 0;
522  } break;
523  case 'I':
524  if( IsInt(aNewValue,20)==0 ){
525  G4cerr <<aNewValue<<": integer expected."
526  <<G4endl;
527  return 0;
528  } break;
529  case 'S':
530  break;
531  case 'B':
532  aNewValue.toUpper();
533  if (aNewValue == "Y" || aNewValue == "N"
534  ||aNewValue == "YES" || aNewValue == "NO"
535  ||aNewValue == "1" || aNewValue == "0"
536  ||aNewValue == "T" || aNewValue == "F"
537  ||aNewValue == "TRUE" || aNewValue == "FALSE")
538  return 1;
539  else return 0;
540  break;
541  default: ;
542  }
543  }
544  return 1;
545 }
G4int IsInt(const char *str, short maxLength)
Definition: G4UIcommand.cc:549
G4int IsDouble(const char *str)
Definition: G4UIcommand.cc:582
#define G4endl
Definition: G4ios.hh:61
std::vector< G4UIparameter * > parameter
Definition: G4UIcommand.hh:120
G4GLOB_DLL std::ostream G4cerr
Here is the call graph for this function:
Here is the caller graph for this function:

◆ UnaryExpression()

yystype G4UIcommand::UnaryExpression ( void  )
private

Definition at line 839 of file G4UIcommand.cc.

840 {
841  yystype result;
842  yystype p;
843  #ifdef DEBUG
844  G4cerr <<" UnaryExpression"<< G4endl;
845  #endif
846  switch(token) {
847  case '-':
848  token = Yylex();
849  p = UnaryExpression();
850  if (p.type == CONSTINT) {
851  result.I = - p.I;
852  result.type = CONSTINT;
853  }
854  if (p.type == CONSTDOUBLE) {
855  result.D = - p.D;
856  result.type = CONSTDOUBLE;
857  } break;
858  case '+':
859  token = Yylex();
860  result = UnaryExpression(); break;
861  case '!':
862  token = Yylex();
863  G4cerr << "Parameter range error: "
864  << "operator '!' is not supported (sorry)."
865  << G4endl;
866  paramERR = 1;
867  result = UnaryExpression(); break;
868  default:
869  result = PrimaryExpression();
870  }
871  return result;
872 }
yystype PrimaryExpression(void)
Definition: G4UIcommand.cc:876
tokenNum Yylex(void)
yystype UnaryExpression(void)
Definition: G4UIcommand.cc:839
G4int paramERR
Definition: G4UIcommand.hh:237
tokenNum token
Definition: G4UIcommand.hh:234
G4int I
Definition: G4UItokenNum.hh:64
tokenNum type
Definition: G4UItokenNum.hh:62
#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:

◆ UnitsList()

G4String G4UIcommand::UnitsList ( const char *  unitCategory)
static

Definition at line 320 of file G4UIcommand.cc.

321 {
322  G4String retStr;
324  size_t i;
325  for(i=0;i<UTbl.size();i++)
326  { if(UTbl[i]->GetName()==unitCategory) break; }
327  if(i==UTbl.size())
328  {
329  G4cerr << "Unit category <" << unitCategory << "> is not defined." << G4endl;
330  return retStr;
331  }
332  G4UnitsContainer& UCnt = UTbl[i]->GetUnitsList();
333  retStr = UCnt[0]->GetSymbol();
334  G4int je = UCnt.size();
335  for(G4int j=1;j<je;j++)
336  {
337  retStr += " ";
338  retStr += UCnt[j]->GetSymbol();
339  }
340  for(G4int k=0;k<je;k++)
341  {
342  retStr += " ";
343  retStr += UCnt[k]->GetName();
344  }
345  return retStr;
346 }
std::vector< G4UnitsCategory * > G4UnitsTable
Definition: G4UnitsTable.hh:59
int G4int
Definition: G4Types.hh:78
static G4UnitsTable & GetUnitsTable()
#define G4endl
Definition: G4ios.hh:61
std::vector< G4UnitDefinition * > G4UnitsContainer
G4GLOB_DLL std::ostream G4cerr
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ValueOf()

G4double G4UIcommand::ValueOf ( const char *  unitName)
static

Definition at line 308 of file G4UIcommand.cc.

309 {
310  G4double value = 0.;
311  value = G4UnitDefinition::GetValueOf(unitName);
312  return value;
313 }
static G4double GetValueOf(const G4String &)
double G4double
Definition: G4Types.hh:76
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Yylex()

tokenNum G4UIcommand::Yylex ( void  )
private

Definition at line 1055 of file G4UIcommand.cc.

1056 { // (returns EOF)
1057  G4int c;
1058  G4String buf;
1059 
1060  while(( c= G4UIpGetc())==' '|| c=='\t' || c== '\n' )
1061  ;
1062  if (c== EOF)
1063  return (tokenNum)EOF; // KR488
1064  buf= "";
1065  if (isdigit(c) || c== '.') { // I or D
1066  do {
1067  buf += G4String((unsigned char)c);
1068  c=G4UIpGetc();
1069  } while (c=='.' || isdigit(c) ||
1070  c=='e' || c=='E' || c=='+' || c=='-');
1071  G4UIpUngetc(c);
1072  const char* t = buf;
1073  std::istringstream is(t);
1074  if ( IsInt(buf.data(),20) ) {
1075  is >> yylval.I;
1076  return CONSTINT;
1077  } else
1078  if ( IsDouble(buf.data()) ) {
1079  is >> yylval.D;
1080  return CONSTDOUBLE;
1081  } else {
1082  G4cerr << buf<<": numeric format error."<<G4endl;
1083  }
1084  }
1085  buf="";
1086  if (isalpha(c)|| c=='_') { // IDENTIFIER
1087  do {
1088  buf += G4String((unsigned char)c);
1089  } while ((c=G4UIpGetc()) != EOF && (isalnum(c) || c=='_'));
1090  G4UIpUngetc(c);
1091  if( IsParameter(buf) ) {
1092  yylval.S =buf;
1093  return IDENTIFIER;
1094  } else {
1095  G4cerr << buf << " is not a parameter name."<< G4endl;
1096  paramERR = 1;
1097  }
1098  }
1099  switch (c) {
1100  case '>': return (tokenNum) Follow('=', GE, GT);
1101  case '<': return (tokenNum) Follow('=', LE, LT);
1102  case '=': return (tokenNum) Follow('=', EQ, '=');
1103  case '!': return (tokenNum) Follow('=', NE, '!');
1104  case '|': return (tokenNum) Follow('|', LOGICALOR, '|');
1105  case '&': return (tokenNum) Follow('&', LOGICALAND, '&');
1106  default:
1107  return (tokenNum) c;
1108  }
1109 }
tokenNum
Definition: G4UItokenNum.hh:36
const char * data() const
Definition: Evaluator.cc:66
G4int G4UIpGetc(void)
Definition: Evaluator.cc:66
G4String S
Definition: G4UItokenNum.hh:66
G4int IsInt(const char *str, short maxLength)
Definition: G4UIcommand.cc:549
Definition: Evaluator.cc:66
Definition: Evaluator.cc:66
int G4int
Definition: G4Types.hh:78
G4int paramERR
Definition: G4UIcommand.hh:237
G4int Follow(G4int expect, G4int ifyes, G4int ifno)
G4int I
Definition: G4UItokenNum.hh:64
unsigned IsParameter(const char *)
G4int IsDouble(const char *str)
Definition: G4UIcommand.cc:582
Definition: Evaluator.cc:66
Definition: Evaluator.cc:66
yystype yylval
Definition: G4UIcommand.hh:235
G4int G4UIpUngetc(G4int c)
#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:

Member Data Documentation

◆ availabelStateList

std::vector<G4ApplicationState> G4UIcommand::availabelStateList
private

Definition at line 122 of file G4UIcommand.hh.

◆ bp

G4int G4UIcommand::bp
private

Definition at line 233 of file G4UIcommand.hh.

◆ commandGuidance

std::vector<G4String> G4UIcommand::commandGuidance
private

Definition at line 121 of file G4UIcommand.hh.

◆ commandName

G4String G4UIcommand::commandName
private

Definition at line 118 of file G4UIcommand.hh.

◆ commandPath

G4String G4UIcommand::commandPath
private

Definition at line 117 of file G4UIcommand.hh.

◆ messenger

G4UImessenger* G4UIcommand::messenger
private

Definition at line 116 of file G4UIcommand.hh.

◆ newVal

std::vector<yystype> G4UIcommand::newVal
private

Definition at line 236 of file G4UIcommand.hh.

◆ paramERR

G4int G4UIcommand::paramERR
private

Definition at line 237 of file G4UIcommand.hh.

◆ parameter

std::vector<G4UIparameter*> G4UIcommand::parameter
private

Definition at line 120 of file G4UIcommand.hh.

◆ rangeBuf

G4String G4UIcommand::rangeBuf
private

Definition at line 232 of file G4UIcommand.hh.

◆ rangeString

G4String G4UIcommand::rangeString
private

Definition at line 119 of file G4UIcommand.hh.

◆ toBeBroadcasted

G4bool G4UIcommand::toBeBroadcasted
protected

Definition at line 179 of file G4UIcommand.hh.

◆ toBeFlushed

G4bool G4UIcommand::toBeFlushed
protected

Definition at line 180 of file G4UIcommand.hh.

◆ token

tokenNum G4UIcommand::token
private

Definition at line 234 of file G4UIcommand.hh.

◆ workerThreadOnly

G4bool G4UIcommand::workerThreadOnly
protected

Definition at line 181 of file G4UIcommand.hh.

◆ yylval

yystype G4UIcommand::yylval
private

Definition at line 235 of file G4UIcommand.hh.


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