42 : messenger(0), toBeBroadcasted(false), toBeFlushed(false), workerThreadOnly(false),
49 :messenger(theMessenger),toBeBroadcasted(tBB),toBeFlushed(false), workerThreadOnly(false),
55 if(comStr(comStr.length()-1)!=
'/')
58 G4cerr <<
" <" << theCommandPath <<
"> must be a directory." <<
G4endl;
74 #ifdef G4MULTITHREADED
79 (
const char * theCommandPath)
81 commandPath = theCommandPath;
82 commandName = theCommandPath;
83 G4int commandNameIndex = commandName.last(
'/');
84 commandName.remove(0,commandNameIndex+1);
85 #ifdef G4MULTITHREADED
86 if(messenger && messenger->CommandsShouldBeInMaster()
89 toBeBroadcasted =
false;
105 for(
G4int i_thParameter=0; i_thParameter < n_parameterEntry; i_thParameter++ )
126 if( n_parameterEntry != 0 )
131 for(
G4int i_thParameter=0; i_thParameter<n_parameterEntry; i_thParameter++ )
133 if(i_thParameter > 0)
135 correctParameters.
append(
" ");
137 aToken = parameterToken();
138 if( aToken.length()>0 && aToken(0)==
'"' )
140 while( aToken(aToken.length()-1) !=
'"'
141 || ( aToken.length()==1 && aToken(0)==
'"' ))
143 G4String additionalToken = parameterToken();
144 if( additionalToken.
isNull() )
147 aToken += additionalToken;
150 else if(i_thParameter==n_parameterEntry-1 &&
parameter[i_thParameter]->GetParameterType()==
's')
153 while(!((anotherToken=parameterToken()).isNull()))
156 if(idxs==
G4int(std::string::npos))
159 aToken += anotherToken;
164 aToken += anotherToken(0,idxs);
172 if( aToken.
isNull() || aToken ==
"!" )
174 if(
parameter[i_thParameter]->IsOmittable())
176 if(
parameter[i_thParameter]->GetCurrentAsDefault())
180 for(
G4int ii=0;ii<i_thParameter;ii++)
185 while( parVal(parVal.length()-1) !=
'"' )
188 if( additionalToken.
isNull() )
191 parVal += additionalToken;
196 if (aCVToken(0)==
'"')
198 while( aCVToken(aCVToken.length()-1) !=
'"' )
201 if( additionalToken.
isNull() )
204 aCVToken += additionalToken;
208 correctParameters.
append(aCVToken);
211 { correctParameters.
append(
parameter[i_thParameter]->GetDefaultValue()); }
219 if(stat)
return stat+i_thParameter;
220 correctParameters.
append(aToken);
296 for(
G4int i=0;i<nState;i++)
325 for(i=0;i<UTbl.size();i++)
326 {
if(UTbl[i]->GetName()==unitCategory)
break; }
329 G4cerr <<
"Unit category <" << unitCategory <<
"> is not defined." <<
G4endl;
333 retStr = UCnt[0]->GetSymbol();
334 G4int je = UCnt.size();
335 for(
G4int j=1;j<je;j++)
338 retStr += UCnt[j]->GetSymbol();
340 for(
G4int k=0;k<je;k++)
343 retStr += UCnt[k]->GetName();
355 {
G4cout <<
" ---- available only in worker thread" <<
G4endl; }
358 for(
G4int i_thGuidance=0; i_thGuidance < n_guidanceEntry; i_thGuidance++ )
363 if( n_parameterEntry > 0 )
365 for(
G4int i_thParameter=0; i_thParameter<n_parameterEntry; i_thParameter++ )
374 if(boolVal) vl =
"1";
380 std::ostringstream os;
388 std::ostringstream os;
399 std::ostringstream os;
400 os << doubleValue/uv <<
" " << unitName;
407 std::ostringstream os;
408 os << vec.x() <<
" " << vec.y() <<
" " << vec.z();
418 std::ostringstream os;
419 os << vec.x()/uv <<
" " << vec.y()/uv <<
" " << vec.z()/uv
430 if( v==
"Y" || v==
"YES" || v==
"1" || v==
"T" || v==
"TRUE" )
438 std::istringstream is(st);
446 std::istringstream is(st);
456 std::istringstream is(st);
468 std::istringstream is(st);
469 is >> vx >> vy >> vz;
479 std::istringstream is(st);
480 is >> vx >> vy >> vz >> unts;
512 std::istringstream is(t);
513 for (
unsigned i=0; i<
parameter.size(); i++) {
515 type = toupper(
parameter[i]->GetParameterType());
519 G4cerr << aNewValue <<
": double value expected."
524 if(
IsInt(aNewValue,20)==0 ){
525 G4cerr <<aNewValue<<
": integer expected."
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")
549 IsInt(
const char* buf,
short maxDigits)
553 if( *p ==
'+' || *p ==
'-') { ++p; }
554 if( isdigit( (
G4int)(*p) )) {
555 while( isdigit( (
G4int)(*p) )) { ++p; ++length; }
557 if( length > maxDigits) {
576 if(
IsInt( str, maxExplength=7 ))
return 1;
586 case '+':
case '-': ++p;
588 while( isdigit( (
G4int)(*p) )) { ++p; }
596 if( *p ==
'\0' )
return 1;
599 while( isdigit( (
G4int)(*p) )) { ++p; }
600 if( *p ==
'\0' )
return 1;
602 }
else return 0;
break;
606 if( *p ==
'.' ) { ++p;
608 while( isdigit( (
G4int)(*p) )) { ++p; }
609 if( *p ==
'\0' )
return 1;
616 while( isdigit( (
G4int)(*p) )) { ++p; }
617 if( *p ==
'\0' )
return 1;
622 while( isdigit( (
G4int)(*p) )) { ++p; }
623 if( *p ==
'\0' )
return 1;
625 if( *p ==
'.' ) { ++p;
626 if( *p ==
'\0' )
return 1;
629 while( isdigit( (
G4int)(*p) )) { ++p; }
630 if( *p ==
'\0' )
return 1;
646 std::istringstream is(t);
647 for (
unsigned i=0; i<
parameter.size(); i++) {
648 type= toupper(
parameter[i]->GetParameterType());
650 case 'D': is >>
newVal[i].D;
break;
651 case 'I': is >>
newVal[i].I;
break;
663 G4cerr <<
"Illegal Expression in parameter range." <<
G4endl;
666 if ( result.
I )
return 1;
691 G4cerr <<
"Parameter range: illegal type at '||'" <<
G4endl;
700 G4cerr <<
"Parameter range: illegal type at '||'" <<
G4endl;
708 result.
I += (p.
D != 0.0);
726 G4cerr <<
"Parameter range: illegal type at '&&'" <<
G4endl;
735 G4cerr <<
"Parameter range: illegal type at '&&'" <<
G4endl;
743 result.
I *= (p.
D != 0.0);
769 result.
I =
Eval2( arg1, operat, arg2 );
776 G4cerr <<
"Parameter range: error at EqualityExpression"
800 result.
I =
Eval2( arg1, operat, arg2 );
818 if(
token !=
'+' &&
token !=
'-' )
return result;
819 G4cerr <<
"Parameter range: operator "
821 <<
" is not supported." <<
G4endl;
831 G4cerr <<
"Parameter range: operator "
833 <<
" is not supported." <<
G4endl;
863 G4cerr <<
"Parameter range error: "
864 <<
"operator '!' is not supported (sorry)."
918 <<
": meaningless comparison"
925 newValtype = toupper(
parameter[i]->GetParameterType());
926 switch ( newValtype ) {
931 G4cerr <<
"integer operand expected for "
947 newValtype = toupper(
parameter[i]->GetParameterType());
948 switch ( newValtype ) {
953 G4cerr <<
"integer operand expected for "
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;
983 G4cerr <<
"Parameter range: error at CompareInt" <<
G4endl;
988 << arg1 <<
" " << opr << arg2
989 <<
" result: " << result
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;
1008 G4cerr <<
"Parameter range: error at CompareDouble"
1013 G4cerr <<
"CompareDouble "
1014 << arg1 <<
" " << opr <<
" "<< arg2
1015 <<
" result: " << result
1028 pname =
parameter[i]-> GetParameterName();
1029 if( pname == nam ) {
1034 G4cerr <<
"parameter name:"<<nam<<
" not found."<<
G4endl;
1043 for(
unsigned i=0; i<
parameter.size(); i++)
1045 pname =
parameter[i]-> GetParameterName();
1046 if( pname == nam )
return 1;
1060 while(( c=
G4UIpGetc())==
' '|| c==
'\t' || c==
'\n' )
1065 if (isdigit(c) || c==
'.') {
1069 }
while (c==
'.' || isdigit(c) ||
1070 c==
'e' || c==
'E' || c==
'+' || c==
'-');
1072 const char* t = buf;
1073 std::istringstream is(t);
1086 if (isalpha(c)|| c==
'_') {
1089 }
while ((c=
G4UIpGetc()) != EOF && (isalnum(c) || c==
'_'));
G4UImessenger * messenger
yystype MultiplicativeExpression(void)
std::vector< yystype > newVal
G4int Eval2(yystype arg1, G4int op, yystype arg2)
virtual G4String GetCurrentValue(G4UIcommand *command)
CLHEP::Hep3Vector G4ThreeVector
G4int operator!=(const G4UIcommand &right) const
static G4UImanager * GetMasterUIpointer()
G4int IsInt(const char *str, short maxLength)
std::vector< G4UnitsCategory * > G4UnitsTable
unsigned IndexOf(const char *)
yystype PrimaryExpression(void)
virtual void SetNewValue(G4UIcommand *command, G4String newValue)
static G4String ConvertToString(G4bool boolVal)
G4int CompareDouble(G4double arg1, G4int op, G4double arg2)
G4int TypeCheck(const char *t)
std::vector< G4ApplicationState > availabelStateList
yystype UnaryExpression(void)
static G4ThreeVector ConvertTo3Vector(const char *st)
static G4double ConvertToDimensionedDouble(const char *st)
G4int Follow(G4int expect, G4int ifyes, G4int ifno)
G4int ExpectExponent(const char *str)
static G4UImanager * GetUIpointer()
static G4StateManager * GetStateManager()
static G4double GetValueOf(const G4String &)
yystype LogicalANDExpression(void)
G4GLOB_DLL std::ostream G4cout
G4int CheckNewValue(const char *newValue)
yystype LogicalORExpression(void)
str_size index(const char *, G4int pos=0) const
void G4UIcommandCommonConstructorCode(const char *theCommandPath)
static G4String UnitsList(const char *unitCategory)
static G4bool ConvertToBool(const char *st)
unsigned IsParameter(const char *)
G4int IsDouble(const char *str)
static G4double ConvertToDouble(const char *st)
void RemoveCommand(G4UIcommand *aCommand)
const G4String & GetCommandPath() const
void AvailableForStates(G4ApplicationState s1)
G4ApplicationState GetCurrentState() const
yystype AdditiveExpression(void)
static G4int ConvertToInt(const char *st)
static G4UnitsTable & GetUnitsTable()
G4int operator==(const G4UIcommand &right) const
static G4String GetCategory(const G4String &)
const char * data() const
void AddNewCommand(G4UIcommand *newCommand)
G4int G4UIpUngetc(G4int c)
G4String & append(const G4String &)
static G4double ValueOf(const char *unitName)
yystype EqualityExpression(void)
yystype RelationalExpression(void)
std::vector< G4UnitDefinition * > G4UnitsContainer
std::vector< G4String > commandGuidance
std::vector< G4UIparameter * > parameter
static G4String CategoryOf(const char *unitName)
virtual G4int DoIt(G4String parameterList)
G4int CompareInt(G4int arg1, G4int op, G4int arg2)
G4String GetCurrentValue()
G4int RangeCheck(const char *t)
G4GLOB_DLL std::ostream G4cerr
static G4ThreeVector ConvertToDimensioned3Vector(const char *st)