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;
75 (
const char * theCommandPath)
77 commandPath = theCommandPath;
78 commandName = theCommandPath;
79 G4int commandNameIndex = commandName.last(
'/');
80 commandName.remove(0,commandNameIndex+1);
91 for(
G4int i_thParameter=0; i_thParameter < n_parameterEntry; i_thParameter++ )
112 if( n_parameterEntry != 0 )
117 for(
G4int i_thParameter=0; i_thParameter<n_parameterEntry; i_thParameter++ )
119 if(i_thParameter > 0)
121 correctParameters.
append(
" ");
123 aToken = parameterToken();
124 if( aToken.length()>0 && aToken(0)==
'"' )
126 while( aToken(aToken.length()-1) !=
'"'
127 || ( aToken.length()==1 && aToken(0)==
'"' ))
129 G4String additionalToken = parameterToken();
130 if( additionalToken.
isNull() )
133 aToken += additionalToken;
136 else if(i_thParameter==n_parameterEntry-1 &&
parameter[i_thParameter]->GetParameterType()==
's')
139 while(!((anotherToken=parameterToken()).isNull()))
142 if(idxs==
G4int(std::string::npos))
145 aToken += anotherToken;
150 aToken += anotherToken(0,idxs);
158 if( aToken.
isNull() || aToken ==
"!" )
160 if(
parameter[i_thParameter]->IsOmittable())
162 if(
parameter[i_thParameter]->GetCurrentAsDefault())
166 for(
G4int ii=0;ii<i_thParameter;ii++)
171 while( parVal(parVal.length()-1) !=
'"' )
174 if( additionalToken.
isNull() )
177 parVal += additionalToken;
182 if (aCVToken(0)==
'"')
184 while( aCVToken(aCVToken.length()-1) !=
'"' )
187 if( additionalToken.
isNull() )
190 aCVToken += additionalToken;
194 correctParameters.
append(aCVToken);
197 { correctParameters.
append(
parameter[i_thParameter]->GetDefaultValue()); }
205 if(stat)
return stat+i_thParameter;
206 correctParameters.
append(aToken);
282 for(
G4int i=0;i<nState;i++)
311 for(i=0;i<UTbl.size();i++)
312 {
if(UTbl[i]->GetName()==unitCategory)
break; }
315 G4cerr <<
"Unit category <" << unitCategory <<
"> is not defined." <<
G4endl;
319 retStr = UCnt[0]->GetSymbol();
320 G4int je = UCnt.size();
321 for(
G4int j=1;j<je;j++)
324 retStr += UCnt[j]->GetSymbol();
326 for(
G4int k=0;k<je;k++)
329 retStr += UCnt[k]->GetName();
341 {
G4cout <<
" ---- available only in worker thread" <<
G4endl; }
344 for(
G4int i_thGuidance=0; i_thGuidance < n_guidanceEntry; i_thGuidance++ )
349 if( n_parameterEntry > 0 )
351 for(
G4int i_thParameter=0; i_thParameter<n_parameterEntry; i_thParameter++ )
360 if(boolVal) vl =
"1";
366 std::ostringstream os;
374 std::ostringstream os;
385 std::ostringstream os;
386 os << doubleValue/uv <<
" " << unitName;
393 std::ostringstream os;
394 os << vec.x() <<
" " << vec.y() <<
" " << vec.z();
404 std::ostringstream os;
405 os << vec.x()/uv <<
" " << vec.y()/uv <<
" " << vec.z()/uv
416 if( v==
"Y" || v==
"YES" || v==
"1" || v==
"T" || v==
"TRUE" )
424 std::istringstream is(st);
432 std::istringstream is(st);
442 std::istringstream is(st);
454 std::istringstream is(st);
455 is >> vx >> vy >> vz;
465 std::istringstream is(st);
466 is >> vx >> vy >> vz >> unts;
498 std::istringstream is(t);
499 for (
unsigned i=0; i<
parameter.size(); i++) {
501 type = toupper(
parameter[i]->GetParameterType());
505 G4cerr << aNewValue <<
": double value expected."
510 if(
IsInt(aNewValue,20)==0 ){
511 G4cerr <<aNewValue<<
": integer expected."
519 if (aNewValue ==
"Y" || aNewValue ==
"N"
520 ||aNewValue ==
"YES" || aNewValue ==
"NO"
521 ||aNewValue ==
"1" || aNewValue ==
"0"
522 ||aNewValue ==
"T" || aNewValue ==
"F"
523 ||aNewValue ==
"TRUE" || aNewValue ==
"FALSE")
535 IsInt(
const char* buf,
short maxDigits)
539 if( *p ==
'+' || *p ==
'-') { ++p; }
540 if( isdigit( (
G4int)(*p) )) {
541 while( isdigit( (
G4int)(*p) )) { ++p; ++length; }
543 if( length > maxDigits) {
562 if(
IsInt( str, maxExplength=7 ))
return 1;
572 case '+':
case '-': ++p;
574 while( isdigit( (
G4int)(*p) )) { ++p; }
582 if( *p ==
'\0' )
return 1;
585 while( isdigit( (
G4int)(*p) )) { ++p; }
586 if( *p ==
'\0' )
return 1;
588 }
else return 0;
break;
592 if( *p ==
'.' ) { ++p;
594 while( isdigit( (
G4int)(*p) )) { ++p; }
595 if( *p ==
'\0' )
return 1;
602 while( isdigit( (
G4int)(*p) )) { ++p; }
603 if( *p ==
'\0' )
return 1;
608 while( isdigit( (
G4int)(*p) )) { ++p; }
609 if( *p ==
'\0' )
return 1;
611 if( *p ==
'.' ) { ++p;
612 if( *p ==
'\0' )
return 1;
615 while( isdigit( (
G4int)(*p) )) { ++p; }
616 if( *p ==
'\0' )
return 1;
632 std::istringstream is(t);
633 for (
unsigned i=0; i<
parameter.size(); i++) {
634 type= toupper(
parameter[i]->GetParameterType());
636 case 'D': is >>
newVal[i].D;
break;
637 case 'I': is >>
newVal[i].I;
break;
649 G4cerr <<
"Illegal Expression in parameter range." <<
G4endl;
652 if ( result.
I )
return 1;
677 G4cerr <<
"Parameter range: illegal type at '||'" <<
G4endl;
686 G4cerr <<
"Parameter range: illegal type at '||'" <<
G4endl;
694 result.
I += (p.
D != 0.0);
712 G4cerr <<
"Parameter range: illegal type at '&&'" <<
G4endl;
721 G4cerr <<
"Parameter range: illegal type at '&&'" <<
G4endl;
729 result.
I *= (p.
D != 0.0);
755 result.
I =
Eval2( arg1, operat, arg2 );
762 G4cerr <<
"Parameter range: error at EqualityExpression"
786 result.
I =
Eval2( arg1, operat, arg2 );
804 if(
token !=
'+' &&
token !=
'-' )
return result;
805 G4cerr <<
"Parameter range: operator "
807 <<
" is not supported." <<
G4endl;
817 G4cerr <<
"Parameter range: operator "
819 <<
" is not supported." <<
G4endl;
849 G4cerr <<
"Parameter range error: "
850 <<
"operator '!' is not supported (sorry)."
904 <<
": meaningless comparison"
911 newValtype = toupper(
parameter[i]->GetParameterType());
912 switch ( newValtype ) {
917 G4cerr <<
"integer operand expected for "
933 newValtype = toupper(
parameter[i]->GetParameterType());
934 switch ( newValtype ) {
939 G4cerr <<
"integer operand expected for "
962 case GT: result = ( arg1 > arg2); opr=
">" ;
break;
963 case GE: result = ( arg1 >= arg2); opr=
">=";
break;
964 case LT: result = ( arg1 < arg2); opr=
"<" ;
break;
965 case LE: result = ( arg1 <= arg2); opr=
"<=";
break;
966 case EQ: result = ( arg1 == arg2); opr=
"==";
break;
967 case NE: result = ( arg1 != arg2); opr=
"!=";
break;
969 G4cerr <<
"Parameter range: error at CompareInt" <<
G4endl;
974 << arg1 <<
" " << opr << arg2
975 <<
" result: " << result
987 case GT: result = ( arg1 > arg2); opr=
">";
break;
988 case GE: result = ( arg1 >= arg2); opr=
">=";
break;
989 case LT: result = ( arg1 < arg2); opr=
"<";
break;
990 case LE: result = ( arg1 <= arg2); opr=
"<=";
break;
991 case EQ: result = ( arg1 == arg2); opr=
"==";
break;
992 case NE: result = ( arg1 != arg2); opr=
"!=";
break;
994 G4cerr <<
"Parameter range: error at CompareDouble"
999 G4cerr <<
"CompareDouble "
1000 << arg1 <<
" " << opr <<
" "<< arg2
1001 <<
" result: " << result
1014 pname =
parameter[i]-> GetParameterName();
1015 if( pname == nam ) {
1020 G4cerr <<
"parameter name:"<<nam<<
" not found."<<
G4endl;
1029 for(
unsigned i=0; i<
parameter.size(); i++)
1031 pname =
parameter[i]-> GetParameterName();
1032 if( pname == nam )
return 1;
1046 while(( c=
G4UIpGetc())==
' '|| c==
'\t' || c==
'\n' )
1051 if (isdigit(c) || c==
'.') {
1055 }
while (c==
'.' || isdigit(c) ||
1056 c==
'e' || c==
'E' || c==
'+' || c==
'-');
1058 const char* t = buf;
1059 std::istringstream is(t);
1072 if (isalpha(c)|| c==
'_') {
1075 }
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
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)