Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Functions
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

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

Definition at line 62 of file G4AttUtils.hh.

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

63  {
64  const std::map<G4String, G4AttDef>* attDefs = object.GetAttDefs();
65 
66  std::map<G4String, G4AttDef>::const_iterator iter = attDefs->find(name);
67  if (iter == attDefs->end()) return false;
68 
69  def = iter->second;
70 
71  return true;
72  }
template<typename T >
G4bool G4AttUtils::ExtractAttValue ( const T &  object,
const G4String name,
G4AttValue attVal 
)

Definition at line 76 of file G4AttUtils.hh.

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

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

Definition at line 41 of file G4AttUtils.cc.

References G4AttDef::GetExtra(), and G4AttDef::GetValueType().

Referenced by G4AttFilterUtils::GetNewFilter().

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