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