43 : messenger(0), toBeBroadcasted(false), toBeFlushed(false), workerThreadOnly(false),
44 commandFailureCode(0), failureDescription(
""),
51 :messenger(theMessenger),toBeBroadcasted(tBB),toBeFlushed(false), workerThreadOnly(false),
52 commandFailureCode(0), failureDescription(
""),
58 if(comStr(comStr.length()-1)!=
'/')
61 G4cerr <<
" <" << theCommandPath <<
"> must be a directory." <<
G4endl;
77 #ifdef G4MULTITHREADED
82 (
const char * theCommandPath)
84 commandPath = theCommandPath;
85 commandName = theCommandPath;
86 G4int commandNameIndex = commandName.last(
'/');
87 commandName.remove(0,commandNameIndex+1);
88 #ifdef G4MULTITHREADED
89 if(messenger && messenger->CommandsShouldBeInMaster()
92 toBeBroadcasted =
false;
108 for(
G4int i_thParameter=0; i_thParameter < n_parameterEntry; i_thParameter++ )
129 if( n_parameterEntry != 0 )
134 for(
G4int i_thParameter=0; i_thParameter<n_parameterEntry; i_thParameter++ )
136 if(i_thParameter > 0)
138 correctParameters.
append(
" ");
140 aToken = parameterToken();
141 if( aToken.length()>0 && aToken(0)==
'"' )
143 while( aToken(aToken.length()-1) !=
'"'
144 || ( aToken.length()==1 && aToken(0)==
'"' ))
146 G4String additionalToken = parameterToken();
147 if( additionalToken.
isNull() )
150 aToken += additionalToken;
153 else if(i_thParameter==n_parameterEntry-1 &&
parameter[i_thParameter]->GetParameterType()==
's')
156 while(!((anotherToken=parameterToken()).isNull()))
159 if(idxs==
G4int(std::string::npos))
162 aToken += anotherToken;
167 aToken += anotherToken(0,idxs);
175 if( aToken.
isNull() || aToken ==
"!" )
177 if(
parameter[i_thParameter]->IsOmittable())
179 if(
parameter[i_thParameter]->GetCurrentAsDefault())
183 for(
G4int ii=0;ii<i_thParameter;ii++)
188 while( parVal(parVal.length()-1) !=
'"' )
191 if( additionalToken.
isNull() )
194 parVal += additionalToken;
199 if (aCVToken(0)==
'"')
201 while( aCVToken(aCVToken.length()-1) !=
'"' )
204 if( additionalToken.
isNull() )
207 aCVToken += additionalToken;
211 correctParameters.
append(aCVToken);
214 { correctParameters.
append(
parameter[i_thParameter]->GetDefaultValue()); }
222 if(stat)
return stat+i_thParameter;
223 correctParameters.
append(aToken);
299 for(
G4int i=0;i<nState;i++)
328 for(i=0;i<UTbl.size();i++)
329 {
if(UTbl[i]->GetName()==unitCategory)
break; }
332 G4cerr <<
"Unit category <" << unitCategory <<
"> is not defined." <<
G4endl;
336 retStr = UCnt[0]->GetSymbol();
337 G4int je = UCnt.size();
338 for(
G4int j=1;j<je;j++)
341 retStr += UCnt[j]->GetSymbol();
343 for(
G4int k=0;k<je;k++)
346 retStr += UCnt[k]->GetName();
358 {
G4cout <<
" ---- available only in worker thread" <<
G4endl; }
361 for(
G4int i_thGuidance=0; i_thGuidance < n_guidanceEntry; i_thGuidance++ )
366 if( n_parameterEntry > 0 )
368 for(
G4int i_thParameter=0; i_thParameter<n_parameterEntry; i_thParameter++ )
377 if(boolVal) vl =
"1";
383 std::ostringstream os;
391 std::ostringstream os;
393 { os << std::setprecision(17) << doubleValue; }
395 { os << doubleValue; }
405 std::ostringstream os;
407 { os << std::setprecision(17) << doubleValue/uv <<
" " << unitName; }
409 { os << doubleValue/uv <<
" " << unitName; }
416 std::ostringstream os;
418 { os << std::setprecision(17) << vec.
x() <<
" " << vec.
y() <<
" " << vec.
z(); }
420 { os << vec.
x() <<
" " << vec.
y() <<
" " << vec.
z(); }
430 std::ostringstream os;
432 { os << std::setprecision(17) << vec.
x()/uv <<
" " << vec.
y()/uv <<
" " << vec.
z()/uv <<
" " << unitName; }
434 { os << vec.
x()/uv <<
" " << vec.
y()/uv <<
" " << vec.
z()/uv <<
" " << unitName; }
444 if( v==
"Y" || v==
"YES" || v==
"1" || v==
"T" || v==
"TRUE" )
452 std::istringstream is(st);
460 std::istringstream is(st);
470 std::istringstream is(st);
482 std::istringstream is(st);
483 is >> vx >> vy >> vz;
493 std::istringstream is(st);
494 is >> vx >> vy >> vz >> unts;
526 std::istringstream is(t);
527 for (
unsigned i=0; i<
parameter.size(); i++) {
529 type = toupper(
parameter[i]->GetParameterType());
533 G4cerr << aNewValue <<
": double value expected."
538 if(
IsInt(aNewValue,20)==0 ){
539 G4cerr <<aNewValue<<
": integer expected."
547 if (aNewValue ==
"Y" || aNewValue ==
"N"
548 ||aNewValue ==
"YES" || aNewValue ==
"NO"
549 ||aNewValue ==
"1" || aNewValue ==
"0"
550 ||aNewValue ==
"T" || aNewValue ==
"F"
551 ||aNewValue ==
"TRUE" || aNewValue ==
"FALSE")
563 IsInt(
const char* buf,
short maxDigits)
567 if( *p ==
'+' || *p ==
'-') { ++
p; }
568 if( isdigit( (
G4int)(*p) )) {
569 while( isdigit( (
G4int)(*p) )) { ++
p; ++length; }
571 if( length > maxDigits) {
590 if(
IsInt( str, maxExplength=7 ))
return 1;
600 case '+':
case '-': ++
p;
602 while( isdigit( (
G4int)(*p) )) { ++
p; }
610 if( *p ==
'\0' )
return 1;
613 while( isdigit( (
G4int)(*p) )) { ++
p; }
614 if( *p ==
'\0' )
return 1;
616 }
else return 0;
break;
620 if( *p ==
'.' ) { ++
p;
622 while( isdigit( (
G4int)(*p) )) { ++
p; }
623 if( *p ==
'\0' )
return 1;
630 while( isdigit( (
G4int)(*p) )) { ++
p; }
631 if( *p ==
'\0' )
return 1;
636 while( isdigit( (
G4int)(*p) )) { ++
p; }
637 if( *p ==
'\0' )
return 1;
639 if( *p ==
'.' ) { ++
p;
640 if( *p ==
'\0' )
return 1;
643 while( isdigit( (
G4int)(*p) )) { ++
p; }
644 if( *p ==
'\0' )
return 1;
660 std::istringstream is(t);
661 for (
unsigned i=0; i<
parameter.size(); i++) {
662 type= toupper(
parameter[i]->GetParameterType());
664 case 'D': is >>
newVal[i].D;
break;
665 case 'I': is >>
newVal[i].I;
break;
677 G4cerr <<
"Illegal Expression in parameter range." <<
G4endl;
680 if ( result.
I )
return 1;
705 G4cerr <<
"Parameter range: illegal type at '||'" <<
G4endl;
714 G4cerr <<
"Parameter range: illegal type at '||'" <<
G4endl;
722 result.
I += (p.
D != 0.0);
740 G4cerr <<
"Parameter range: illegal type at '&&'" <<
G4endl;
749 G4cerr <<
"Parameter range: illegal type at '&&'" <<
G4endl;
757 result.
I *= (p.
D != 0.0);
783 result.
I =
Eval2( arg1, operat, arg2 );
790 G4cerr <<
"Parameter range: error at EqualityExpression"
814 result.
I =
Eval2( arg1, operat, arg2 );
833 G4cerr <<
"Parameter range: operator "
835 <<
" is not supported." <<
G4endl;
845 G4cerr <<
"Parameter range: operator "
847 <<
" is not supported." <<
G4endl;
877 G4cerr <<
"Parameter range error: "
878 <<
"operator '!' is not supported (sorry)."
932 <<
": meaningless comparison"
939 newValtype = toupper(
parameter[i]->GetParameterType());
940 switch ( newValtype ) {
945 G4cerr <<
"integer operand expected for "
961 newValtype = toupper(
parameter[i]->GetParameterType());
962 switch ( newValtype ) {
967 G4cerr <<
"integer operand expected for "
990 case GT: result = ( arg1 > arg2); opr=
">" ;
break;
991 case GE: result = ( arg1 >= arg2); opr=
">=";
break;
992 case LT: result = ( arg1 < arg2); opr=
"<" ;
break;
993 case LE: result = ( arg1 <= arg2); opr=
"<=";
break;
994 case EQ: result = ( arg1 == arg2); opr=
"==";
break;
995 case NE: result = ( arg1 != arg2); opr=
"!=";
break;
997 G4cerr <<
"Parameter range: error at CompareInt" <<
G4endl;
1002 << arg1 <<
" " << opr << arg2
1003 <<
" result: " << result
1015 case GT: result = ( arg1 > arg2); opr=
">";
break;
1016 case GE: result = ( arg1 >= arg2); opr=
">=";
break;
1017 case LT: result = ( arg1 < arg2); opr=
"<";
break;
1018 case LE: result = ( arg1 <= arg2); opr=
"<=";
break;
1019 case EQ: result = ( arg1 == arg2); opr=
"==";
break;
1020 case NE: result = ( arg1 != arg2); opr=
"!=";
break;
1022 G4cerr <<
"Parameter range: error at CompareDouble"
1027 G4cerr <<
"CompareDouble "
1028 << arg1 <<
" " << opr <<
" "<< arg2
1029 <<
" result: " << result
1042 pname =
parameter[i]-> GetParameterName();
1043 if( pname == nam ) {
1048 G4cerr <<
"parameter name:"<<nam<<
" not found."<<
G4endl;
1057 for(
unsigned i=0; i<
parameter.size(); i++)
1059 pname =
parameter[i]-> GetParameterName();
1060 if( pname == nam )
return 1;
1074 while(( c=
G4UIpGetc())==
' '|| c==
'\t' || c==
'\n' )
1079 if (isdigit(c) || c==
'.') {
1083 }
while (c==
'.' || isdigit(c) ||
1084 c==
'e' || c==
'E' || c==
'+' || c==
'-');
1086 const char* t = buf;
1087 std::istringstream is(t);
1100 if (isalpha(c)|| c==
'_') {
1103 }
while ((c=
G4UIpGetc()) != EOF && (isalnum(c) || c==
'_'));
static G4double ValueOf(const char *unitName)
static G4String CategoryOf(const char *unitName)
G4int Follow(G4int expect, G4int ifyes, G4int ifno)
G4int G4UIpUngetc(G4int c)
static G4bool DoublePrecisionStr()
CLHEP::Hep3Vector G4ThreeVector
static G4double ConvertToDouble(const char *st)
G4int TypeCheck(const char *t)
void AddNewCommand(G4UIcommand *newCommand)
yystype EqualityExpression(void)
G4int operator!=(const G4UIcommand &right) const
unsigned IndexOf(const char *)
virtual G4int DoIt(G4String parameterList)
G4int CompareDouble(G4double arg1, G4int op, G4double arg2)
static G4bool ConvertToBool(const char *st)
yystype RelationalExpression(void)
void RemoveCommand(G4UIcommand *aCommand)
yystype LogicalANDExpression(void)
str_size index(const char *, G4int pos=0) const
static G4UImanager * GetUIpointer()
G4int Eval2(yystype arg1, G4int op, yystype arg2)
static G4int ConvertToInt(const char *st)
static G4UImanager * GetMasterUIpointer()
G4int IsInt(const char *str, short maxLength)
std::vector< G4UnitsCategory * > G4UnitsTable
std::vector< G4String > commandGuidance
const XML_Char int const XML_Char * value
yystype PrimaryExpression(void)
G4int CompareInt(G4int arg1, G4int op, G4int arg2)
const char * data() const
G4int RangeCheck(const char *t)
yystype AdditiveExpression(void)
static G4double GetValueOf(const G4String &)
yystype MultiplicativeExpression(void)
static G4UnitsTable & GetUnitsTable()
const G4String & GetCommandPath() const
static G4ThreeVector ConvertTo3Vector(const char *st)
G4GLOB_DLL std::ostream G4cerr
G4double G4ParticleHPJENDLHEData::G4double result
virtual G4String GetCurrentValue(G4UIcommand *command)
static G4String ConvertToString(G4bool boolVal)
G4int IsDouble(const char *str)
void G4UIcommandCommonConstructorCode(const char *theCommandPath)
G4ApplicationState GetCurrentState() const
std::vector< G4UnitDefinition * > G4UnitsContainer
unsigned IsParameter(const char *)
std::vector< G4UIparameter * > parameter
G4UImessenger * messenger
G4GLOB_DLL std::ostream G4cout
virtual void SetNewValue(G4UIcommand *command, G4String newValue)
static G4String GetCategory(const G4String &)
static G4ThreeVector ConvertToDimensioned3Vector(const char *st)
yystype LogicalORExpression(void)
static G4String UnitsList(const char *unitCategory)
static G4double ConvertToDimensionedDouble(const char *st)
G4String GetCurrentValue()
std::vector< G4ApplicationState > availabelStateList
G4String & append(const G4String &)
G4int CheckNewValue(const char *newValue)
std::vector< yystype > newVal
yystype UnaryExpression(void)
G4int ExpectExponent(const char *str)
void AvailableForStates(G4ApplicationState s1)
G4int operator==(const G4UIcommand &right) const
static G4StateManager * GetStateManager()