source: trunk/source/persistency/gdml/include/G4GDMLRead.hh @ 1202

Last change on this file since 1202 was 987, checked in by garnier, 15 years ago

fichiers manquants

File size: 5.3 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: G4GDMLRead.hh,v 1.27 2009/01/22 11:02:07 gcosmo Exp $
28// GEANT4 tag $Name: geant4-09-02-ref-02 $
29//
30// class G4GDMLRead
31//
32// Class description:
33//
34// GDML reader.
35
36// History:
37// - Created.                                  Zoltan Torzsok, November 2007
38// -------------------------------------------------------------------------
39
40#ifndef _G4GDMLBASE_INCLUDED_
41#define _G4GDMLBASE_INCLUDED_
42
43#include <xercesc/parsers/XercesDOMParser.hpp>
44#include <xercesc/util/PlatformUtils.hpp>
45#include <xercesc/sax/HandlerBase.hpp>
46#include <xercesc/util/XMLUni.hpp>
47#include <xercesc/dom/DOM.hpp>
48
49#include "G4GDMLEvaluator.hh"
50
51#include "G4LogicalVolume.hh"
52#include "G4VisAttributes.hh"
53#include "G4PVPlacement.hh"
54
55#include <sstream>
56
57class G4GDMLErrorHandler : public xercesc::ErrorHandler
58{
59   G4bool Suppress;
60
61 public:
62
63   G4GDMLErrorHandler(const G4bool set) { Suppress = set; }
64
65   void warning(const xercesc::SAXParseException& exception)
66   {
67      if (Suppress)  { return; }
68      char* message = xercesc::XMLString::transcode(exception.getMessage());
69      G4cout << "G4GDML: VALIDATION WARNING! " << message
70             << " at line: " << exception.getLineNumber() << G4endl;
71      xercesc::XMLString::release(&message);
72   }
73
74   void error(const xercesc::SAXParseException& exception)
75   {
76      if (Suppress)  { return; }
77      char* message = xercesc::XMLString::transcode(exception.getMessage());
78      G4cout << "G4GDML: VALIDATION ERROR! " << message
79             << " at line: " << exception.getLineNumber() << G4endl;
80      xercesc::XMLString::release(&message);
81   }
82
83   void fatalError(const xercesc::SAXParseException& exception)
84   {
85      error(exception);
86   }
87   void resetErrors() {}
88};
89
90class G4GDMLRead
91{
92
93 public:  // with description
94
95   virtual void DefineRead(const xercesc::DOMElement* const)=0;
96   virtual void MaterialsRead(const xercesc::DOMElement* const)=0;
97   virtual void SetupRead(const xercesc::DOMElement* const)=0;
98   virtual void SolidsRead(const xercesc::DOMElement* const)=0;
99   virtual void Paramvol_contentRead(const xercesc::DOMElement* const)=0;
100   virtual void Volume_contentRead(const xercesc::DOMElement* const)=0;
101   virtual void StructureRead(const xercesc::DOMElement* const)=0;
102     //
103     // Pure virtual methods implemented in concrete reader plugin's classes
104
105   virtual void ExtensionRead(const xercesc::DOMElement* const);
106     //
107     // To be implemented in the client code for handling extensions
108     // to the GDML schema, identified with the tag "extension".
109     // The implementation should be placed inside a user-class
110     // inheriting from G4GDMLReadStructure and being registered
111     // as argument to G4GDMLParser.
112
113   virtual G4LogicalVolume* GetVolume(const G4String&) const=0;
114   virtual G4String GetSetup(const G4String&)=0;
115     //
116     // More pure virtual methods implemented in the reader plugin.
117
118   void Read(const G4String&, G4bool validation, G4bool isModule);
119     //
120     // Main method for reading GDML files.
121
122   void StripNames() const;
123     //
124     // Strip off pointers from entity IDs.
125
126   void OverlapCheck(G4bool);
127     //
128     // Activate/de-activate surface check for overlaps (default is off)
129
130 protected:
131
132   G4GDMLRead();
133   virtual ~G4GDMLRead();
134
135   G4String Transcode(const XMLCh* const);
136   G4String GenerateName(const G4String& name, G4bool strip=false);
137   G4String Strip(const G4String&) const;
138   void StripName(G4String&) const;
139   void GeneratePhysvolName(const G4String&,G4VPhysicalVolume*);
140   void LoopRead(const xercesc::DOMElement* const,
141                 void(G4GDMLRead::*)(const xercesc::DOMElement* const));
142
143 protected:
144
145   G4GDMLEvaluator eval;
146   G4bool validate;
147   G4bool check;
148
149 private:
150
151   G4int inLoop;
152
153};
154
155#endif
Note: See TracBrowser for help on using the repository browser.