Import Geant4 11.2.2 source tree

This commit is contained in:
Gabriele Cosmo
2024-06-21 15:46:33 +02:00
parent dda54bbdcf
commit f7b23877ed
411 changed files with 22817 additions and 21317 deletions
+8
View File
@@ -6,6 +6,14 @@ It must **not** be used as a substitute for writing good git commit messages!
-------------------------------------------------------------------------------
## 2024-05-18 Makoto Asai (intercoms-V11-01-09)
- G4GenericMessenger.cc : Further addressing to Bug Report #2606
## 2024-04-24 Makoto Asai
- G4UIparsing.hh : checking int or long int parameter value is withing the
range of G4int or G4long
- G4GenericMessenger.cc : Addressing to Bug Report #2606
## 2023-10-16 Makoto Asai (intercoms-V11-01-08)
- Add G4UImessenger::LtoS().
- Missed when StoL() was introduced.
@@ -56,6 +56,27 @@ inline G4String TtoS(T value)
return os.str();
}
// Check if the value is within the range of (long) int
inline G4bool ChkMax(const char* str, short maxDigits)
{
if(maxDigits > 10) {
// long int assumed
auto tmpval = std::stoll(str);
if(tmpval > LONG_MAX || tmpval < LONG_MIN) {
G4cerr << "input string '" << str << "' out-of-range for conversion to 'long int' value" << G4endl;
return false;
}
} else {
// int assumed
auto tmpval = std::stol(str);
if(tmpval > INT_MAX || tmpval < INT_MIN) {
G4cerr << "input string '" << str << "' out-of-range for conversion to 'int' value" << G4endl;
return false;
}
}
return true;
}
// Return true if `str` parses to an integral number no more than `maxDigit` digits
inline G4bool IsInt(const char* str, short maxDigits)
{
@@ -74,7 +95,7 @@ inline G4bool IsInt(const char* str, short maxDigits)
G4cerr << "digit length exceeds" << G4endl;
return false;
}
return true;
return ChkMax(str,maxDigits);
}
}
return false;
+27 -1
View File
@@ -33,20 +33,26 @@
// M.Asai, SLAC - 04 May 2014
// Fix core dump when GetCurrentValue() method is invoked for
// a command defined by DeclareMethod().
// M.Asai, SLAC - 30 September 2020
// Adding new parameter type 'L' for long int.
// M.Asai, SLAC - 11 July 2021
// Adding G4ThreeVector type without unit
// M.Asai, JLab - 24 April 2024
// Fix DeclareMethod() wrongly converts valid boolean parameters.
// --------------------------------------------------------------------
#include "G4GenericMessenger.hh"
#include "G4Threading.hh"
#include "G4Types.hh"
#include "G4UIcmdWithABool.hh"
#include "G4UIcmdWith3Vector.hh"
#include "G4UIcmdWith3VectorAndUnit.hh"
#include "G4UIcmdWithADoubleAndUnit.hh"
#include "G4UIcommand.hh"
#include "G4UIdirectory.hh"
#include "G4UImessenger.hh"
#include "G4Tokenizer.hh"
#include <iostream>
@@ -228,6 +234,13 @@ void G4GenericMessenger::SetNewValue(G4UIcommand* command, G4String newValue)
else if (typeid(*command) == typeid(G4UIcmdWith3VectorAndUnit)) {
newValue = G4UIcommand::ConvertToString(G4UIcommand::ConvertToDimensioned3Vector(newValue));
}
else if (typeid(*command) == typeid(G4UIcmdWithABool)) {
if(StoB(newValue)) {
newValue = "1";
} else {
newValue = "0";
}
}
if (properties.find(command->GetCommandName()) != properties.cend()) {
Property& p = properties[command->GetCommandName()];
@@ -239,7 +252,20 @@ void G4GenericMessenger::SetNewValue(G4UIcommand* command, G4String newValue)
m.method.operator()(m.object);
}
else if (m.method.NArg() > 0) {
m.method.operator()(m.object, newValue);
G4Tokenizer tokens(newValue);
G4String paraValue;
for (std::size_t i = 0; i < m.method.NArg(); ++i) {
G4String aToken = tokens();
if(m.method.ArgType(i)==typeid(bool)) {
if(StoB(aToken)) {
aToken = "1";
} else {
aToken = "0";
}
}
paraValue += aToken + " ";
}
m.method.operator()(m.object, paraValue);
}
else {
throw G4InvalidUICommand();