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().

00063   {
00064     const std::map<G4String, G4AttDef>* attDefs = object.GetAttDefs();
00065 
00066     std::map<G4String, G4AttDef>::const_iterator iter = attDefs->find(name);
00067     if (iter == attDefs->end()) return false;    
00068     
00069     def = iter->second;
00070     
00071     return true;
00072   }

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().

00077   {
00078     std::vector<G4AttValue>* attValues = object.CreateAttValues();
00079     
00080     std::vector<G4AttValue>::iterator iter = std::find_if(attValues->begin(), attValues->end(), 
00081                                                           HasName<G4AttValue>(name));
00082     if (iter == attValues->end()) return false;
00083     
00084     attVal = *iter;
00085     
00086     // Clean up
00087     delete attValues;
00088 
00089     return true;
00090   }

G4TypeKey G4AttUtils::GetKey ( const G4AttDef def  ) 

Definition at line 41 of file G4AttUtils.cc.

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

Referenced by G4AttFilterUtils::GetNewFilter().

00042   {
00043     G4String type = def.GetValueType();
00044     
00045     G4bool withUnit = (def.GetExtra() == "G4BestUnit");
00046     
00047     // Known conversions
00048     if (type == "G4String") return G4TypeKeyT<G4String>();
00049     if (type == "G4int") return G4TypeKeyT<G4int>();
00050     if (type == "G4double" && !withUnit) return G4TypeKeyT<G4double>();
00051     if (type == "G4double" && withUnit) return G4TypeKeyT<G4DimensionedDouble>();
00052     if (type == "G4ThreeVector" && !withUnit) return G4TypeKeyT<G4ThreeVector>();
00053     if (type == "G4ThreeVector" && withUnit) return G4TypeKeyT<G4DimensionedThreeVector>();
00054     if (type == "G4bool") return G4TypeKeyT<G4bool>();
00055     
00056     // Return default (invalid) key
00057     return G4TypeKey();
00058   }


Generated on Mon May 27 17:54:05 2013 for Geant4 by  doxygen 1.4.7