|
||||
File indexing completed on 2025-01-18 09:59:16
0001 // 0002 // ******************************************************************** 0003 // * License and Disclaimer * 0004 // * * 0005 // * The Geant4 software is copyright of the Copyright Holders of * 0006 // * the Geant4 Collaboration. It is provided under the terms and * 0007 // * conditions of the Geant4 Software License, included in the file * 0008 // * LICENSE and available at http://cern.ch/geant4/license . These * 0009 // * include a list of copyright holders. * 0010 // * * 0011 // * Neither the authors of this software system, nor their employing * 0012 // * institutes,nor the agencies providing financial support for this * 0013 // * work make any representation or warranty, express or implied, * 0014 // * regarding this software system or assume any liability for its * 0015 // * use. Please see the license in the file LICENSE and URL above * 0016 // * for the full disclaimer and the limitation of liability. * 0017 // * * 0018 // * This code implementation is the result of the scientific and * 0019 // * technical work of the GEANT4 collaboration. * 0020 // * By using, copying, modifying or distributing the software (or * 0021 // * any work based on the software) you agree to acknowledge its * 0022 // * use in resulting scientific publications, and indicate your * 0023 // * acceptance of all terms of the Geant4 Software license. * 0024 // ******************************************************************** 0025 // 0026 // G4UIparameter 0027 // 0028 // Class description: 0029 // 0030 // This class represents a parameter which will be taken by a G4UIcommand 0031 // object. In case a command is defined by constructing G4UIcmdXXX class, 0032 // it automatically creates necessary parameter objects, thus the user needs 0033 // not to create parameter object(s). In case the user wants to create a 0034 // command directly instantiated by G4UIcommand class, he/she must create 0035 // a parameter object(s) 0036 0037 // Author: Makoto Asai, 1997 0038 // -------------------------------------------------------------------- 0039 #ifndef G4UIparameter_hh 0040 #define G4UIparameter_hh 1 0041 0042 #include "G4UItokenNum.hh" 0043 #include "globals.hh" 0044 0045 class G4UIparameter 0046 { 0047 public: 0048 // Default constructor 0049 G4UIparameter() = default; 0050 0051 // Constructors, where "theName" is the name of the parameter which will 0052 // be used by the range checking, "theType" is the type of the parameter 0053 // (currently "b" (Boolean), "i" (integer), "l" (long int), "d" (double) 0054 // and "s" (string) are supported). 0055 // "theOmittable" is a Boolean flag to set whether 0056 // the user of the command can omit the parameter or not. 0057 // If "theOmittable" is true, the default value must be given 0058 G4UIparameter(char theType); 0059 G4UIparameter(const char* theName, char theType, G4bool theOmittable); 0060 0061 // Destructor. When a command is destructed, the delete operator(s) of the 0062 // associated parameter(s) are AUTOMATICALLY invoked 0063 ~G4UIparameter(); 0064 0065 G4int CheckNewValue(const char* newValue); 0066 void List(); 0067 0068 // These methods set the default value of the parameter 0069 inline void SetDefaultValue(const char* theDefaultValue) { defaultValue = theDefaultValue; } 0070 void SetDefaultValue(G4int theDefaultValue); 0071 void SetDefaultValue(G4long theDefaultValue); 0072 void SetDefaultValue(G4double theDefaultValue); 0073 0074 // This method can be used for a string-type parameter that is 0075 // used to specify a unit. This method is valid only for a 0076 // string-type parameter 0077 void SetDefaultUnit(const char* theDefaultUnit); 0078 0079 inline const G4String& GetDefaultValue() const { return defaultValue; } 0080 inline char GetParameterType() const { return parameterType; } 0081 0082 // Defines the range the parameter can take. 0083 // The variable name appearing in the range expression must be the 0084 // same as the name of the parameter. 0085 // All the C++ syntax of relational operators are allowed for the 0086 // range expression 0087 inline void SetParameterRange(const char* theRange) { rangeExpression = theRange; } 0088 0089 inline const G4String& GetParameterRange() const { return rangeExpression; } 0090 0091 inline void SetParameterName(const char* pName) { parameterName = pName; } 0092 inline const G4String& GetParameterName() const { return parameterName; } 0093 0094 // This method is meaningful if the type of the parameter is string. 0095 // The candidates listed in the argument must be separated by space(s) 0096 inline void SetParameterCandidates(const char* theString) { parameterCandidate = theString; } 0097 0098 inline const G4String& GetParameterCandidates() const { return parameterCandidate; } 0099 0100 inline void SetOmittable(G4bool om) { omittable = om; } 0101 inline G4bool IsOmittable() const { return omittable; } 0102 0103 inline void SetCurrentAsDefault(G4bool val) { currentAsDefaultFlag = val; } 0104 inline G4bool GetCurrentAsDefault() const { return currentAsDefaultFlag; } 0105 0106 // Obsolete methods 0107 // 0108 inline const G4String& GetParameterGuidance() const { return parameterGuidance; } 0109 inline void SetGuidance(const char* theGuidance) { parameterGuidance = theGuidance; } 0110 0111 protected: 0112 using yystype = G4UItokenNum::yystype; 0113 using tokenNum = G4UItokenNum::tokenNum; 0114 0115 private: 0116 // --- the following is used by CheckNewValue() ------- 0117 G4bool TypeCheck(const char* newValue); 0118 G4bool RangeCheck(const char* newValue); 0119 G4bool CandidateCheck(const char* newValue); 0120 // syntax nodes 0121 yystype Expression(); 0122 yystype LogicalORExpression(); 0123 yystype LogicalANDExpression(); 0124 yystype EqualityExpression(); 0125 yystype RelationalExpression(); 0126 yystype AdditiveExpression(); 0127 yystype MultiplicativeExpression(); 0128 yystype UnaryExpression(); 0129 yystype PrimaryExpression(); 0130 // semantics routines 0131 G4int Eval2(const yystype& arg1, G4int op, const yystype& arg2); 0132 // utility 0133 tokenNum Yylex(); // returns next token 0134 G4int G4UIpGetc(); // read one char from rangeBuf 0135 G4int G4UIpUngetc(G4int c); // put back 0136 G4int Backslash(G4int c); 0137 G4int Follow(G4int expect, G4int ifyes, G4int ifno); 0138 0139 // data ----------------------------------------------------------- 0140 0141 G4String parameterName; 0142 G4String parameterGuidance; 0143 G4String defaultValue; 0144 G4String rangeExpression; 0145 G4String parameterCandidate; 0146 char parameterType = '\0'; 0147 G4bool omittable = false; 0148 G4bool currentAsDefaultFlag = false; 0149 0150 //------------ CheckNewValue() related data members --------------- 0151 G4int bp = 0; // current index in rangeExpression 0152 tokenNum token = G4UItokenNum::NONE; 0153 yystype yylval; 0154 yystype newVal; 0155 G4int paramERR = 0; 0156 }; 0157 0158 #endif
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |