G4GDMLReadSetup Class Reference

#include <G4GDMLReadSetup.hh>

Inheritance diagram for G4GDMLReadSetup:

G4GDMLReadSolids G4GDMLReadMaterials G4GDMLReadDefine G4GDMLRead G4GDMLReadParamvol G4GDMLReadStructure

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, G4StringsetupMap

Detailed Description

Definition at line 49 of file G4GDMLReadSetup.hh.


Constructor & Destructor Documentation

G4GDMLReadSetup::G4GDMLReadSetup (  )  [protected]

Definition at line 36 of file G4GDMLReadSetup.cc.

00036                                  : G4GDMLReadSolids()
00037 {
00038 }

G4GDMLReadSetup::~G4GDMLReadSetup (  )  [protected, virtual]

Definition at line 40 of file G4GDMLReadSetup.cc.

00041 {
00042 }


Member Function Documentation

G4String G4GDMLReadSetup::GetSetup ( const G4String  )  [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 }


Field Documentation

std::map<G4String,G4String> G4GDMLReadSetup::setupMap [protected]

Definition at line 64 of file G4GDMLReadSetup.hh.

Referenced by GetSetup(), and SetupRead().


The documentation for this class was generated from the following files:
Generated on Mon May 27 17:52:02 2013 for Geant4 by  doxygen 1.4.7