Import Geant4 11.2.0.beta source tree
This commit is contained in:
@@ -38,30 +38,28 @@
|
||||
#ifndef G4UIcommand_hh
|
||||
#define G4UIcommand_hh 1
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "G4UIparameter.hh"
|
||||
#include "globals.hh"
|
||||
#include "G4ApplicationState.hh"
|
||||
#include "G4UItokenNum.hh"
|
||||
#include "G4ThreeVector.hh"
|
||||
#include "G4UIparameter.hh"
|
||||
#include "G4UItokenNum.hh"
|
||||
#include "globals.hh"
|
||||
|
||||
#include <vector>
|
||||
|
||||
class G4UImessenger;
|
||||
|
||||
class G4UIcommand
|
||||
{
|
||||
public:
|
||||
|
||||
// Dummy default constructor
|
||||
G4UIcommand() = default;
|
||||
// Dummy default constructor
|
||||
|
||||
G4UIcommand(const char* theCommandPath, G4UImessenger* theMessenger,
|
||||
G4bool tBB = true);
|
||||
// Constructor. The command string with full path directory
|
||||
// and the pointer to the messenger must be given.
|
||||
// If tBB is set to false, this command won't be sent to worker threads.
|
||||
// This tBB parameter could be changed with SetToBeBroadcasted() method
|
||||
// except for G4UIdirectory
|
||||
// Constructor. The command string with full path directory
|
||||
// and the pointer to the messenger must be given.
|
||||
// If tBB is set to false, this command won't be sent to worker threads.
|
||||
// This tBB parameter could be changed with SetToBeBroadcasted() method
|
||||
// except for G4UIdirectory
|
||||
G4UIcommand(const char* theCommandPath, G4UImessenger* theMessenger, G4bool tBB = true);
|
||||
|
||||
virtual ~G4UIcommand();
|
||||
|
||||
@@ -72,35 +70,36 @@ class G4UIcommand
|
||||
|
||||
G4String GetCurrentValue();
|
||||
|
||||
// These methods define the states where the command is available.
|
||||
// Once one of these commands is invoked, the command application will
|
||||
// be denied when Geant4 is NOT in the assigned states
|
||||
void AvailableForStates(G4ApplicationState s1);
|
||||
void AvailableForStates(G4ApplicationState s1, G4ApplicationState s2);
|
||||
void AvailableForStates(G4ApplicationState s1, G4ApplicationState s2,
|
||||
G4ApplicationState s3);
|
||||
void AvailableForStates(G4ApplicationState s1, G4ApplicationState s2,
|
||||
G4ApplicationState s3, G4ApplicationState s4);
|
||||
void AvailableForStates(G4ApplicationState s1, G4ApplicationState s2,
|
||||
G4ApplicationState s3, G4ApplicationState s4,
|
||||
G4ApplicationState s5);
|
||||
// These methods define the states where the command is available.
|
||||
// Once one of these commands is invoked, the command application will
|
||||
// be denied when Geant4 is NOT in the assigned states
|
||||
void AvailableForStates(G4ApplicationState s1, G4ApplicationState s2, G4ApplicationState s3);
|
||||
void AvailableForStates(G4ApplicationState s1, G4ApplicationState s2, G4ApplicationState s3,
|
||||
G4ApplicationState s4);
|
||||
void AvailableForStates(G4ApplicationState s1, G4ApplicationState s2, G4ApplicationState s3,
|
||||
G4ApplicationState s4, G4ApplicationState s5);
|
||||
|
||||
G4bool IsAvailable();
|
||||
|
||||
virtual void List();
|
||||
|
||||
// Static methods for conversion from value(s) to a string.
|
||||
// These methods are to be used by GetCurrentValues() methods
|
||||
// of concrete messengers
|
||||
static G4String ConvertToString(G4bool boolVal);
|
||||
static G4String ConvertToString(G4int intValue);
|
||||
static G4String ConvertToString(G4long longValue);
|
||||
static G4String ConvertToString(G4double doubleValue);
|
||||
static G4String ConvertToString(G4double doubleValue, const char* unitName);
|
||||
static G4String ConvertToString(const G4ThreeVector& vec);
|
||||
static G4String ConvertToString(const G4ThreeVector& vec,
|
||||
const char* unitName);
|
||||
// Static methods for conversion from value(s) to a string.
|
||||
// These methods are to be used by GetCurrentValues() methods
|
||||
// of concrete messengers
|
||||
static G4String ConvertToString(const G4ThreeVector& vec, const char* unitName);
|
||||
|
||||
// Static methods for conversion from a string to a value of the returning
|
||||
// type. These methods are to be used directly by SetNewValues() methods
|
||||
// of concrete messengers, or GetNewXXXValue() of classes derived from
|
||||
// this G4UIcommand class
|
||||
static G4bool ConvertToBool(const char* st);
|
||||
static G4int ConvertToInt(const char* st);
|
||||
static G4long ConvertToLongInt(const char* st);
|
||||
@@ -108,72 +107,55 @@ class G4UIcommand
|
||||
static G4double ConvertToDimensionedDouble(const char* st);
|
||||
static G4ThreeVector ConvertTo3Vector(const char* st);
|
||||
static G4ThreeVector ConvertToDimensioned3Vector(const char* st);
|
||||
// Static methods for conversion from a string to a value of the returning
|
||||
// type. These methods are to be used directly by SetNewValues() methods
|
||||
// of concrete messengers, or GetNewXXXValue() of classes derived from
|
||||
// this G4UIcommand class
|
||||
|
||||
// Static methods for unit and its category
|
||||
static G4double ValueOf(const char* unitName);
|
||||
static G4String CategoryOf(const char* unitName);
|
||||
static G4String UnitsList(const char* unitCategory);
|
||||
// Static methods for unit and its category
|
||||
|
||||
inline void SetRange(const char* rs) { rangeString = rs; }
|
||||
// Defines the range the command parameter(s) can take.
|
||||
// The variable name(s) appear in the range expression must be the same
|
||||
// as the name(s) of the parameter(s).
|
||||
// All the C++ syntax of relational operators are allowed for the
|
||||
// range expression
|
||||
// Defines the range the command parameter(s) can take.
|
||||
// The variable name(s) appear in the range expression must be the same
|
||||
// as the name(s) of the parameter(s).
|
||||
// All the C++ syntax of relational operators are allowed for the
|
||||
// range expression
|
||||
inline void SetRange(const char* rs) { rangeExpression = rs; }
|
||||
|
||||
inline const G4String& GetRange() const { return rangeString; }
|
||||
inline std::size_t GetGuidanceEntries() const
|
||||
{
|
||||
return commandGuidance.size();
|
||||
}
|
||||
inline const G4String& GetGuidanceLine(G4int i) const
|
||||
{
|
||||
return commandGuidance[i];
|
||||
}
|
||||
inline const G4String& GetRange() const { return rangeExpression; }
|
||||
inline std::size_t GetGuidanceEntries() const { return commandGuidance.size(); }
|
||||
inline const G4String& GetGuidanceLine(G4int i) const { return commandGuidance[i]; }
|
||||
inline const G4String& GetCommandPath() const { return commandPath; }
|
||||
inline const G4String& GetCommandName() const { return commandName; }
|
||||
inline std::size_t GetParameterEntries() const { return parameter.size(); }
|
||||
inline G4UIparameter* GetParameter(G4int i) const { return parameter[i]; }
|
||||
inline std::vector<G4ApplicationState>* GetStateList()
|
||||
{
|
||||
return &availabelStateList;
|
||||
}
|
||||
inline std::vector<G4ApplicationState>* GetStateList() { return &availabelStateList; }
|
||||
inline G4UImessenger* GetMessenger() const { return messenger; }
|
||||
|
||||
// Defines a parameter. This method is used by the derived command
|
||||
// classes but the user can directly use this command when defining
|
||||
// a command, without using the derived class. For this case, the order
|
||||
// of the parameters is the order of invoking this method
|
||||
inline void SetParameter(G4UIparameter* const newParameter)
|
||||
// Defines a parameter. This method is used by the derived command
|
||||
// classes but the user can directly use this command when defining
|
||||
// a command, without using the derived class. For this case, the order
|
||||
// of the parameters is the order of invoking this method
|
||||
{
|
||||
parameter.push_back(newParameter);
|
||||
newVal.resize(parameter.size());
|
||||
}
|
||||
|
||||
inline void SetGuidance(const char* aGuidance)
|
||||
// Adds a guidance line. Unlimited times of invokation of this method is
|
||||
// allowed. The given lines of guidance will appear for the help.
|
||||
// The first line of the guidance will be used as the title of the
|
||||
// command, i.e. one line list of the commands
|
||||
{
|
||||
commandGuidance.emplace_back(aGuidance);
|
||||
}
|
||||
// Adds a guidance line. Unlimited times of invokation of this method is
|
||||
// allowed. The given lines of guidance will appear for the help.
|
||||
// The first line of the guidance will be used as the title of the
|
||||
// command, i.e. one line list of the commands
|
||||
inline void SetGuidance(const char* aGuidance) { commandGuidance.emplace_back(aGuidance); }
|
||||
|
||||
inline const G4String GetTitle() const
|
||||
{
|
||||
return (commandGuidance.empty()) ? G4String("...Title not available...")
|
||||
: commandGuidance[0];
|
||||
return (commandGuidance.empty()) ? G4String("...Title not available...") : commandGuidance[0];
|
||||
}
|
||||
|
||||
inline void SetToBeBroadcasted(G4bool val) { toBeBroadcasted = val; }
|
||||
inline G4bool ToBeBroadcasted() const { return toBeBroadcasted; }
|
||||
inline void SetToBeFlushed(G4bool val) { toBeFlushed = val; }
|
||||
inline G4bool ToBeFlushed() const { return toBeFlushed; }
|
||||
inline void SetWorkerThreadOnly(G4bool val = true) { workerThreadOnly=val; }
|
||||
inline void SetWorkerThreadOnly(G4bool val = true) { workerThreadOnly = val; }
|
||||
inline G4bool IsWorkerThreadOnly() const { return workerThreadOnly; }
|
||||
|
||||
inline void CommandFailed(G4int errCode, G4ExceptionDescription& ed)
|
||||
@@ -187,7 +169,7 @@ class G4UIcommand
|
||||
failureDescription = ed.str();
|
||||
}
|
||||
inline G4int IfCommandFailed() { return commandFailureCode; }
|
||||
inline const G4String& GetFailureDescription() {return failureDescription;}
|
||||
inline const G4String& GetFailureDescription() { return failureDescription; }
|
||||
inline void ResetFailure()
|
||||
{
|
||||
commandFailureCode = 0;
|
||||
@@ -195,23 +177,29 @@ class G4UIcommand
|
||||
}
|
||||
|
||||
public:
|
||||
enum CommandType
|
||||
{ BaseClassCmd, WithoutParameterCmd,
|
||||
WithABoolCmd, WithAnIntegerCmd, WithALongIntCmd,
|
||||
WithADoubleCmd, WithADoubleAndUnitCmd, With3VectorCmd, With3VectorAndUnitCmd,
|
||||
WithAStringCmd, CmdDirectory = -1 };
|
||||
|
||||
inline CommandType GetCommandType() const
|
||||
{ return commandType; }
|
||||
enum CommandType
|
||||
{
|
||||
BaseClassCmd,
|
||||
WithoutParameterCmd,
|
||||
WithABoolCmd,
|
||||
WithAnIntegerCmd,
|
||||
WithALongIntCmd,
|
||||
WithADoubleCmd,
|
||||
WithADoubleAndUnitCmd,
|
||||
With3VectorCmd,
|
||||
With3VectorAndUnitCmd,
|
||||
WithAStringCmd,
|
||||
CmdDirectory = -1
|
||||
};
|
||||
|
||||
inline CommandType GetCommandType() const { return commandType; }
|
||||
void SetCommandType(CommandType);
|
||||
|
||||
inline void SetDefaultSortFlag(G4bool val)
|
||||
{ ifSort = val; }
|
||||
inline void SetDefaultSortFlag(G4bool val) { ifSort = val; }
|
||||
|
||||
protected:
|
||||
|
||||
// --- the following is used by CheckNewValue() --------
|
||||
using yystype = G4UItokenNum::yystype;
|
||||
using yystype = G4UItokenNum::yystype;
|
||||
using tokenNum = G4UItokenNum::tokenNum;
|
||||
|
||||
G4int CheckNewValue(const char* newValue);
|
||||
@@ -226,14 +214,10 @@ class G4UIcommand
|
||||
G4bool ifSort = false;
|
||||
|
||||
private:
|
||||
|
||||
void G4UIcommandCommonConstructorCode(const char* theCommandPath);
|
||||
|
||||
G4int TypeCheck(const char* t);
|
||||
G4int RangeCheck(const char* t);
|
||||
G4int IsInt(const char* str, short maxLength); // used for both int and long int
|
||||
G4int IsDouble(const char* str);
|
||||
G4int ExpectExponent(const char* str);
|
||||
G4bool RangeCheck(const char* t);
|
||||
|
||||
// syntax nodes
|
||||
yystype Expression();
|
||||
yystype LogicalORExpression();
|
||||
@@ -246,19 +230,14 @@ class G4UIcommand
|
||||
yystype PrimaryExpression();
|
||||
// semantics routines
|
||||
G4int Eval2(const yystype& arg1, G4int op, const yystype& arg2);
|
||||
G4int CompareInt(G4int arg1, G4int op, G4int arg2);
|
||||
G4int CompareLong(G4long arg1, G4int op, G4long arg2);
|
||||
G4int CompareDouble(G4double arg1, G4int op, G4double arg2);
|
||||
// utility
|
||||
tokenNum Yylex(); // returns next token
|
||||
unsigned IndexOf(const char*); // returns the index of the var name
|
||||
tokenNum Yylex(); // returns next token
|
||||
unsigned IndexOf(const char*); // returns the index of the var name
|
||||
unsigned IsParameter(const char*); // returns 1 or 0
|
||||
G4int G4UIpGetc(); // read one char from rangeBuf
|
||||
G4int G4UIpUngetc(G4int c); // put back
|
||||
G4int G4UIpGetc(); // read one char from rangeBuf
|
||||
G4int G4UIpUngetc(G4int c); // put back
|
||||
G4int Backslash(G4int c);
|
||||
G4int Follow(G4int expect, G4int ifyes, G4int ifno);
|
||||
//G4String TokenToStr(G4int token);
|
||||
//void PrintToken(void); // for debug
|
||||
|
||||
// Data -----------------------------------------------------------
|
||||
|
||||
@@ -267,13 +246,12 @@ class G4UIcommand
|
||||
G4UImessenger* messenger = nullptr;
|
||||
G4String commandPath;
|
||||
G4String commandName;
|
||||
G4String rangeString;
|
||||
G4String rangeExpression;
|
||||
std::vector<G4UIparameter*> parameter;
|
||||
std::vector<G4String> commandGuidance;
|
||||
std::vector<G4ApplicationState> availabelStateList;
|
||||
|
||||
G4String rangeBuf;
|
||||
G4int bp = 0; // buffer pointer for rangeBuf
|
||||
G4int bp = 0; // current index into rangeExpression
|
||||
tokenNum token = G4UItokenNum::IDENTIFIER;
|
||||
yystype yylval;
|
||||
std::vector<yystype> newVal;
|
||||
|
||||
Reference in New Issue
Block a user