source: trunk/source/persistency/gdml/src/G4GDMLReadSetup.cc@ 1164

Last change on this file since 1164 was 987, checked in by garnier, 17 years ago

fichiers manquants

File size: 3.7 KB
Line 
1//
2// ********************************************************************
3// * License and Disclaimer *
4// * *
5// * The Geant4 software is copyright of the Copyright Holders of *
6// * the Geant4 Collaboration. It is provided under the terms and *
7// * conditions of the Geant4 Software License, included in the file *
8// * LICENSE and available at http://cern.ch/geant4/license . These *
9// * include a list of copyright holders. *
10// * *
11// * Neither the authors of this software system, nor their employing *
12// * institutes,nor the agencies providing financial support for this *
13// * work make any representation or warranty, express or implied, *
14// * regarding this software system or assume any liability for its *
15// * use. Please see the license in the file LICENSE and URL above *
16// * for the full disclaimer and the limitation of liability. *
17// * *
18// * This code implementation is the result of the scientific and *
19// * technical work of the GEANT4 collaboration. *
20// * By using, copying, modifying or distributing the software (or *
21// * any work based on the software) you agree to acknowledge its *
22// * use in resulting scientific publications, and indicate your *
23// * acceptance of all terms of the Geant4 Software license. *
24// ********************************************************************
25//
26// $Id: G4GDMLReadSetup.cc,v 1.9 2008/07/16 15:46:34 gcosmo Exp $
27// GEANT4 tag $Name: geant4-09-02-ref-02 $
28//
29// class G4GDMLReadSetup Implementation
30//
31// Original author: Zoltan Torzsok, November 2007
32//
33// --------------------------------------------------------------------
34
35#include "G4GDMLReadSetup.hh"
36
37G4String G4GDMLReadSetup::GetSetup(const G4String& ref)
38{
39 if (setupMap.size() == 1) // If there is only one setup defined,
40 { // no matter how it is named
41 return setupMap.begin()->second;
42 }
43
44 if (setupMap.find(ref) == setupMap.end())
45 {
46 G4String error_msg = "Referenced setup '" + ref + "' was not found!";
47 G4Exception("G4GDMLReadSetup::getSetup()", "ReadError",
48 FatalException, error_msg);
49 }
50
51 return setupMap[ref];
52}
53
54void G4GDMLReadSetup::SetupRead(const xercesc::DOMElement* const element)
55{
56 G4cout << "G4GDML: Reading setup..." << G4endl;
57
58 G4String name;
59
60 const xercesc::DOMNamedNodeMap* const attributes = element->getAttributes();
61 XMLSize_t attributeCount = attributes->getLength();
62
63 for (XMLSize_t attribute_index=0;
64 attribute_index<attributeCount; attribute_index++)
65 {
66 xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
67
68 if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
69 { continue; }
70
71 const xercesc::DOMAttr* const attribute
72 = dynamic_cast<xercesc::DOMAttr*>(attribute_node);
73 const G4String attName = Transcode(attribute->getName());
74 const G4String attValue = Transcode(attribute->getValue());
75
76 if (attName=="name") { name = attValue; }
77 }
78
79 for (xercesc::DOMNode* iter = element->getFirstChild();
80 iter != 0; iter = iter->getNextSibling())
81 {
82 if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) { continue; }
83
84 const xercesc::DOMElement* const child
85 = dynamic_cast<xercesc::DOMElement*>(iter);
86 const G4String tag = Transcode(child->getTagName());
87
88 if (tag == "world") { setupMap[name] = GenerateName(RefRead(child)); }
89 }
90}
Note: See TracBrowser for help on using the repository browser.