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

Functions

template<typename T >
G4bool ExtractAttDef (const T &object, const G4String &name, G4AttDef &def)
 
template<typename T >
G4bool ExtractAttValue (const T &object, const G4String &name, G4AttValue &attVal)
 
G4TypeKey GetKey (const G4AttDef &def)
 

Function Documentation

◆ ExtractAttDef()

template<typename T >
G4bool G4AttUtils::ExtractAttDef ( const T &  object,
const G4String name,
G4AttDef def 
)

Definition at line 61 of file G4AttUtils.hh.

62 {
63 const std::map<G4String, G4AttDef>* attDefs = object.GetAttDefs();
64
65 std::map<G4String, G4AttDef>::const_iterator iter = attDefs->find(name);
66 if (iter == attDefs->end()) return false;
67
68 def = iter->second;
69
70 return true;
71 }

Referenced by G4TrajectoryDrawByAttribute::Draw(), and G4AttributeFilterT< T >::Evaluate().

◆ ExtractAttValue()

template<typename T >
G4bool G4AttUtils::ExtractAttValue ( const T &  object,
const G4String name,
G4AttValue attVal 
)

Definition at line 75 of file G4AttUtils.hh.

76 {
77 std::vector<G4AttValue>* attValues = object.CreateAttValues();
78
79 std::vector<G4AttValue>::iterator iter = std::find_if(attValues->begin(), attValues->end(),
80 HasName<G4AttValue>(name));
81 if (iter == attValues->end()) return false;
82
83 attVal = *iter;
84
85 // Clean up
86 delete attValues;
87
88 return true;
89 }

Referenced by G4TrajectoryDrawByAttribute::Draw(), and G4AttributeFilterT< T >::Evaluate().

◆ GetKey()

G4TypeKey G4AttUtils::GetKey ( const G4AttDef def)

Definition at line 40 of file G4AttUtils.cc.

41 {
42 G4String type = def.GetValueType();
43
44 G4bool withUnit = (def.GetExtra() == "G4BestUnit");
45
46 // Known conversions
47 if (type == "G4String") return G4TypeKeyT<G4String>();
48 if (type == "G4int") return G4TypeKeyT<G4int>();
49 if (type == "G4double" && !withUnit) return G4TypeKeyT<G4double>();
50 if (type == "G4double" && withUnit) return G4TypeKeyT<G4DimensionedDouble>();
51 if (type == "G4ThreeVector" && !withUnit) return G4TypeKeyT<G4ThreeVector>();
52 if (type == "G4ThreeVector" && withUnit) return G4TypeKeyT<G4DimensionedThreeVector>();
53 if (type == "G4bool") return G4TypeKeyT<G4bool>();
54
55 // Return default (invalid) key
56 return G4TypeKey();
57 }
bool G4bool
Definition: G4Types.hh:86
const G4String & GetExtra() const
Definition: G4AttDef.hh:86
const G4String & GetValueType() const
Definition: G4AttDef.hh:87

Referenced by G4AttFilterUtils::GetNewFilter().