G4UIparameter.hh

Go to the documentation of this file.
00001 //
00002 // ********************************************************************
00003 // * License and Disclaimer                                           *
00004 // *                                                                  *
00005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
00006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
00007 // * conditions of the Geant4 Software License,  included in the file *
00008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
00009 // * include a list of copyright holders.                             *
00010 // *                                                                  *
00011 // * Neither the authors of this software system, nor their employing *
00012 // * institutes,nor the agencies providing financial support for this *
00013 // * work  make  any representation or  warranty, express or implied, *
00014 // * regarding  this  software system or assume any liability for its *
00015 // * use.  Please see the license in the file  LICENSE  and URL above *
00016 // * for the full disclaimer and the limitation of liability.         *
00017 // *                                                                  *
00018 // * This  code  implementation is the result of  the  scientific and *
00019 // * technical work of the GEANT4 collaboration.                      *
00020 // * By using,  copying,  modifying or  distributing the software (or *
00021 // * any work based  on the software)  you  agree  to acknowledge its *
00022 // * use  in  resulting  scientific  publications,  and indicate your *
00023 // * acceptance of all terms of the Geant4 Software license.          *
00024 // ********************************************************************
00025 //
00026 //
00027 // $Id$
00028 //
00029 // 
00030 // ---------------------------------------------------------------------
00031 
00032 #ifndef G4UIparameter_h
00033 #define G4UIparameter_h 1
00034 
00035 #include "globals.hh"
00036 #include "G4UItokenNum.hh"
00037 
00038 // class description:
00039 //
00040 //  This class represents a parameter which will be taken by a G4UIcommand
00041 // object. In case a command is defined by constructing G4UIcmdXXX class,
00042 // it automatically creates necessary parameter objects, thus the user needs 
00043 // not to create parameter object(s) by him/herself. In case the user wants 
00044 // to create a command directly instansiated by G4UIcommand class, he/she
00045 // must create parameter object(s) by him/herself.
00046 
00047 class G4UIparameter 
00048 {
00049   public: // with description
00050       G4UIparameter();
00051       G4UIparameter(char theType);
00052       G4UIparameter(const char * theName, char theType, G4bool theOmittable);
00053       // Constructors, where "theName" is the name of the parameter which will
00054       // be used by the range checking, "theType" is the type of the parameter
00055       // (currently "b" (boolean), "i" (integer), "d" (double), and "s" (string)
00056       // are supported), and "theOmittable" is a boolean flag to set whether
00057       // the user of the command can ommit the parameter or not. If "theOmittable"
00058       // is true, the default value must be given.
00059       ~G4UIparameter();
00060       // Destructor. When a command is destructed, the delete operator(s) for 
00061       // associating parameter(s) are AUTOMATICALLY invoked. Thus the user needs 
00062       // NOT to invoke this by him/herself.
00063 
00064   public:
00065       G4int operator==(const G4UIparameter &right) const;
00066       G4int operator!=(const G4UIparameter &right) const;
00067 
00068       G4int CheckNewValue(const char* newValue);
00069       void List();
00070 
00071   private:
00072       G4String parameterName;
00073       G4String parameterGuidance;
00074       G4String defaultValue;
00075       G4String parameterRange;
00076       G4String parameterCandidate;
00077       char parameterType;
00078       G4bool omittable;
00079       G4bool currentAsDefaultFlag;
00080       G4int widget;
00081 
00082   public: // with description
00083       inline void SetDefaultValue(const char * theDefaultValue)
00084       { defaultValue = theDefaultValue; }
00085       void SetDefaultValue(G4int theDefaultValue);
00086       void SetDefaultValue(G4double theDefaultValue);
00087       // These methods set the default value of the parameter.
00088   public:
00089       inline G4String GetDefaultValue() const
00090       { return defaultValue; }
00091       inline char GetParameterType() const
00092       { return parameterType; }
00093 
00094   public: // with description
00095       inline void SetParameterRange(const char * theRange)
00096       { parameterRange = theRange; }
00097       //  Defines the range the parameter can take.
00098       //  The variable name appear in the range expression must be same
00099       // as the name of the parameter.
00100       //  All the C++ syntax of relational operators are allowed for the
00101       // range expression.
00102   public:
00103       inline G4String GetParameterRange() const
00104       { return parameterRange; }
00105     
00106     // parameterName
00107       inline void SetParameterName(const char * theName)
00108       { parameterName = theName; }
00109       inline G4String GetParameterName() const
00110       { return parameterName; }
00111     
00112   public: // with description
00113       inline void SetParameterCandidates(const char * theString)
00114       { parameterCandidate = theString; }
00115       //  This method is meaningful if the type of the parameter is string.
00116       // The candidates listed in the argument must be separated by space(s).
00117   public:
00118       inline G4String GetParameterCandidates() const
00119       { return parameterCandidate; }
00120     
00121     // omittable
00122       inline void SetOmittable(G4bool om)
00123       { omittable = om; }
00124       inline G4bool IsOmittable() const
00125       { return omittable; }
00126     
00127     // currentAsDefaultFlag
00128       inline void SetCurrentAsDefault(G4bool val)
00129       { currentAsDefaultFlag = val; }
00130       inline G4bool GetCurrentAsDefault() const
00131       { return currentAsDefaultFlag; }
00132     
00133     // out of date methods
00134       inline void SetWidget(G4int theWidget)
00135       { widget = theWidget; }
00136       inline const G4String GetParameterGuidance() const
00137       { return parameterGuidance; }
00138       inline void SetGuidance(const char * theGuidance)
00139       { parameterGuidance = theGuidance; }
00140 
00141   private:
00142     // --- the following is used by CheckNewValue() -------
00143     G4int TypeCheck(const char* newValue );
00144     G4int RangeCheck(const char* newValue );
00145     G4int CandidateCheck(const char* newValue );
00146     G4int IsInt(const char* str, short maxDigit);
00147     G4int IsDouble(const char* str);
00148     G4int ExpectExponent(const char* str);
00149     //  syntax nodes
00150     yystype Expression( void );
00151     yystype LogicalORExpression( void );
00152     yystype LogicalANDExpression( void );
00153     yystype EqualityExpression ( void );
00154     yystype RelationalExpression( void );
00155     yystype AdditiveExpression( void );
00156     yystype MultiplicativeExpression( void );
00157     yystype UnaryExpression( void );
00158     yystype PrimaryExpression( void );
00159     //  semantics routines
00160     G4int Eval2( yystype arg1, G4int op, yystype arg2 );
00161     G4int CompareInt( G4int arg1, G4int op, G4int arg2);
00162     G4int CompareDouble( double arg1, G4int op, double arg2);
00163     //  utility 
00164     tokenNum Yylex( void );     // returns next token
00165     G4int G4UIpGetc( void );     // read one char from rangeBuf
00166     G4int G4UIpUngetc( G4int c );  // put back  
00167     G4int Backslash( G4int c );
00168     G4int Follow( G4int expect, G4int ifyes, G4int ifno );
00169     G4String TokenToStr(G4int token);
00170     //void PrintToken(void);  // debug
00171     //  data
00172     G4String rangeBuf;
00173     G4int bp;                  // buffer pointer for rangeBuf
00174     tokenNum token;
00175     yystype yylval;
00176     yystype newVal;
00177     G4int paramERR;
00178    //------------ end of CheckNewValue() related member --------------
00179 
00180 };
00181 
00182 #endif
00183 

Generated on Mon May 27 17:50:06 2013 for Geant4 by  doxygen 1.4.7