Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
G4GDMLReadSetup.cc
이 파일의 문서화 페이지로 가기
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 108895 2018-03-15 10:27:25Z gcosmo $
27 //
28 // class G4GDMLReadSetup Implementation
29 //
30 // Original author: Zoltan Torzsok, November 2007
31 //
32 // --------------------------------------------------------------------
33 
34 #include "G4GDMLReadSetup.hh"
35 
37 {
38 }
39 
41 {
42 }
43 
45 {
46  if (setupMap.size() == 1) // If there is only one setup defined,
47  { // no matter how it is named
48  return setupMap.begin()->second;
49  }
50 
51  if (setupMap.find(ref) == setupMap.end())
52  {
53 #ifdef G4VERBOSE
54  std::ostringstream message;
55  message << "Referenced setup '" << ref << "' was not found!";
56  G4Exception("G4GDMLReadSetup::getSetup()", "NullSetup",
57  JustWarning, message, "Returning NULL pointer!");
58 #endif
59  return "";
60  }
61 
62  return setupMap[ref];
63 }
64 
65 void G4GDMLReadSetup::SetupRead(const xercesc::DOMElement* const element)
66 {
67 #ifdef G4VERBOSE
68  G4cout << "G4GDML: Reading setup..." << G4endl;
69 #endif
70  G4String name;
71 
72  const xercesc::DOMNamedNodeMap* const attributes = element->getAttributes();
73  XMLSize_t attributeCount = attributes->getLength();
74 
75  for (XMLSize_t attribute_index=0;
76  attribute_index<attributeCount; attribute_index++)
77  {
78  xercesc::DOMNode* attribute_node = attributes->item(attribute_index);
79 
80  if (attribute_node->getNodeType() != xercesc::DOMNode::ATTRIBUTE_NODE)
81  { continue; }
82 
83  const xercesc::DOMAttr* const attribute
84  = dynamic_cast<xercesc::DOMAttr*>(attribute_node);
85  if (!attribute)
86  {
87  G4Exception("G4GDMLReadSetup::SetupRead()",
88  "InvalidRead", FatalException, "No attribute found!");
89  return;
90  }
91  const G4String attName = Transcode(attribute->getName());
92  const G4String attValue = Transcode(attribute->getValue());
93 
94  if (attName=="name") { name = attValue; }
95  }
96 
97  for (xercesc::DOMNode* iter = element->getFirstChild();
98  iter != 0; iter = iter->getNextSibling())
99  {
100  if (iter->getNodeType() != xercesc::DOMNode::ELEMENT_NODE) { continue; }
101 
102  const xercesc::DOMElement* const child
103  = dynamic_cast<xercesc::DOMElement*>(iter);
104  if (!child)
105  {
106  G4Exception("G4GDMLReadSetup::SetupRead()",
107  "InvalidRead", FatalException, "No child found!");
108  return;
109  }
110  const G4String tag = Transcode(child->getTagName());
111 
112  if (tag == "world") { setupMap[name] = GenerateName(RefRead(child)); }
113  }
114 }
const XML_Char * name
Definition: expat.h:151
G4String GetSetup(const G4String &)
#define G4endl
Definition: G4ios.hh:61
Definition: xmlparse.cc:187
void message(RunManager *runmanager)
Definition: ts_scorers.cc:72
G4String GenerateName(const G4String &name, G4bool strip=false)
Definition: G4GDMLRead.cc:68
virtual void SetupRead(const xercesc::DOMElement *const element)
virtual ~G4GDMLReadSetup()
std::map< G4String, G4String > setupMap
G4String RefRead(const xercesc::DOMElement *const)
G4String Transcode(const XMLCh *const)
Definition: G4GDMLRead.cc:55
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.hh:65
G4GLOB_DLL std::ostream G4cout