ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4UIparameter.hh
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file G4UIparameter.hh
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
26 //
27 //
28 //
29 // ---------------------------------------------------------------------
30 
31 #ifndef G4UIparameter_h
32 #define G4UIparameter_h 1
33 
34 #include "globals.hh"
35 #include "G4UItokenNum.hh"
36 
37 // class description:
38 //
39 // This class represents a parameter which will be taken by a G4UIcommand
40 // object. In case a command is defined by constructing G4UIcmdXXX class,
41 // it automatically creates necessary parameter objects, thus the user needs
42 // not to create parameter object(s) by him/herself. In case the user wants
43 // to create a command directly instansiated by G4UIcommand class, he/she
44 // must create parameter object(s) by him/herself.
45 
47 {
48  public: // with description
49  G4UIparameter();
50  G4UIparameter(char theType);
51  G4UIparameter(const char * theName, char theType, G4bool theOmittable);
52  // Constructors, where "theName" is the name of the parameter which will
53  // be used by the range checking, "theType" is the type of the parameter
54  // (currently "b" (boolean), "i" (integer), "d" (double), and "s" (string)
55  // are supported), and "theOmittable" is a boolean flag to set whether
56  // the user of the command can ommit the parameter or not. If "theOmittable"
57  // is true, the default value must be given.
59  // Destructor. When a command is destructed, the delete operator(s) for
60  // associating parameter(s) are AUTOMATICALLY invoked. Thus the user needs
61  // NOT to invoke this by him/herself.
62 
63  public:
64  G4bool operator==(const G4UIparameter &right) const;
65  G4bool operator!=(const G4UIparameter &right) const;
66 
67  G4int CheckNewValue(const char* newValue);
68  void List();
69 
70  private:
80 
81  public: // with description
82  inline void SetDefaultValue(const char * theDefaultValue)
83  { defaultValue = theDefaultValue; }
84  void SetDefaultValue(G4int theDefaultValue);
85  void SetDefaultValue(G4double theDefaultValue);
86  // These methods set the default value of the parameter.
87  void SetDefaultUnit(const char * theDefaultUnit);
88  // This method can be used for a string-type parameter that is
89  // used to specify a unit. This method is valid only for a
90  // string-type parameter. With this set-method, not only the
91  // default unit but also candidate units that belong to the
92  // same unit category (a.k.a. dimension) as the default unit.
93  public:
94  inline G4String GetDefaultValue() const
95  { return defaultValue; }
96  inline char GetParameterType() const
97  { return parameterType; }
98 
99  public: // with description
100  inline void SetParameterRange(const char * theRange)
101  { parameterRange = theRange; }
102  // Defines the range the parameter can take.
103  // The variable name appear in the range expression must be same
104  // as the name of the parameter.
105  // All the C++ syntax of relational operators are allowed for the
106  // range expression.
107  public:
109  { return parameterRange; }
110 
111  // parameterName
112  inline void SetParameterName(const char * theName)
113  { parameterName = theName; }
114  inline G4String GetParameterName() const
115  { return parameterName; }
116 
117  public: // with description
118  inline void SetParameterCandidates(const char * theString)
119  { parameterCandidate = theString; }
120  // This method is meaningful if the type of the parameter is string.
121  // The candidates listed in the argument must be separated by space(s).
122  public:
124  { return parameterCandidate; }
125 
126  // omittable
127  inline void SetOmittable(G4bool om)
128  { omittable = om; }
129  inline G4bool IsOmittable() const
130  { return omittable; }
131 
132  // currentAsDefaultFlag
133  inline void SetCurrentAsDefault(G4bool val)
134  { currentAsDefaultFlag = val; }
136  { return currentAsDefaultFlag; }
137 
138  // out of date methods
139  inline void SetWidget(G4int theWidget)
140  { widget = theWidget; }
141  inline const G4String GetParameterGuidance() const
142  { return parameterGuidance; }
143  inline void SetGuidance(const char * theGuidance)
144  { parameterGuidance = theGuidance; }
145 
146  protected:
149  private:
150  // --- the following is used by CheckNewValue() -------
151  G4int TypeCheck(const char* newValue );
152  G4int RangeCheck(const char* newValue );
153  G4int CandidateCheck(const char* newValue );
154  G4int IsInt(const char* str, short maxDigit);
155  G4int IsDouble(const char* str);
156  G4int ExpectExponent(const char* str);
157  // syntax nodes
158  yystype Expression( void );
161  yystype EqualityExpression ( void );
163  yystype AdditiveExpression( void );
165  yystype UnaryExpression( void );
166  yystype PrimaryExpression( void );
167  // semantics routines
168  G4int Eval2( yystype arg1, G4int op, yystype arg2 );
169  G4int CompareInt( G4int arg1, G4int op, G4int arg2);
170  G4int CompareDouble( double arg1, G4int op, double arg2);
171  // utility
172  tokenNum Yylex( void ); // returns next token
173  G4int G4UIpGetc( void ); // read one char from rangeBuf
174  G4int G4UIpUngetc( G4int c ); // put back
175  G4int Backslash( G4int c );
176  G4int Follow( G4int expect, G4int ifyes, G4int ifno );
178  //void PrintToken(void); // debug
179  // data
181  G4int bp; // buffer pointer for rangeBuf
186  //------------ end of CheckNewValue() related member --------------
187 
188 };
189 
190 #endif
191