#include <G4GDMLReadSetup.hh>
Inheritance diagram for G4GDMLReadSetup:
Public Member Functions | |
G4String | GetSetup (const G4String &) |
virtual void | SetupRead (const xercesc::DOMElement *const element) |
Protected Member Functions | |
G4GDMLReadSetup () | |
virtual | ~G4GDMLReadSetup () |
Protected Attributes | |
std::map< G4String, G4String > | setupMap |
Definition at line 49 of file G4GDMLReadSetup.hh.
G4GDMLReadSetup::G4GDMLReadSetup | ( | ) | [protected] |
G4GDMLReadSetup::~G4GDMLReadSetup | ( | ) | [protected, virtual] |
Implements G4GDMLRead.
Definition at line 44 of file G4GDMLReadSetup.cc.
References FatalException, G4Exception(), and setupMap.
Referenced by G4GDMLReadStructure::FileRead(), and G4GDMLReadStructure::GetWorldVolume().
00045 { 00046 if (setupMap.size() == 1) // If there is only one setup defined, 00047 { // no matter how it is named 00048 return setupMap.begin()->second; 00049 } 00050 00051 if (setupMap.find(ref) == setupMap.end()) 00052 { 00053 G4String error_msg = "Referenced setup '" + ref + "' was not found!"; 00054 G4Exception("G4GDMLReadSetup::getSetup()", "ReadError", 00055 FatalException, error_msg); 00056 } 00057 00058 return setupMap[ref]; 00059 }
void G4GDMLReadSetup::SetupRead | ( | const xercesc::DOMElement *const | element | ) | [virtual] |
Implements G4GDMLRead.
Definition at line 61 of file G4GDMLReadSetup.cc.
References FatalException, G4cout, G4endl, G4Exception(), G4GDMLRead::GenerateName(), G4GDMLReadDefine::RefRead(), setupMap, and G4GDMLRead::Transcode().
00062 { 00063 G4cout << "G4GDML: Reading setup..." << G4endl; 00064 00065 G4String name; 00066 00067 const xercesc::DOMNamedNodeMap* const attributes = element->getAttributes(); 00068 XMLSize_t attributeCount = attributes->getLength(); 00069 00070 for (XMLSize_t attribute_index=0; 00071 attribute_index<attributeCount; attribute_index++) 00072 { 00073 xercesc::DOMNode* attribute_node = attributes->item(attribute_index); 00074 00075 if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE) 00076 { continue; } 00077 00078 const xercesc::DOMAttr* const attribute 00079 = dynamic_cast<xercesc::DOMAttr*>(attribute_node); 00080 if (!attribute) 00081 { 00082 G4Exception("G4GDMLReadSetup::SetupRead()", 00083 "InvalidRead", FatalException, "No attribute found!"); 00084 return; 00085 } 00086 const G4String attName = Transcode(attribute->getName()); 00087 const G4String attValue = Transcode(attribute->getValue()); 00088 00089 if (attName=="name") { name = attValue; } 00090 } 00091 00092 for (xercesc::DOMNode* iter = element->getFirstChild(); 00093 iter != 0; iter = iter->getNextSibling()) 00094 { 00095 if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) { continue; } 00096 00097 const xercesc::DOMElement* const child 00098 = dynamic_cast<xercesc::DOMElement*>(iter); 00099 if (!child) 00100 { 00101 G4Exception("G4GDMLReadSetup::SetupRead()", 00102 "InvalidRead", FatalException, "No child found!"); 00103 return; 00104 } 00105 const G4String tag = Transcode(child->getTagName()); 00106 00107 if (tag == "world") { setupMap[name] = GenerateName(RefRead(child)); } 00108 } 00109 }
std::map<G4String,G4String> G4GDMLReadSetup::setupMap [protected] |