source: trunk/source/persistency/gdml/src/G4GDMLSetup.cc @ 818

Last change on this file since 818 was 818, checked in by garnier, 16 years ago

import all except CVS

File size: 3.5 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//
27// $Id: G4GDMLSetup.cc,v 1.11 2007/11/29 13:13:06 ztorzsok Exp $
28// GEANT4 tag $ Name:$
29//
30// class G4GDMLSetup Implementation
31//
32// Original author: Zoltan Torzsok, November 2007
33//
34// --------------------------------------------------------------------
35
36#include "G4GDMLSetup.hh"
37
38G4String G4GDMLSetup::getSetup(const G4String& ref) {
39
40   if (setupMap.find(ref) == setupMap.end())
41      G4Exception("GDML: Referenced setup '"+ref+"' was not found!");
42
43   return setupMap[ref];
44}
45
46void G4GDMLSetup::setupRead(const xercesc::DOMElement* const element) {
47
48   G4String name;
49
50   const xercesc::DOMNamedNodeMap* const attributes = element->getAttributes();
51   XMLSize_t attributeCount = attributes->getLength();
52
53   for (XMLSize_t attribute_index=0;attribute_index<attributeCount;attribute_index++) {
54
55      xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
56
57      if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE) continue;
58
59      const xercesc::DOMAttr* const attribute = dynamic_cast<xercesc::DOMAttr*>(attribute_node);   
60
61      const G4String attribute_name  = xercesc::XMLString::transcode(attribute->getName());
62      const G4String attribute_value = xercesc::XMLString::transcode(attribute->getValue());
63
64      if (attribute_name=="name") name = attribute_value;
65   }
66
67   for (xercesc::DOMNode* iter = element->getFirstChild();iter != 0;iter = iter->getNextSibling()) {
68
69      if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) continue;
70
71      const xercesc::DOMElement* const child = dynamic_cast<xercesc::DOMElement*>(iter);
72
73      const G4String tag = xercesc::XMLString::transcode(child->getTagName());
74
75      if (tag != "world") continue;
76
77      XMLCh *ref_attr = xercesc::XMLString::transcode("ref");
78      G4String ref = xercesc::XMLString::transcode(child->getAttribute(ref_attr));
79      xercesc::XMLString::release(&ref_attr);
80
81      setupMap[name] = GenerateName(ref);
82   }
83}
Note: See TracBrowser for help on using the repository browser.