Geant4  10.03.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4UIparameter.hh
Go to the documentation of this file.
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 // $Id: G4UIparameter.hh 67965 2013-03-13 09:35:29Z gcosmo $
28 //
29 //
30 // ---------------------------------------------------------------------
31 
32 #ifndef G4UIparameter_h
33 #define G4UIparameter_h 1
34 
35 #include "globals.hh"
36 #include "G4UItokenNum.hh"
37 
38 // class description:
39 //
40 // This class represents a parameter which will be taken by a G4UIcommand
41 // object. In case a command is defined by constructing G4UIcmdXXX class,
42 // it automatically creates necessary parameter objects, thus the user needs
43 // not to create parameter object(s) by him/herself. In case the user wants
44 // to create a command directly instansiated by G4UIcommand class, he/she
45 // must create parameter object(s) by him/herself.
46 
48 {
49  public: // with description
50  G4UIparameter();
51  G4UIparameter(char theType);
52  G4UIparameter(const char * theName, char theType, G4bool theOmittable);
53  // Constructors, where "theName" is the name of the parameter which will
54  // be used by the range checking, "theType" is the type of the parameter
55  // (currently "b" (boolean), "i" (integer), "d" (double), and "s" (string)
56  // are supported), and "theOmittable" is a boolean flag to set whether
57  // the user of the command can ommit the parameter or not. If "theOmittable"
58  // is true, the default value must be given.
60  // Destructor. When a command is destructed, the delete operator(s) for
61  // associating parameter(s) are AUTOMATICALLY invoked. Thus the user needs
62  // NOT to invoke this by him/herself.
63 
64  public:
65  G4int operator==(const G4UIparameter &right) const;
66  G4int operator!=(const G4UIparameter &right) const;
67 
68  G4int CheckNewValue(const char* newValue);
69  void List();
70 
71  private:
72  G4String parameterName;
73  G4String parameterGuidance;
74  G4String defaultValue;
75  G4String parameterRange;
76  G4String parameterCandidate;
77  char parameterType;
78  G4bool omittable;
79  G4bool currentAsDefaultFlag;
80  G4int widget;
81 
82  public: // with description
83  inline void SetDefaultValue(const char * theDefaultValue)
84  { defaultValue = theDefaultValue; }
85  void SetDefaultValue(G4int theDefaultValue);
86  void SetDefaultValue(G4double theDefaultValue);
87  // These methods set the default value of the parameter.
88  public:
89  inline G4String GetDefaultValue() const
90  { return defaultValue; }
91  inline char GetParameterType() const
92  { return parameterType; }
93 
94  public: // with description
95  inline void SetParameterRange(const char * theRange)
96  { parameterRange = theRange; }
97  // Defines the range the parameter can take.
98  // The variable name appear in the range expression must be same
99  // as the name of the parameter.
100  // All the C++ syntax of relational operators are allowed for the
101  // range expression.
102  public:
104  { return parameterRange; }
105 
106  // parameterName
107  inline void SetParameterName(const char * theName)
108  { parameterName = theName; }
109  inline G4String GetParameterName() const
110  { return parameterName; }
111 
112  public: // with description
113  inline void SetParameterCandidates(const char * theString)
114  { parameterCandidate = theString; }
115  // This method is meaningful if the type of the parameter is string.
116  // The candidates listed in the argument must be separated by space(s).
117  public:
119  { return parameterCandidate; }
120 
121  // omittable
122  inline void SetOmittable(G4bool om)
123  { omittable = om; }
124  inline G4bool IsOmittable() const
125  { return omittable; }
126 
127  // currentAsDefaultFlag
128  inline void SetCurrentAsDefault(G4bool val)
129  { currentAsDefaultFlag = val; }
131  { return currentAsDefaultFlag; }
132 
133  // out of date methods
134  inline void SetWidget(G4int theWidget)
135  { widget = theWidget; }
136  inline const G4String GetParameterGuidance() const
137  { return parameterGuidance; }
138  inline void SetGuidance(const char * theGuidance)
139  { parameterGuidance = theGuidance; }
140 
141  private:
142  // --- the following is used by CheckNewValue() -------
143  G4int TypeCheck(const char* newValue );
144  G4int RangeCheck(const char* newValue );
145  G4int CandidateCheck(const char* newValue );
146  G4int IsInt(const char* str, short maxDigit);
147  G4int IsDouble(const char* str);
148  G4int ExpectExponent(const char* str);
149  // syntax nodes
150  yystype Expression( void );
151  yystype LogicalORExpression( void );
152  yystype LogicalANDExpression( void );
153  yystype EqualityExpression ( void );
154  yystype RelationalExpression( void );
155  yystype AdditiveExpression( void );
156  yystype MultiplicativeExpression( void );
157  yystype UnaryExpression( void );
158  yystype PrimaryExpression( void );
159  // semantics routines
160  G4int Eval2( yystype arg1, G4int op, yystype arg2 );
161  G4int CompareInt( G4int arg1, G4int op, G4int arg2);
162  G4int CompareDouble( double arg1, G4int op, double arg2);
163  // utility
164  tokenNum Yylex( void ); // returns next token
165  G4int G4UIpGetc( void ); // read one char from rangeBuf
166  G4int G4UIpUngetc( G4int c ); // put back
167  G4int Backslash( G4int c );
168  G4int Follow( G4int expect, G4int ifyes, G4int ifno );
169  G4String TokenToStr(G4int token);
170  //void PrintToken(void); // debug
171  // data
172  G4String rangeBuf;
173  G4int bp; // buffer pointer for rangeBuf
174  tokenNum token;
175  yystype yylval;
176  yystype newVal;
177  G4int paramERR;
178  //------------ end of CheckNewValue() related member --------------
179 
180 };
181 
182 #endif
183 
tokenNum
Definition: G4UItokenNum.hh:36
G4String GetParameterCandidates() const
void SetParameterRange(const char *theRange)
void SetOmittable(G4bool om)
void SetParameterCandidates(const char *theString)
G4String GetParameterName() const
void SetDefaultValue(const char *theDefaultValue)
void SetParameterName(const char *theName)
int G4int
Definition: G4Types.hh:78
G4int operator==(const G4UIparameter &right) const
void SetCurrentAsDefault(G4bool val)
G4bool IsOmittable() const
G4int CheckNewValue(const char *newValue)
bool G4bool
Definition: G4Types.hh:79
void SetWidget(G4int theWidget)
G4int operator!=(const G4UIparameter &right) const
G4String GetDefaultValue() const
char GetParameterType() const
const G4String GetParameterGuidance() const
double G4double
Definition: G4Types.hh:76
tuple c
Definition: test.py:13
void SetGuidance(const char *theGuidance)
G4String GetParameterRange() const
G4bool GetCurrentAsDefault() const