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10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /intercoms/include/G4UIcommand.hh (Version 11.3.0) and /intercoms/include/G4UIcommand.hh (Version 4.0.p2)


  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 // G4UIcommand                                 << 
 27 //                                                 23 //
 28 // Class description:                          <<  24 // $Id: G4UIcommand.hh,v 1.10 2001/10/16 08:14:31 gcosmo Exp $
                                                   >>  25 // GEANT4 tag $Name: geant4-04-00 $
 29 //                                                 26 //
 30 // This G4UIcommand is the "concrete" base cla <<  27 // 
 31 // used by Geant4 (G)UI. The user can use this << 
 32 // arguments of a command are not suitable wit << 
 33 // classes.                                    << 
 34 // Some methods defined in this base class are << 
 35                                                    28 
 36 // Author: Makoto Asai (SLAC), 1998            <<  29 #ifndef G4UIcommand_h
 37 // ------------------------------------------- <<  30 #define G4UIcommand_h 1
 38 #ifndef G4UIcommand_hh                         << 
 39 #define G4UIcommand_hh 1                       << 
 40                                                    31 
 41 #include "G4ApplicationState.hh"               << 
 42 #include "G4ThreeVector.hh"                    << 
 43 #include "G4UIparameter.hh"                        32 #include "G4UIparameter.hh"
                                                   >>  33 class G4UImessenger;
 44 #include "globals.hh"                              34 #include "globals.hh"
                                                   >>  35 #include "G4ApplicationState.hh"
                                                   >>  36 #include "g4std/vector"
                                                   >>  37 #include "G4UItokenNum.hh"
 45                                                    38 
 46 #include <vector>                              <<  39 // class description:
 47                                                <<  40 //  
 48 class G4UImessenger;                           <<  41 //  This G4UIcommand is the "concrete" base class which represents a command
                                                   >>  42 // used by Geant4 (G)UI. The user can use this class in case the parameter
                                                   >>  43 // arguments of a command are not suitable with respect to the derived command
                                                   >>  44 // classes.
                                                   >>  45 //  Some methods defined in this base class are used by the derived classes.
                                                   >>  46 //
 49                                                    47 
 50 class G4UIcommand                              <<  48 class G4UIcommand 
 51 {                                                  49 {
                                                   >>  50   public: 
                                                   >>  51       G4UIcommand();
                                                   >>  52   public: // with description
                                                   >>  53       G4UIcommand(const char * theCommandPath, G4UImessenger * theMessenger);
                                                   >>  54       //  Constructor. The command string with full path directory
                                                   >>  55       // and the pointer to the messenger must be given.
                                                   >>  56   public: 
                                                   >>  57       virtual ~G4UIcommand();
                                                   >>  58 
                                                   >>  59       G4int operator==(const G4UIcommand &right) const;
                                                   >>  60       G4int operator!=(const G4UIcommand &right) const;
                                                   >>  61 
                                                   >>  62       G4int DoIt(G4String parameterList);
                                                   >>  63       G4String GetCurrentValue();
                                                   >>  64   public: // with description
                                                   >>  65       void AvailableForStates(G4ApplicationState s1);
                                                   >>  66       void AvailableForStates(G4ApplicationState s1,G4ApplicationState s2);
                                                   >>  67       void AvailableForStates(G4ApplicationState s1,G4ApplicationState s2,
                                                   >>  68                               G4ApplicationState s3);
                                                   >>  69       void AvailableForStates(G4ApplicationState s1,G4ApplicationState s2,
                                                   >>  70                               G4ApplicationState s3,G4ApplicationState s4);
                                                   >>  71       void AvailableForStates(G4ApplicationState s1,G4ApplicationState s2,
                                                   >>  72                               G4ApplicationState s3,G4ApplicationState s4,
                                                   >>  73                               G4ApplicationState s5);
                                                   >>  74       //  These methods define the states where the command is available.
                                                   >>  75       // Once one of these commands is invoked, the command application will
                                                   >>  76       // be denied when Geant4 is NOT in the assigned states.
 52   public:                                          77   public:
 53     // Dummy default constructor               <<  78       G4bool IsAvailable();
 54     G4UIcommand() = default;                   <<  79       virtual void List();
 55                                                << 
 56     // Constructor. The command string with fu << 
 57     // and the pointer to the messenger must b << 
 58     // If tBB is set to false, this command wo << 
 59     // This tBB parameter could be changed wit << 
 60     // except for G4UIdirectory                << 
 61     G4UIcommand(const char* theCommandPath, G4 << 
 62                                                << 
 63     virtual ~G4UIcommand();                    << 
 64                                                << 
 65     G4bool operator==(const G4UIcommand& right << 
 66     G4bool operator!=(const G4UIcommand& right << 
 67                                                << 
 68     virtual G4int DoIt(const G4String& paramet << 
 69                                                << 
 70     G4String GetCurrentValue();                << 
 71                                                << 
 72     // These methods define the states where t << 
 73     // Once one of these commands is invoked,  << 
 74     // be denied when Geant4 is NOT in the ass << 
 75     void AvailableForStates(G4ApplicationState << 
 76     void AvailableForStates(G4ApplicationState << 
 77     void AvailableForStates(G4ApplicationState << 
 78     void AvailableForStates(G4ApplicationState << 
 79                             G4ApplicationState << 
 80     void AvailableForStates(G4ApplicationState << 
 81                             G4ApplicationState << 
 82                                                << 
 83     G4bool IsAvailable();                      << 
 84                                                << 
 85     virtual void List();                       << 
 86                                                << 
 87     // Static methods for conversion from valu << 
 88     // These methods are to be used by GetCurr << 
 89     // of concrete messengers                  << 
 90     static G4String ConvertToString(G4bool boo << 
 91     static G4String ConvertToString(G4int intV << 
 92     static G4String ConvertToString(G4long lon << 
 93     static G4String ConvertToString(G4double d << 
 94     static G4String ConvertToString(G4double d << 
 95     static G4String ConvertToString(const G4Th << 
 96     static G4String ConvertToString(const G4Th << 
 97                                                << 
 98     // Static methods for conversion from a st << 
 99     // type. These methods are to be used dire << 
100     // of concrete messengers, or GetNewXXXVal << 
101     // this G4UIcommand class                  << 
102     static G4bool ConvertToBool(const char* st << 
103     static G4int ConvertToInt(const char* st); << 
104     static G4long ConvertToLongInt(const char* << 
105     static G4double ConvertToDouble(const char << 
106     static G4double ConvertToDimensionedDouble << 
107     static G4ThreeVector ConvertTo3Vector(cons << 
108     static G4ThreeVector ConvertToDimensioned3 << 
109                                                << 
110     // Static methods for unit and its categor << 
111     static G4double ValueOf(const char* unitNa << 
112     static G4String CategoryOf(const char* uni << 
113     static G4String UnitsList(const char* unit << 
114                                                << 
115     // Defines the range the command parameter << 
116     // The variable name(s) appear in the rang << 
117     // as the name(s) of the parameter(s).     << 
118     // All the C++ syntax of relational operat << 
119     // range expression                        << 
120     inline void SetRange(const char* rs) { ran << 
121                                                << 
122     inline const G4String& GetRange() const {  << 
123     inline std::size_t GetGuidanceEntries() co << 
124     inline const G4String& GetGuidanceLine(G4i << 
125     inline const G4String& GetCommandPath() co << 
126     inline const G4String& GetCommandName() co << 
127     inline std::size_t GetParameterEntries() c << 
128     inline G4UIparameter* GetParameter(G4int i << 
129     inline std::vector<G4ApplicationState>* Ge << 
130     inline G4UImessenger* GetMessenger() const << 
131                                                << 
132     // Defines a parameter. This method is use << 
133     // classes but the user can directly use t << 
134     // a command, without using the derived cl << 
135     // of the parameters is the order of invok << 
136     inline void SetParameter(G4UIparameter* co << 
137     {                                          << 
138       parameter.push_back(newParameter);       << 
139     }                                          << 
140                                                << 
141     // Adds a guidance line. Unlimited times o << 
142     // allowed. The given lines of guidance wi << 
143     // The first line of the guidance will be  << 
144     // command, i.e. one line list of the comm << 
145     inline void SetGuidance(const char* aGuida << 
146                                                << 
147     inline const G4String GetTitle() const     << 
148     {                                          << 
149       return (commandGuidance.empty()) ? G4Str << 
150     }                                          << 
151                                                << 
152     inline void SetToBeBroadcasted(G4bool val) << 
153     inline G4bool ToBeBroadcasted() const { re << 
154     inline void SetToBeFlushed(G4bool val) { t << 
155     inline G4bool ToBeFlushed() const { return << 
156     inline void SetWorkerThreadOnly(G4bool val << 
157     inline G4bool IsWorkerThreadOnly() const { << 
158                                                << 
159     inline void CommandFailed(G4int errCode, G << 
160     {                                          << 
161       commandFailureCode = errCode;            << 
162       failureDescription = ed.str();           << 
163     }                                          << 
164     inline void CommandFailed(G4ExceptionDescr << 
165     {                                          << 
166       commandFailureCode = 1;                  << 
167       failureDescription = ed.str();           << 
168     }                                          << 
169     inline G4int IfCommandFailed() { return co << 
170     inline const G4String& GetFailureDescripti << 
171     inline void ResetFailure()                 << 
172     {                                          << 
173       commandFailureCode = 0;                  << 
174       failureDescription = "";                 << 
175     }                                          << 
176                                                    80 
177   public:                                          81   public:
178     enum CommandType                           <<  82       static G4double ValueOf(G4String unitName);
179     {                                          <<  83       static G4String CategoryOf(G4String unitName);
180       BaseClassCmd,                            <<  84       static G4String UnitsList(G4String unitCategory);
181       WithoutParameterCmd,                     <<  85 
182       WithABoolCmd,                            <<  86   private:  
183       WithAnIntegerCmd,                        <<  87       void G4UIcommandCommonConstructorCode (const char * theCommandPath);
184       WithALongIntCmd,                         <<  88       G4UImessenger *messenger;
185       WithADoubleCmd,                          <<  89       G4String commandPath;
186       WithADoubleAndUnitCmd,                   <<  90       G4String commandName;
187       With3VectorCmd,                          <<  91       G4String rangeString;
188       With3VectorAndUnitCmd,                   <<  92       G4std::vector<G4UIparameter*> parameter;
189       WithAStringCmd,                          <<  93       G4std::vector<G4String> commandGuidance;
190       CmdDirectory = -1                        <<  94       G4std::vector<G4ApplicationState> availabelStateList;
191     };                                         <<  95 
192                                                <<  96   public: // with description
193     inline CommandType GetCommandType() const  <<  97       inline void SetRange(const char* rs)
194     void SetCommandType(CommandType);          <<  98       { rangeString = rs; }
195                                                <<  99       //  Defines the range the command parameter(s) can take.
196     inline void SetDefaultSortFlag(G4bool val) << 100       //  The variable name(s) appear in the range expression must be same
                                                   >> 101       // as the name(s) of the parameter(s).
                                                   >> 102       //  All the C++ syntax of relational operators are allowed for the
                                                   >> 103       // range expression.
                                                   >> 104   public:
                                                   >> 105       inline const G4String GetRange() const
                                                   >> 106       { return rangeString; };
                                                   >> 107       inline G4int GetGuidanceEntries() const
                                                   >> 108       { return commandGuidance.size(); }
                                                   >> 109       inline const G4String GetGuidanceLine(G4int i) const
                                                   >> 110       { return commandGuidance[i]; }
                                                   >> 111       inline const G4String GetCommandPath() const
                                                   >> 112       { return commandPath; }
                                                   >> 113       inline const G4String GetCommandName() const
                                                   >> 114       { return commandName; }
                                                   >> 115       inline G4int GetParameterEntries() const
                                                   >> 116       { return parameter.size(); }
                                                   >> 117       inline G4UIparameter * GetParameter(G4int i) const
                                                   >> 118       { return parameter[i]; }
                                                   >> 119       inline G4std::vector<G4ApplicationState>* GetStateList()
                                                   >> 120       { return &availabelStateList; }
                                                   >> 121   public: // with description
                                                   >> 122       inline void SetParameter(G4UIparameter *const newParameter)
                                                   >> 123       {
                                                   >> 124   parameter.push_back( newParameter );
                                                   >> 125   newVal.resize( parameter.size() );
                                                   >> 126       }
                                                   >> 127       //  Defines a parameter. This method is used by the derived command classes
                                                   >> 128       // but the user can directly use this command when he/she defines a command
                                                   >> 129       // by hem(her)self without using the derived class. For this case, the order
                                                   >> 130       // of the parameters is the order of invoking this method.
                                                   >> 131       inline void SetGuidance(const char * aGuidance)
                                                   >> 132       { 
                                                   >> 133         G4String * theGuidance = new G4String( aGuidance );
                                                   >> 134         commandGuidance.push_back( *theGuidance ); 
                                                   >> 135       }
                                                   >> 136       //  Adds a guidance line. Unlimitted number of invokation of this method is
                                                   >> 137       // allowed. The given lines of guidance will appear for the help. The first
                                                   >> 138       // line of the guidance will be used as the title of the command, i.e. one
                                                   >> 139       // line list of the commands.
                                                   >> 140   public:
                                                   >> 141       inline const G4String GetTitle() const
                                                   >> 142       {
                                                   >> 143       if(commandGuidance.size() == 0)
                                                   >> 144       { return G4String("...Title not available..."); }
                                                   >> 145       else
                                                   >> 146       { return commandGuidance[0]; }
                                                   >> 147       }
197                                                   148 
198   protected:                                      149   protected:
199     G4int CheckNewValue(const char* newValue); << 150     G4int CheckNewValue(G4String newValue);
200                                                << 
201     G4bool toBeBroadcasted = false;            << 
202     G4bool toBeFlushed = false;                << 
203     G4bool workerThreadOnly = false;           << 
204                                                << 
205     G4int commandFailureCode = 0;              << 
206     G4String failureDescription = "";          << 
207                                                << 
208     G4bool ifSort = false;                     << 
209                                                   151 
                                                   >> 152     // --- the following is used by CheckNewValue() --------
210   private:                                        153   private:
211     void G4UIcommandCommonConstructorCode(cons << 154     G4int TypeCheck(G4String newValue);
212                                                << 155     G4int RangeCheck(G4String newValue);
213   private:                                     << 156     G4int IsInt(const char* str, short maxLength);
214     CommandType commandType = BaseClassCmd;    << 157     G4int IsDouble(const char* str);
215     G4UImessenger* messenger = nullptr;        << 158     G4int ExpectExponent(const char* str);
216     G4String commandPath;                      << 159     //  syntax nodes
217     G4String commandName;                      << 160     yystype Expression( void );
218     G4String rangeExpression;                  << 161     yystype LogicalORExpression( void );
219     std::vector<G4UIparameter*> parameter;     << 162     yystype LogicalANDExpression( void );
220     std::vector<G4String> commandGuidance;     << 163     yystype EqualityExpression ( void );
221     std::vector<G4ApplicationState> availabelS << 164     yystype RelationalExpression( void );
                                                   >> 165     yystype AdditiveExpression( void );
                                                   >> 166     yystype MultiplicativeExpression( void );
                                                   >> 167     yystype UnaryExpression( void );
                                                   >> 168     yystype PrimaryExpression( void );
                                                   >> 169     //  semantics routines
                                                   >> 170     G4int Eval2( yystype arg1, G4int op, yystype arg2 );
                                                   >> 171     G4int CompareInt( G4int arg1, G4int op, G4int arg2);
                                                   >> 172     G4int CompareDouble( G4double arg1, G4int op, G4double arg2);
                                                   >> 173     //  utility 
                                                   >> 174     tokenNum Yylex( void );      // returns next token
                                                   >> 175     unsigned IndexOf( G4String ); // returns the index of the var name
                                                   >> 176     unsigned IsParameter( G4String ); // returns 1 or 0
                                                   >> 177     G4int G4UIpGetc( void );      // read one char from rangeBuf
                                                   >> 178     G4int G4UIpUngetc( G4int c );   // put back  
                                                   >> 179     G4int Backslash( G4int c );
                                                   >> 180     G4int Follow( G4int expect, G4int ifyes, G4int ifno );
                                                   >> 181     G4String TokenToStr(G4int token);
                                                   >> 182     void PrintToken(void);      // for debug
                                                   >> 183     //  data
                                                   >> 184     G4String rangeBuf;
                                                   >> 185     G4int bp;                      // buffer pointer for rangeBuf
                                                   >> 186     tokenNum token;
                                                   >> 187     yystype yylval;
                                                   >> 188     G4std::vector<yystype>  newVal;
                                                   >> 189     G4int paramERR;
222 };                                                190 };
223                                                   191 
224 #endif                                            192 #endif
                                                   >> 193 
225                                                   194