41 using namespace G4UItokenNum;
44 : messenger(0), toBeBroadcasted(
false), toBeFlushed(
false), workerThreadOnly(
false),
45 commandFailureCode(0), failureDescription(
""),
52 :messenger(theMessenger),toBeBroadcasted(tBB),toBeFlushed(
false), workerThreadOnly(
false),
53 commandFailureCode(0), failureDescription(
""),
59 if(comStr(comStr.length()-1)!=
'/')
62 G4cerr <<
" <" << theCommandPath <<
"> must be a directory." <<
G4endl;
78 #ifdef G4MULTITHREADED
83 (
const char * theCommandPath)
85 commandPath = theCommandPath;
86 commandName = theCommandPath;
87 G4int commandNameIndex = commandName.last(
'/');
88 commandName.remove(0,commandNameIndex+1);
89 #ifdef G4MULTITHREADED
90 if(messenger && messenger->CommandsShouldBeInMaster()
93 toBeBroadcasted =
false;
109 for(
G4int i_thParameter=0; i_thParameter < n_parameterEntry; i_thParameter++ )
130 if( n_parameterEntry != 0 )
135 for(
G4int i_thParameter=0; i_thParameter<n_parameterEntry; i_thParameter++ )
137 if(i_thParameter > 0)
139 correctParameters.
append(
" ");
141 aToken = parameterToken();
142 if( aToken.length()>0 && aToken(0)==
'"' )
144 while( aToken(aToken.length()-1) !=
'"'
145 || ( aToken.length()==1 && aToken(0)==
'"' ))
147 G4String additionalToken = parameterToken();
148 if( additionalToken.
isNull() )
151 aToken += additionalToken;
154 else if(i_thParameter==n_parameterEntry-1 &&
parameter[i_thParameter]->GetParameterType()==
's')
157 while(!((anotherToken=parameterToken()).isNull()))
160 if(idxs==
G4int(std::string::npos))
163 aToken += anotherToken;
168 aToken += anotherToken(0,idxs);
176 if( aToken.
isNull() || aToken ==
"!" )
178 if(
parameter[i_thParameter]->IsOmittable())
180 if(
parameter[i_thParameter]->GetCurrentAsDefault())
184 for(
G4int ii=0;ii<i_thParameter;ii++)
189 while( parVal(parVal.length()-1) !=
'"' )
192 if( additionalToken.
isNull() )
195 parVal += additionalToken;
200 if (aCVToken(0)==
'"')
202 while( aCVToken(aCVToken.length()-1) !=
'"' )
205 if( additionalToken.
isNull() )
208 aCVToken += additionalToken;
212 correctParameters.
append(aCVToken);
215 { correctParameters.
append(
parameter[i_thParameter]->GetDefaultValue()); }
223 if(stat)
return stat+i_thParameter;
224 correctParameters.
append(aToken);
300 for(
G4int i=0;i<nState;i++)
329 for(i=0;i<UTbl.size();i++)
330 {
if(UTbl[i]->GetName()==unitCategory)
break; }
333 G4cerr <<
"Unit category <" << unitCategory <<
"> is not defined." <<
G4endl;
337 retStr = UCnt[0]->GetSymbol();
338 G4int je = UCnt.size();
339 for(
G4int j=1;j<je;j++)
342 retStr += UCnt[j]->GetSymbol();
347 retStr += UCnt[
k]->GetName();
359 {
G4cout <<
" ---- available only in worker thread" <<
G4endl; }
362 for(
G4int i_thGuidance=0; i_thGuidance < n_guidanceEntry; i_thGuidance++ )
367 if( n_parameterEntry > 0 )
369 for(
G4int i_thParameter=0; i_thParameter<n_parameterEntry; i_thParameter++ )
378 if(boolVal) vl =
"1";
384 std::ostringstream os;
392 std::ostringstream os;
394 { os << std::setprecision(17) << doubleValue; }
396 { os << doubleValue; }
406 std::ostringstream os;
408 { os << std::setprecision(17) << doubleValue/uv <<
" " << unitName; }
410 { os << doubleValue/uv <<
" " << unitName; }
417 std::ostringstream os;
419 { os << std::setprecision(17) << vec.
x() <<
" " << vec.
y() <<
" " << vec.
z(); }
421 { os << vec.
x() <<
" " << vec.
y() <<
" " << vec.
z(); }
431 std::ostringstream os;
433 { os << std::setprecision(17) << vec.
x()/uv <<
" " << vec.
y()/uv <<
" " << vec.
z()/uv <<
" " << unitName; }
435 { os << vec.
x()/uv <<
" " << vec.
y()/uv <<
" " << vec.
z()/uv <<
" " << unitName; }
445 if( v==
"Y" || v==
"YES" || v==
"1" || v==
"T" || v==
"TRUE" )
453 std::istringstream is(st);
461 std::istringstream is(st);
471 std::istringstream is(st);
483 std::istringstream is(st);
484 is >> vx >> vy >> vz;
494 std::istringstream is(st);
495 is >> vx >> vy >> vz >> unts;
527 std::istringstream is(t);
528 for (
unsigned i=0; i<
parameter.size(); i++) {
530 type = toupper(
parameter[i]->GetParameterType());
534 G4cerr << aNewValue <<
": double value expected."
539 if(
IsInt(aNewValue,20)==0 ){
540 G4cerr <<aNewValue<<
": integer expected."
548 if (aNewValue ==
"Y" || aNewValue ==
"N"
549 ||aNewValue ==
"YES" || aNewValue ==
"NO"
550 ||aNewValue ==
"1" || aNewValue ==
"0"
551 ||aNewValue ==
"T" || aNewValue ==
"F"
552 ||aNewValue ==
"TRUE" || aNewValue ==
"FALSE")
564 IsInt(
const char* buf,
short maxDigits)
568 if( *p ==
'+' || *p ==
'-') { ++
p; }
569 if( isdigit( (
G4int)(*p) )) {
572 if( length > maxDigits) {
591 if(
IsInt( str, maxExplength=7 ))
return 1;
601 case '+':
case '-': ++
p;
603 while( isdigit( (
G4int)(*p) )) { ++
p; }
611 if( *p ==
'\0' )
return 1;
614 while( isdigit( (
G4int)(*p) )) { ++
p; }
615 if( *p ==
'\0' )
return 1;
617 }
else return 0;
break;
621 if( *p ==
'.' ) { ++
p;
623 while( isdigit( (
G4int)(*p) )) { ++
p; }
624 if( *p ==
'\0' )
return 1;
631 while( isdigit( (
G4int)(*p) )) { ++
p; }
632 if( *p ==
'\0' )
return 1;
637 while( isdigit( (
G4int)(*p) )) { ++
p; }
638 if( *p ==
'\0' )
return 1;
640 if( *p ==
'.' ) { ++
p;
641 if( *p ==
'\0' )
return 1;
644 while( isdigit( (
G4int)(*p) )) { ++
p; }
645 if( *p ==
'\0' )
return 1;
661 std::istringstream is(t);
662 for (
unsigned i=0; i<
parameter.size(); i++) {
663 type= toupper(
parameter[i]->GetParameterType());
665 case 'D': is >>
newVal[i].D;
break;
666 case 'I': is >>
newVal[i].I;
break;
667 case 'S': is >>
newVal[i].S;
break;
668 case 'B': is >>
newVal[i].C;
break;
678 G4cerr <<
"Illegal Expression in parameter range." <<
G4endl;
681 if ( result.
I )
return 1;
706 G4cerr <<
"Parameter range: illegal type at '||'" <<
G4endl;
715 G4cerr <<
"Parameter range: illegal type at '||'" <<
G4endl;
723 result.
I += (p.
D != 0.0);
741 G4cerr <<
"Parameter range: illegal type at '&&'" <<
G4endl;
750 G4cerr <<
"Parameter range: illegal type at '&&'" <<
G4endl;
758 result.
I *= (p.
D != 0.0);
784 result.
I =
Eval2( arg1, operat, arg2 );
791 G4cerr <<
"Parameter range: error at EqualityExpression"
815 result.
I =
Eval2( arg1, operat, arg2 );
833 if(
token !=
'+' &&
token !=
'-' )
return result;
834 G4cerr <<
"Parameter range: operator "
836 <<
" is not supported." <<
G4endl;
846 G4cerr <<
"Parameter range: operator "
848 <<
" is not supported." <<
G4endl;
878 G4cerr <<
"Parameter range error: "
879 <<
"operator '!' is not supported (sorry)."
933 <<
": meaningless comparison"
940 newValtype = toupper(
parameter[i]->GetParameterType());
941 switch ( newValtype ) {
949 char newValtype2 = toupper(
parameter[iii]->GetParameterType());
950 if( newValtype2 ==
'I' ) {
952 }
else if( newValtype2 ==
'D' ) {
953 G4cerr <<
"Warning : Integer is compared with double : "
959 G4cerr <<
"integer operand expected for "
972 char newValtype2 = toupper(
parameter[iii]->GetParameterType());
973 if( newValtype2 ==
'I' ) {
975 }
else if( newValtype2 ==
'D' ) {
985 newValtype = toupper(
parameter[i]->GetParameterType());
986 switch ( newValtype ) {
991 G4cerr <<
"integer operand expected for "
1014 case GT: result = ( arg1 > arg2); opr=
">" ;
break;
1015 case GE: result = ( arg1 >= arg2); opr=
">=";
break;
1016 case LT: result = ( arg1 < arg2); opr=
"<" ;
break;
1017 case LE: result = ( arg1 <= arg2); opr=
"<=";
break;
1018 case EQ: result = ( arg1 == arg2); opr=
"==";
break;
1019 case NE: result = ( arg1 != arg2); opr=
"!=";
break;
1021 G4cerr <<
"Parameter range: error at CompareInt" <<
G4endl;
1026 << arg1 <<
" " << opr << arg2
1027 <<
" result: " << result
1039 case GT: result = ( arg1 > arg2); opr=
">";
break;
1040 case GE: result = ( arg1 >= arg2); opr=
">=";
break;
1041 case LT: result = ( arg1 < arg2); opr=
"<";
break;
1042 case LE: result = ( arg1 <= arg2); opr=
"<=";
break;
1043 case EQ: result = ( arg1 == arg2); opr=
"==";
break;
1044 case NE: result = ( arg1 != arg2); opr=
"!=";
break;
1046 G4cerr <<
"Parameter range: error at CompareDouble"
1051 G4cerr <<
"CompareDouble "
1052 << arg1 <<
" " << opr <<
" "<< arg2
1053 <<
" result: " << result
1066 pname =
parameter[i]-> GetParameterName();
1067 if( pname == nam ) {
1072 G4cerr <<
"parameter name:"<<nam<<
" not found."<<
G4endl;
1081 for(
unsigned i=0; i<
parameter.size(); i++)
1083 pname =
parameter[i]-> GetParameterName();
1084 if( pname == nam )
return 1;
1098 while(( c=
G4UIpGetc())==
' '|| c==
'\t' || c==
'\n' )
1103 if (isdigit(c) || c==
'.') {
1107 }
while (c==
'.' || isdigit(c) ||
1108 c==
'e' || c==
'E' || c==
'+' || c==
'-');
1110 const char*
t = buf;
1111 std::istringstream is(t);
1124 if (isalpha(c)|| c==
'_') {
1127 }
while ((c=
G4UIpGetc()) != EOF && (isalnum(c) || c==
'_'));