Geant4 11.1.1
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4DimensionedTypeUtils Namespace Reference

Classes

class  HasName
 

Functions

G4bool GetUnitValue (const G4String &unit, G4double &value)
 

Function Documentation

◆ GetUnitValue()

G4bool G4DimensionedTypeUtils::GetUnitValue ( const G4String unit,
G4double value 
)

Definition at line 48 of file G4DimensionedTypeUtils.cc.

49 {
50 // Get units table
52 if (unitTable.empty()) G4UnitDefinition::BuildUnitsTable();
53
54 // Iterate over unit lists, searching for unit match
55 auto iterTable = unitTable.begin();
56
57 HasName myUnit(unit);
58 G4bool gotUnit(false);
59
60 while (!gotUnit && (iterTable != unitTable.end())) {
61 G4UnitsContainer unitContainer = (*iterTable)->GetUnitsList();
62
63 auto iterUnits =
64 std::find_if(unitContainer.begin(), unitContainer.end(), myUnit);
65
66 if (iterUnits != unitContainer.end()) {
67 value = (*iterUnits)->GetValue();
68 gotUnit = true;
69 }
70
71 iterTable++;
72 }
73
74 return gotUnit;
75 }
bool G4bool
Definition: G4Types.hh:86
std::vector< G4UnitDefinition * > G4UnitsContainer
std::vector< G4UnitsCategory * > G4UnitsTable
Definition: G4UnitsTable.hh:68
static void BuildUnitsTable()
static G4UnitsTable & GetUnitsTable()

Referenced by G4DimensionedType< T, ConversionErrorPolicy >::G4DimensionedType().