Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer << 3 // * DISCLAIMER * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th << 5 // * The following disclaimer summarizes all the specific disclaimers * 6 // * the Geant4 Collaboration. It is provided << 6 // * of contributors to this software. The specific disclaimers,which * 7 // * conditions of the Geant4 Software License << 7 // * govern, are listed with their locations in: * 8 // * LICENSE and available at http://cern.ch/ << 8 // * http://cern.ch/geant4/license * 9 // * include a list of copyright holders. << 10 // * 9 // * * 11 // * Neither the authors of this software syst 10 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 11 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 12 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 13 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file << 14 // * use. * 16 // * for the full disclaimer and the limitatio << 17 // * 15 // * * 18 // * This code implementation is the result << 16 // * This code implementation is the intellectual property of the * 19 // * technical work of the GEANT4 collaboratio << 17 // * GEANT4 collaboration. * 20 // * By using, copying, modifying or distri << 18 // * By copying, distributing or modifying the Program (or any work * 21 // * any work based on the software) you ag << 19 // * based on the Program) you indicate your acceptance of this * 22 // * use in resulting scientific publicati << 20 // * statement, and all its terms. * 23 // * acceptance of all terms of the Geant4 Sof << 24 // ******************************************* 21 // ******************************************************************** 25 // 22 // 26 // G4UIparameter << 27 // 23 // 28 // Class description: << 24 // $Id: G4UIparameter.hh,v 1.8 2005/10/26 06:09:15 kmura Exp $ >> 25 // GEANT4 tag $Name: geant4-08-00-patch-01 $ 29 // 26 // 30 // This class represents a parameter which wil << 27 // 31 // object. In case a command is defined by con << 28 // --------------------------------------------------------------------- 32 // it automatically creates necessary paramete << 29 33 // not to create parameter object(s). In case << 30 #ifndef G4UIparameter_h 34 // command directly instantiated by G4UIcomman << 31 #define G4UIparameter_h 1 35 // a parameter object(s) << 36 << 37 // Author: Makoto Asai, 1997 << 38 // ------------------------------------------- << 39 #ifndef G4UIparameter_hh << 40 #define G4UIparameter_hh 1 << 41 32 42 #include "globals.hh" 33 #include "globals.hh" >> 34 #include "G4UItokenNum.hh" >> 35 >> 36 // class description: >> 37 // >> 38 // This class represents a parameter which will be taken by a G4UIcommand >> 39 // object. In case a command is defined by constructing G4UIcmdXXX class, >> 40 // it automatically creates necessary parameter objects, thus the user needs >> 41 // not to create parameter object(s) by him/herself. In case the user wants >> 42 // to create a command directly instansiated by G4UIcommand class, he/she >> 43 // must create parameter object(s) by him/herself. 43 44 44 class G4UIparameter << 45 class G4UIparameter 45 { 46 { >> 47 public: // with description >> 48 G4UIparameter(); >> 49 G4UIparameter(char theType); >> 50 G4UIparameter(const char * theName, char theType, G4bool theOmittable); >> 51 // Constructors, where "theName" is the name of the parameter which will >> 52 // be used by the range checking, "theType" is the type of the parameter >> 53 // (currently "b" (boolean), "i" (integer), "d" (double), and "s" (string) >> 54 // are supported), and "theOmittable" is a boolean flag to set whether >> 55 // the user of the command can ommit the parameter or not. If "theOmittable" >> 56 // is true, the default value must be given. >> 57 ~G4UIparameter(); >> 58 // Destructor. When a command is destructed, the delete operator(s) for >> 59 // associating parameter(s) are AUTOMATICALLY invoked. Thus the user needs >> 60 // NOT to invoke this by him/herself. >> 61 46 public: 62 public: 47 // Default constructor << 63 G4int operator==(const G4UIparameter &right) const; 48 G4UIparameter() = default; << 64 G4int operator!=(const G4UIparameter &right) const; 49 65 50 // Constructors, where "theName" is the na << 66 G4int CheckNewValue(const char* newValue); 51 // be used by the range checking, "theType << 67 void List(); 52 // (currently "b" (Boolean), "i" (integer) << 53 // and "s" (string) are supported). << 54 // "theOmittable" is a Boolean flag to set << 55 // the user of the command can omit the pa << 56 // If "theOmittable" is true, the default << 57 G4UIparameter(char theType); << 58 G4UIparameter(const char* theName, char th << 59 << 60 // Destructor. When a command is destructe << 61 // associated parameter(s) are AUTOMATICAL << 62 ~G4UIparameter(); << 63 << 64 G4int CheckNewValue(const char* newValue); << 65 void List(); << 66 << 67 // These methods set the default value of << 68 inline void SetDefaultValue(const char* th << 69 void SetDefaultValue(G4int theDefaultValue << 70 void SetDefaultValue(G4long theDefaultValu << 71 void SetDefaultValue(G4double theDefaultVa << 72 << 73 // This method can be used for a string-ty << 74 // used to specify a unit. This method is << 75 // string-type parameter << 76 void SetDefaultUnit(const char* theDefault << 77 << 78 inline const G4String& GetDefaultValue() c << 79 inline char GetParameterType() const { ret << 80 << 81 // Defines the range the parameter can tak << 82 // The variable name appearing in the rang << 83 // same as the name of the parameter. << 84 // All the C++ syntax of relational operat << 85 // range expression << 86 inline void SetParameterRange(const char* << 87 << 88 inline const G4String& GetParameterRange() << 89 << 90 inline void SetParameterName(const char* p << 91 inline const G4String& GetParameterName() << 92 << 93 // This method is meaningful if the type o << 94 // The candidates listed in the argument m << 95 inline void SetParameterCandidates(const c << 96 << 97 inline const G4String& GetParameterCandida << 98 << 99 inline void SetOmittable(G4bool om) { omit << 100 inline G4bool IsOmittable() const { return << 101 << 102 inline void SetCurrentAsDefault(G4bool val << 103 inline G4bool GetCurrentAsDefault() const << 104 << 105 // Obsolete methods << 106 // << 107 inline const G4String& GetParameterGuidanc << 108 inline void SetGuidance(const char* theGui << 109 68 110 private: 69 private: 111 G4bool TypeCheck(const char* newValue); << 70 G4String parameterName; 112 G4bool CandidateCheck(const char* newValue << 71 G4String parameterGuidance; >> 72 G4String defaultValue; >> 73 G4String parameterRange; >> 74 G4String parameterCandidate; >> 75 char parameterType; >> 76 G4bool omittable; >> 77 G4bool currentAsDefaultFlag; >> 78 G4int widget; >> 79 >> 80 public: // with description >> 81 inline void SetDefaultValue(const char * theDefaultValue) >> 82 { defaultValue = theDefaultValue; } >> 83 void SetDefaultValue(G4int theDefaultValue); >> 84 void SetDefaultValue(G4double theDefaultValue); >> 85 // These methods set the default value of the parameter. >> 86 public: >> 87 inline G4String GetDefaultValue() const >> 88 { return defaultValue; } >> 89 inline char GetParameterType() const >> 90 { return parameterType; } >> 91 >> 92 public: // with description >> 93 inline void SetParameterRange(const char * theRange) >> 94 { parameterRange = theRange; } >> 95 // Defines the range the parameter can take. >> 96 // The variable name appear in the range expression must be same >> 97 // as the name of the parameter. >> 98 // All the C++ syntax of relational operators are allowed for the >> 99 // range expression. >> 100 public: >> 101 inline G4String GetParameterRange() const >> 102 { return parameterRange; } >> 103 >> 104 // parameterName >> 105 inline void SetParameterName(const char * theName) >> 106 { parameterName = theName; } >> 107 inline G4String GetParameterName() const >> 108 { return parameterName; } >> 109 >> 110 public: // with description >> 111 inline void SetParameterCandidates(const char * theString) >> 112 { parameterCandidate = theString; } >> 113 // This method is meaningful if the type of the parameter is string. >> 114 // The candidates listed in the argument must be separated by space(s). >> 115 public: >> 116 inline G4String GetParameterCandidates() const >> 117 { return parameterCandidate; } >> 118 >> 119 // omittable >> 120 inline void SetOmittable(G4bool om) >> 121 { omittable = om; } >> 122 inline G4bool IsOmittable() const >> 123 { return omittable; } >> 124 >> 125 // currentAsDefaultFlag >> 126 inline void SetCurrentAsDefault(G4bool val) >> 127 { currentAsDefaultFlag = val; } >> 128 inline G4bool GetCurrentAsDefault() const >> 129 { return currentAsDefaultFlag; } >> 130 >> 131 // out of date methods >> 132 inline void SetWidget(G4int theWidget) >> 133 { widget = theWidget; } >> 134 inline const G4String GetParameterGuidance() const >> 135 { return parameterGuidance; } >> 136 inline void SetGuidance(const char * theGuidance) >> 137 { parameterGuidance = theGuidance; } 113 138 114 private: 139 private: 115 G4String parameterName; << 140 // --- the following is used by CheckNewValue() ------- 116 G4String parameterGuidance; << 141 G4int TypeCheck(const char* newValue ); 117 G4String defaultValue; << 142 G4int RangeCheck(const char* newValue ); 118 G4String rangeExpression; << 143 G4int CandidateCheck(const char* newValue ); 119 G4String parameterCandidate; << 144 G4int IsInt(const char* str, short maxDigit); 120 char parameterType = '\0'; << 145 G4int IsDouble(const char* str); 121 G4bool omittable = false; << 146 G4int ExpectExponent(const char* str); 122 G4bool currentAsDefaultFlag = false; << 147 // syntax nodes >> 148 yystype Expression( void ); >> 149 yystype LogicalORExpression( void ); >> 150 yystype LogicalANDExpression( void ); >> 151 yystype EqualityExpression ( void ); >> 152 yystype RelationalExpression( void ); >> 153 yystype AdditiveExpression( void ); >> 154 yystype MultiplicativeExpression( void ); >> 155 yystype UnaryExpression( void ); >> 156 yystype PrimaryExpression( void ); >> 157 // semantics routines >> 158 G4int Eval2( yystype arg1, G4int op, yystype arg2 ); >> 159 G4int CompareInt( G4int arg1, G4int op, G4int arg2); >> 160 G4int CompareDouble( double arg1, G4int op, double arg2); >> 161 // utility >> 162 tokenNum Yylex( void ); // returns next token >> 163 G4int G4UIpGetc( void ); // read one char from rangeBuf >> 164 G4int G4UIpUngetc( G4int c ); // put back >> 165 G4int Backslash( G4int c ); >> 166 G4int Follow( G4int expect, G4int ifyes, G4int ifno ); >> 167 G4String TokenToStr(G4int token); >> 168 //void PrintToken(void); // debug >> 169 // data >> 170 G4String rangeBuf; >> 171 G4int bp; // buffer pointer for rangeBuf >> 172 tokenNum token; >> 173 yystype yylval; >> 174 yystype newVal; >> 175 G4int paramERR; >> 176 //------------ end of CheckNewValue() related member -------------- >> 177 123 }; 178 }; 124 179 125 #endif 180 #endif >> 181 126 182