Import Geant4 11.3.0 source tree
This commit is contained in:
@@ -6,6 +6,24 @@ It must **not** be used as a substitute for writing good git commit messages!
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
## 2024-07-29 John Allison (intercoms-V11-02-07)
|
||||
- G4UImanager::ApplyCommand:
|
||||
- Replace `isMaster` by `G4Threading::IsMasterThread()`.
|
||||
- This controls highlighting of echoed commands in the Qt GUI.
|
||||
- This was a misunderstanding. I thought `isMaster` referred to the thread.
|
||||
It looks like it refers to a type of run manager. Luckily for MT mode,
|
||||
`isMaster` is true, but for Serial mode, it is false, so highlighting did
|
||||
not work for Serial mode. This was an oversight on my part - I should have
|
||||
tested Serial mode when I introduced highlighting in January and February
|
||||
2020 (intercoms-V10-07-01 and 2).
|
||||
|
||||
## 2024-07-16 Gabriele Cosmo (intercoms-V11-02-06)
|
||||
- More fixes for Coverity defects.
|
||||
|
||||
## 2024-07-15 Gabriele Cosmo (intercoms-V11-02-05)
|
||||
- Fixed reported Coverity defects, use consistently 'const G4String&' to
|
||||
avoid implicit copy.
|
||||
|
||||
## 2024-05-18 Makoto Asai (intercoms-V11-02-04)
|
||||
- G4GenericMessenger.cc : Further addressing to Bug Report #2606
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ class G4UImanager;
|
||||
class G4UIbridge
|
||||
{
|
||||
public:
|
||||
G4UIbridge(G4UImanager* localUI, G4String dir);
|
||||
G4UIbridge(G4UImanager* localUI, const G4String& dir);
|
||||
~G4UIbridge() = default;
|
||||
|
||||
G4int ApplyCommand(const G4String& aCmd);
|
||||
|
||||
@@ -46,7 +46,7 @@ class G4UIcmdWith3VectorAndUnit : public G4UIcommand
|
||||
// and the pointer to the messenger must be given
|
||||
G4UIcmdWith3VectorAndUnit(const char* theCommandPath, G4UImessenger* theMessenger);
|
||||
|
||||
G4int DoIt(G4String parameterList) override;
|
||||
G4int DoIt(const G4String& parameterList) override;
|
||||
|
||||
// Convert a 3 vector value to a string of digits and unit. Best unit is
|
||||
// chosen from the unit category of default unit (in case SetDefaultUnit()
|
||||
|
||||
@@ -45,7 +45,7 @@ class G4UIcmdWithADoubleAndUnit : public G4UIcommand
|
||||
// and the pointer to the messenger must be given
|
||||
G4UIcmdWithADoubleAndUnit(const char* theCommandPath, G4UImessenger* theMessenger);
|
||||
|
||||
G4int DoIt(G4String parameterList) override;
|
||||
G4int DoIt(const G4String& parameterList) override;
|
||||
|
||||
// Convert a double value to a string of digits and unit. Best unit is
|
||||
// chosen from the unit category of default unit (in case SetDefaultUnit()
|
||||
|
||||
@@ -65,7 +65,7 @@ class G4UIcommand
|
||||
G4bool operator==(const G4UIcommand& right) const;
|
||||
G4bool operator!=(const G4UIcommand& right) const;
|
||||
|
||||
virtual G4int DoIt(G4String parameterList);
|
||||
virtual G4int DoIt(const G4String& parameterList);
|
||||
|
||||
G4String GetCurrentValue();
|
||||
|
||||
|
||||
@@ -79,7 +79,7 @@ class G4UImessenger
|
||||
G4int StoI(const G4String& s);
|
||||
G4long StoL(const G4String& s);
|
||||
G4double StoD(const G4String& s);
|
||||
G4bool StoB(G4String s);
|
||||
G4bool StoB(const G4String& s);
|
||||
|
||||
void AddUIcommand(G4UIcommand* newCommand);
|
||||
|
||||
|
||||
@@ -32,7 +32,8 @@
|
||||
#include "G4UImanager.hh"
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
G4UIbridge::G4UIbridge(G4UImanager* localUI, G4String dir) : localUImanager(localUI)
|
||||
G4UIbridge::G4UIbridge(G4UImanager* localUI, const G4String& dir)
|
||||
: localUImanager(localUI)
|
||||
{
|
||||
// make sure dirName starts and ends with '/'
|
||||
if (dir[0] == '/') {
|
||||
|
||||
@@ -54,7 +54,7 @@ G4UIcmdWith3VectorAndUnit::G4UIcmdWith3VectorAndUnit(const char* theCommandPath,
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
G4int G4UIcmdWith3VectorAndUnit::DoIt(G4String parameterList)
|
||||
G4int G4UIcmdWith3VectorAndUnit::DoIt(const G4String& parameterList)
|
||||
{
|
||||
std::vector<G4String> token_vector;
|
||||
G4Tokenizer tkn(parameterList);
|
||||
|
||||
@@ -51,7 +51,7 @@ G4UIcmdWithADoubleAndUnit::G4UIcmdWithADoubleAndUnit(const char* theCommandPath,
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
G4int G4UIcmdWithADoubleAndUnit::DoIt(G4String parameterList)
|
||||
G4int G4UIcmdWithADoubleAndUnit::DoIt(const G4String& parameterList)
|
||||
{
|
||||
std::vector<G4String> token_vector;
|
||||
G4Tokenizer tkn(parameterList);
|
||||
|
||||
@@ -119,7 +119,7 @@ G4bool G4UIcommand::operator!=(const G4UIcommand& right) const
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
G4int G4UIcommand::DoIt(G4String parameterList)
|
||||
G4int G4UIcommand::DoIt(const G4String& parameterList)
|
||||
{
|
||||
G4String correctParameters;
|
||||
std::size_t n_parameterEntry = parameter.size();
|
||||
@@ -220,7 +220,7 @@ G4int G4UIcommand::DoIt(G4String parameterList)
|
||||
return 0;
|
||||
}
|
||||
|
||||
messenger->SetNewValue(this, correctParameters);
|
||||
messenger->SetNewValue(this, std::move(correctParameters));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -170,18 +170,17 @@ void G4UIcommandTree::RemoveCommand(G4UIcommand* aCommand, G4bool workerThreadOn
|
||||
return;
|
||||
}
|
||||
G4String commandPath = aCommand->GetCommandPath();
|
||||
G4String remainingPath = commandPath;
|
||||
remainingPath.erase(0, pathName.length());
|
||||
if (remainingPath.empty()) {
|
||||
commandPath.erase(0, pathName.length());
|
||||
if (commandPath.empty()) {
|
||||
guidance = nullptr;
|
||||
}
|
||||
else {
|
||||
std::size_t i = remainingPath.find('/');
|
||||
std::size_t i = commandPath.find('/');
|
||||
if (i == std::string::npos) {
|
||||
// Find command
|
||||
std::size_t n_commandEntry = command.size();
|
||||
for (std::size_t i_thCommand = 0; i_thCommand < n_commandEntry; ++i_thCommand) {
|
||||
if (remainingPath == command[i_thCommand]->GetCommandName()) {
|
||||
if (commandPath == command[i_thCommand]->GetCommandName()) {
|
||||
command.erase(command.begin() + i_thCommand);
|
||||
break;
|
||||
}
|
||||
@@ -190,7 +189,7 @@ void G4UIcommandTree::RemoveCommand(G4UIcommand* aCommand, G4bool workerThreadOn
|
||||
else {
|
||||
// Find path
|
||||
G4String nextPath = pathName;
|
||||
nextPath.append(remainingPath.substr(0, i + 1));
|
||||
nextPath.append(commandPath.substr(0, i + 1));
|
||||
std::size_t n_treeEntry = tree.size();
|
||||
for (std::size_t i_thTree = 0; i_thTree < n_treeEntry; ++i_thTree) {
|
||||
if (nextPath == tree[i_thTree]->GetPathName()) {
|
||||
@@ -310,7 +309,7 @@ G4String G4UIcommandTree::CompleteCommandPath(const G4String& aCommandPath)
|
||||
|
||||
// directory ...
|
||||
for (G4int idir = 1; idir <= Ndir; ++idir) {
|
||||
G4String fpdir = aTree->GetTree(idir)->GetPathName();
|
||||
const G4String& fpdir = aTree->GetTree(idir)->GetPathName();
|
||||
// matching test
|
||||
if (fpdir.find(remainingPath, 0) == 0) {
|
||||
if (nMatch == 0) {
|
||||
|
||||
@@ -446,9 +446,9 @@ void G4UIcontrolMessenger::SetNewValue(G4UIcommand* command, G4String newValue)
|
||||
}
|
||||
if (command == getValCmd) {
|
||||
G4Tokenizer next(newValue);
|
||||
G4String aliName = next();
|
||||
G4String com = next();
|
||||
G4String curVal = UI->GetCurrentValues(com);
|
||||
const G4String& aliName = next();
|
||||
const G4String& com = next();
|
||||
const G4String& curVal = UI->GetCurrentValues(com);
|
||||
if (!(curVal.empty())) {
|
||||
G4String theValue = curVal;
|
||||
G4String iIdx = next();
|
||||
@@ -469,7 +469,7 @@ void G4UIcontrolMessenger::SetNewValue(G4UIcommand* command, G4String newValue)
|
||||
}
|
||||
if (command == shellCommand) {
|
||||
command->ResetFailure();
|
||||
int rc = system(newValue);
|
||||
G4int rc = system(newValue);
|
||||
if (rc < 0) {
|
||||
G4ExceptionDescription ed;
|
||||
ed << "<" << newValue << "> is not a valid shell command. Command ignored.";
|
||||
@@ -503,9 +503,9 @@ void G4UIcontrolMessenger::SetNewValue(G4UIcommand* command, G4String newValue)
|
||||
if (command == ifCommand) {
|
||||
G4Tokenizer next(newValue);
|
||||
G4double l = StoD(next());
|
||||
G4String comp = next();
|
||||
const G4String& comp = next();
|
||||
G4double r = StoD(next());
|
||||
G4String mac = next();
|
||||
const G4String& mac = next();
|
||||
G4bool x = false;
|
||||
if (comp == ">") {
|
||||
x = (l > r);
|
||||
@@ -532,7 +532,7 @@ void G4UIcontrolMessenger::SetNewValue(G4UIcommand* command, G4String newValue)
|
||||
if (command == doifCommand) {
|
||||
G4Tokenizer next(newValue);
|
||||
G4double l = StoD(next());
|
||||
G4String comp = next();
|
||||
const G4String& comp = next();
|
||||
G4double r = StoD(next());
|
||||
|
||||
G4String c1 = next();
|
||||
@@ -549,7 +549,7 @@ void G4UIcontrolMessenger::SetNewValue(G4UIcommand* command, G4String newValue)
|
||||
else {
|
||||
strippedValue = c1.substr(1, c1.length() - 1);
|
||||
}
|
||||
c1 = strippedValue;
|
||||
c1 = std::move(strippedValue);
|
||||
}
|
||||
|
||||
G4bool x = false;
|
||||
@@ -577,7 +577,7 @@ void G4UIcontrolMessenger::SetNewValue(G4UIcommand* command, G4String newValue)
|
||||
}
|
||||
if (command == addCommand) {
|
||||
G4Tokenizer next(newValue);
|
||||
G4String newA = next();
|
||||
const G4String& newA = next();
|
||||
G4double l = StoD(next());
|
||||
G4double r = StoD(next());
|
||||
G4String st = "/control/alias ";
|
||||
@@ -588,7 +588,7 @@ void G4UIcontrolMessenger::SetNewValue(G4UIcommand* command, G4String newValue)
|
||||
}
|
||||
if (command == subtractCommand) {
|
||||
G4Tokenizer next(newValue);
|
||||
G4String newA = next();
|
||||
const G4String& newA = next();
|
||||
G4double l = StoD(next());
|
||||
G4double r = StoD(next());
|
||||
G4String st = "/control/alias ";
|
||||
@@ -599,7 +599,7 @@ void G4UIcontrolMessenger::SetNewValue(G4UIcommand* command, G4String newValue)
|
||||
}
|
||||
if (command == multiplyCommand) {
|
||||
G4Tokenizer next(newValue);
|
||||
G4String newA = next();
|
||||
const G4String& newA = next();
|
||||
G4double l = StoD(next());
|
||||
G4double r = StoD(next());
|
||||
G4String st = "/control/alias ";
|
||||
@@ -610,7 +610,7 @@ void G4UIcontrolMessenger::SetNewValue(G4UIcommand* command, G4String newValue)
|
||||
}
|
||||
if (command == divideCommand) {
|
||||
G4Tokenizer next(newValue);
|
||||
G4String newA = next();
|
||||
const G4String& newA = next();
|
||||
G4double l = StoD(next());
|
||||
G4double r = StoD(next());
|
||||
G4String st = "/control/alias ";
|
||||
@@ -621,7 +621,7 @@ void G4UIcontrolMessenger::SetNewValue(G4UIcommand* command, G4String newValue)
|
||||
}
|
||||
if (command == remainderCommand) {
|
||||
G4Tokenizer next(newValue);
|
||||
G4String newA = next();
|
||||
const G4String& newA = next();
|
||||
G4int l = StoI(next());
|
||||
G4int r = StoI(next());
|
||||
G4String st = "/control/alias ";
|
||||
@@ -632,10 +632,10 @@ void G4UIcontrolMessenger::SetNewValue(G4UIcommand* command, G4String newValue)
|
||||
}
|
||||
if (command == strifCommand) {
|
||||
G4Tokenizer next(newValue);
|
||||
G4String l = next();
|
||||
G4String comp = next();
|
||||
G4String r = next();
|
||||
G4String mac = next();
|
||||
const G4String& l = next();
|
||||
const G4String& comp = next();
|
||||
const G4String& r = next();
|
||||
const G4String& mac = next();
|
||||
G4bool x = false;
|
||||
if (comp == "==") {
|
||||
x = (l == r);
|
||||
@@ -649,9 +649,9 @@ void G4UIcontrolMessenger::SetNewValue(G4UIcommand* command, G4String newValue)
|
||||
}
|
||||
if (command == strdoifCommand) {
|
||||
G4Tokenizer next(newValue);
|
||||
G4String l = next();
|
||||
G4String comp = next();
|
||||
G4String r = next();
|
||||
const G4String& l = next();
|
||||
const G4String& comp = next();
|
||||
const G4String& r = next();
|
||||
|
||||
G4String c1 = next();
|
||||
G4String ca;
|
||||
@@ -667,7 +667,7 @@ void G4UIcontrolMessenger::SetNewValue(G4UIcommand* command, G4String newValue)
|
||||
else {
|
||||
strippedValue = c1.substr(1, c1.length() - 1);
|
||||
}
|
||||
c1 = strippedValue;
|
||||
c1 = std::move(strippedValue);
|
||||
}
|
||||
|
||||
G4bool x = false;
|
||||
|
||||
@@ -337,10 +337,10 @@ void G4UImanager::Loop(const char* macroFile, const char* variableName, G4double
|
||||
// --------------------------------------------------------------------
|
||||
void G4UImanager::ForeachS(const char* valueList)
|
||||
{
|
||||
G4String vl = valueList;
|
||||
const G4String& vl = valueList;
|
||||
G4Tokenizer parameterToken(vl);
|
||||
G4String mf = parameterToken();
|
||||
G4String vn = parameterToken();
|
||||
const G4String& mf = parameterToken();
|
||||
const G4String& vn = parameterToken();
|
||||
G4String c1 = parameterToken();
|
||||
G4String ca;
|
||||
while (!((ca = parameterToken()).empty())) {
|
||||
@@ -348,7 +348,7 @@ void G4UImanager::ForeachS(const char* valueList)
|
||||
c1 += ca;
|
||||
}
|
||||
|
||||
G4String aliasValue = c1;
|
||||
G4String aliasValue = std::move(c1);
|
||||
if (aliasValue[0] == '"') {
|
||||
G4String strippedValue;
|
||||
if (aliasValue.back() == '"') {
|
||||
@@ -357,7 +357,7 @@ void G4UImanager::ForeachS(const char* valueList)
|
||||
else {
|
||||
strippedValue = aliasValue.substr(1, aliasValue.length() - 1);
|
||||
}
|
||||
aliasValue = strippedValue;
|
||||
aliasValue = std::move(strippedValue);
|
||||
}
|
||||
|
||||
// Foreach(mf,vn,c1);
|
||||
@@ -445,12 +445,12 @@ G4int G4UImanager::ApplyCommand(const G4String& aCmd)
|
||||
// --------------------------------------------------------------------
|
||||
G4int G4UImanager::ApplyCommand(const char* aCmd)
|
||||
{
|
||||
G4String aCommand = SolveAlias(aCmd);
|
||||
const G4String& aCommand = SolveAlias(aCmd);
|
||||
if (aCommand.empty()) {
|
||||
return fAliasNotFound;
|
||||
}
|
||||
if (verboseLevel != 0) {
|
||||
if (isMaster) {
|
||||
if (G4Threading::IsMasterThread()) {
|
||||
fLastCommandOutputTreated = false;
|
||||
}
|
||||
G4cout << aCommand << G4endl;
|
||||
@@ -551,7 +551,7 @@ G4UIcommand* G4UImanager::FindCommand(const G4String& aCmd)
|
||||
// --------------------------------------------------------------------
|
||||
G4UIcommand* G4UImanager::FindCommand(const char* aCmd)
|
||||
{
|
||||
G4String aCommand = SolveAlias(aCmd);
|
||||
const G4String& aCommand = SolveAlias(aCmd);
|
||||
if (aCommand.empty()) {
|
||||
return nullptr;
|
||||
}
|
||||
@@ -615,7 +615,7 @@ void G4UImanager::ListCommands(const char* direct)
|
||||
// --------------------------------------------------------------------
|
||||
G4UIcommandTree* G4UImanager::FindDirectory(const char* dirName)
|
||||
{
|
||||
G4String aDirName = dirName;
|
||||
const G4String& aDirName = dirName;
|
||||
G4String targetDir = G4StrUtil::strip_copy(aDirName);
|
||||
if (targetDir.back() != '/') {
|
||||
targetDir += "/";
|
||||
@@ -666,9 +666,9 @@ void G4UImanager::SetCoutDestination(G4UIsession* const value)
|
||||
// --------------------------------------------------------------------
|
||||
void G4UImanager::SetAlias(const char* aliasLine)
|
||||
{
|
||||
G4String aLine = aliasLine;
|
||||
const G4String& aLine = aliasLine;
|
||||
std::size_t i = aLine.find(' ');
|
||||
G4String aliasName = aLine.substr(0, i);
|
||||
const G4String& aliasName = aLine.substr(0, i);
|
||||
G4String aliasValue = aLine.substr(i + 1, aLine.length() - (i + 1));
|
||||
if (aliasValue[0] == '"') {
|
||||
G4String strippedValue;
|
||||
@@ -678,7 +678,7 @@ void G4UImanager::SetAlias(const char* aliasLine)
|
||||
else {
|
||||
strippedValue = aliasValue.substr(1, aliasValue.length() - 1);
|
||||
}
|
||||
aliasValue = strippedValue;
|
||||
aliasValue = std::move(strippedValue);
|
||||
}
|
||||
|
||||
aliasList->ChangeAlias(aliasName, aliasValue);
|
||||
@@ -687,7 +687,7 @@ void G4UImanager::SetAlias(const char* aliasLine)
|
||||
// --------------------------------------------------------------------
|
||||
void G4UImanager::RemoveAlias(const char* aliasName)
|
||||
{
|
||||
G4String aL = aliasName;
|
||||
const G4String& aL = aliasName;
|
||||
G4String targetAlias = G4StrUtil::strip_copy(aL);
|
||||
aliasList->RemoveAlias(targetAlias);
|
||||
}
|
||||
@@ -728,7 +728,7 @@ void G4UImanager::ParseMacroSearchPath()
|
||||
|
||||
pathstring = searchPath.substr(idxfirst, searchPath.size() - idxfirst);
|
||||
if (!pathstring.empty()) {
|
||||
searchDirs.push_back(pathstring);
|
||||
searchDirs.push_back(std::move(pathstring));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -751,7 +751,7 @@ G4String G4UImanager::FindMacroPath(const G4String& fname) const
|
||||
G4String macrofile = fname;
|
||||
|
||||
for (const auto& searchDir : searchDirs) {
|
||||
G4String fullpath = searchDir + "/" + fname;
|
||||
const G4String& fullpath = searchDir + "/" + fname;
|
||||
if (FileFound(fullpath)) {
|
||||
macrofile = fullpath;
|
||||
break;
|
||||
|
||||
@@ -111,9 +111,9 @@ G4double G4UImessenger::StoD(const G4String& str)
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
G4bool G4UImessenger::StoB(G4String str)
|
||||
G4bool G4UImessenger::StoB(const G4String& str)
|
||||
{
|
||||
G4String v = G4StrUtil::to_upper_copy(std::move(str));
|
||||
const G4String& v = G4StrUtil::to_upper_copy(str);
|
||||
return (v == "Y" || v == "YES" || v == "1" || v == "T" || v == "TRUE");
|
||||
}
|
||||
|
||||
@@ -141,7 +141,7 @@ void G4UImessenger::CreateDirectory(const G4String& path, const G4String& dsc,
|
||||
}
|
||||
else {
|
||||
baseDir = new G4UIdirectory(fullpath.c_str(), commandsToBeBroadcasted);
|
||||
baseDirName = fullpath;
|
||||
baseDirName = std::move(fullpath);
|
||||
baseDir->SetGuidance(dsc.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -312,7 +312,7 @@ inline yystype G4UIRangeChecker::RelationalExpression()
|
||||
result.type = CONSTINT;
|
||||
}
|
||||
else {
|
||||
result = arg1;
|
||||
result = std::move(arg1);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -593,7 +593,7 @@ inline tokenNum G4UIRangeChecker::Yylex() // reads input and returns token numb
|
||||
} while ((c = G4UIpGetc()) != EOF && ((isalnum(c) != 0) || c == '_'));
|
||||
G4UIpUngetc(c);
|
||||
if (IsParameter(buf) != 0u) {
|
||||
yylval.S = buf;
|
||||
yylval.S = std::move(buf);
|
||||
return IDENTIFIER;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user