00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 #ifndef G4UIcommand_h
00032 #define G4UIcommand_h 1
00033
00034 #include "G4UIparameter.hh"
00035 class G4UImessenger;
00036 #include "globals.hh"
00037 #include "G4ApplicationState.hh"
00038 #include <vector>
00039 #include "G4UItokenNum.hh"
00040 #include "G4ThreeVector.hh"
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051 class G4UIcommand
00052 {
00053 public:
00054 G4UIcommand();
00055 public:
00056 G4UIcommand(const char * theCommandPath, G4UImessenger * theMessenger);
00057
00058
00059 public:
00060 virtual ~G4UIcommand();
00061
00062 G4int operator==(const G4UIcommand &right) const;
00063 G4int operator!=(const G4UIcommand &right) const;
00064
00065 virtual G4int DoIt(G4String parameterList);
00066 G4String GetCurrentValue();
00067 public:
00068 void AvailableForStates(G4ApplicationState s1);
00069 void AvailableForStates(G4ApplicationState s1,G4ApplicationState s2);
00070 void AvailableForStates(G4ApplicationState s1,G4ApplicationState s2,
00071 G4ApplicationState s3);
00072 void AvailableForStates(G4ApplicationState s1,G4ApplicationState s2,
00073 G4ApplicationState s3,G4ApplicationState s4);
00074 void AvailableForStates(G4ApplicationState s1,G4ApplicationState s2,
00075 G4ApplicationState s3,G4ApplicationState s4,
00076 G4ApplicationState s5);
00077
00078
00079
00080 public:
00081 G4bool IsAvailable();
00082 virtual void List();
00083
00084 public:
00085 static G4String ConvertToString(G4bool boolVal);
00086 static G4String ConvertToString(G4int intValue);
00087 static G4String ConvertToString(G4double doubleValue);
00088 static G4String ConvertToString(G4double doubleValue,const char* unitName);
00089 static G4String ConvertToString(G4ThreeVector vec);
00090 static G4String ConvertToString(G4ThreeVector vec,const char* unitName);
00091
00092
00093
00094 static G4bool ConvertToBool(const char* st);
00095 static G4int ConvertToInt(const char* st);
00096 static G4double ConvertToDouble(const char* st);
00097 static G4double ConvertToDimensionedDouble(const char* st);
00098 static G4ThreeVector ConvertTo3Vector(const char* st);
00099 static G4ThreeVector ConvertToDimensioned3Vector(const char* st);
00100
00101
00102
00103
00104 static G4double ValueOf(const char* unitName);
00105 static G4String CategoryOf(const char* unitName);
00106 static G4String UnitsList(const char* unitCategory);
00107
00108
00109 private:
00110 void G4UIcommandCommonConstructorCode (const char * theCommandPath);
00111 G4UImessenger *messenger;
00112 G4String commandPath;
00113 G4String commandName;
00114 G4String rangeString;
00115 std::vector<G4UIparameter*> parameter;
00116 std::vector<G4String> commandGuidance;
00117 std::vector<G4ApplicationState> availabelStateList;
00118
00119 public:
00120 inline void SetRange(const char* rs)
00121 { rangeString = rs; }
00122
00123
00124
00125
00126
00127 public:
00128 inline const G4String & GetRange() const
00129 { return rangeString; };
00130 inline G4int GetGuidanceEntries() const
00131 { return commandGuidance.size(); }
00132 inline const G4String & GetGuidanceLine(G4int i) const
00133 { return commandGuidance[i]; }
00134 inline const G4String & GetCommandPath() const
00135 { return commandPath; }
00136 inline const G4String & GetCommandName() const
00137 { return commandName; }
00138 inline G4int GetParameterEntries() const
00139 { return parameter.size(); }
00140 inline G4UIparameter * GetParameter(G4int i) const
00141 { return parameter[i]; }
00142 inline std::vector<G4ApplicationState>* GetStateList()
00143 { return &availabelStateList; }
00144 inline G4UImessenger * GetMessenger() const
00145 { return messenger; }
00146 public:
00147 inline void SetParameter(G4UIparameter *const newParameter)
00148 {
00149 parameter.push_back( newParameter );
00150 newVal.resize( parameter.size() );
00151 }
00152
00153
00154
00155
00156 inline void SetGuidance(const char * aGuidance)
00157 {
00158 commandGuidance.push_back( G4String( aGuidance ) );
00159 }
00160
00161
00162
00163
00164 public:
00165 inline const G4String GetTitle() const
00166 {
00167 if(commandGuidance.size() == 0)
00168 { return G4String("...Title not available..."); }
00169 else
00170 { return commandGuidance[0]; }
00171 }
00172
00173 protected:
00174 G4int CheckNewValue(const char* newValue);
00175
00176
00177 private:
00178 G4int TypeCheck(const char* t);
00179 G4int RangeCheck(const char* t);
00180 G4int IsInt(const char* str, short maxLength);
00181 G4int IsDouble(const char* str);
00182 G4int ExpectExponent(const char* str);
00183
00184 yystype Expression( void );
00185 yystype LogicalORExpression( void );
00186 yystype LogicalANDExpression( void );
00187 yystype EqualityExpression ( void );
00188 yystype RelationalExpression( void );
00189 yystype AdditiveExpression( void );
00190 yystype MultiplicativeExpression( void );
00191 yystype UnaryExpression( void );
00192 yystype PrimaryExpression( void );
00193
00194 G4int Eval2( yystype arg1, G4int op, yystype arg2 );
00195 G4int CompareInt( G4int arg1, G4int op, G4int arg2);
00196 G4int CompareDouble( G4double arg1, G4int op, G4double arg2);
00197
00198 tokenNum Yylex( void );
00199 unsigned IndexOf( const char* );
00200 unsigned IsParameter( const char* );
00201 G4int G4UIpGetc( void );
00202 G4int G4UIpUngetc( G4int c );
00203 G4int Backslash( G4int c );
00204 G4int Follow( G4int expect, G4int ifyes, G4int ifno );
00205 G4String TokenToStr(G4int token);
00206 void PrintToken(void);
00207
00208 G4String rangeBuf;
00209 G4int bp;
00210 tokenNum token;
00211 yystype yylval;
00212 std::vector<yystype> newVal;
00213 G4int paramERR;
00214 };
00215
00216 #endif
00217