Geant4 11.2.2
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4tgrFileReader Class Reference

#include <G4tgrFileReader.hh>

Public Member Functions

virtual ~G4tgrFileReader ()
 
G4bool ReadFiles ()
 
void AddTextFile (const G4String &fname)
 
void SetLineProcessor (G4tgrLineProcessor *lp)
 
G4tgrLineProcessorGetLineProcessor () const
 

Static Public Member Functions

static G4tgrFileReaderGetInstance ()
 

Protected Member Functions

 G4tgrFileReader ()
 

Detailed Description

Definition at line 45 of file G4tgrFileReader.hh.

Constructor & Destructor Documentation

◆ ~G4tgrFileReader()

G4tgrFileReader::~G4tgrFileReader ( )
virtual

Definition at line 56 of file G4tgrFileReader.cc.

57{
58 delete theLineProcessor;
59 delete theInstance;
60}

◆ G4tgrFileReader()

G4tgrFileReader::G4tgrFileReader ( )
protected

Definition at line 50 of file G4tgrFileReader.cc.

51{
52 theLineProcessor = new G4tgrLineProcessor;
53}

Referenced by GetInstance().

Member Function Documentation

◆ AddTextFile()

void G4tgrFileReader::AddTextFile ( const G4String & fname)
inline

Definition at line 56 of file G4tgrFileReader.hh.

56{ theTextFiles.push_back(fname); }

Referenced by G4tgbVolumeMgr::AddTextFile().

◆ GetInstance()

G4tgrFileReader * G4tgrFileReader::GetInstance ( )
static

Definition at line 63 of file G4tgrFileReader.cc.

64{
65 if(theInstance == nullptr)
66 {
67 theInstance = new G4tgrFileReader;
68 }
69 return theInstance;
70}

Referenced by G4tgbVolumeMgr::AddTextFile(), and G4tgbDetectorBuilder::ReadDetector().

◆ GetLineProcessor()

G4tgrLineProcessor * G4tgrFileReader::GetLineProcessor ( ) const
inline

Definition at line 58 of file G4tgrFileReader.hh.

58{ return theLineProcessor; }

◆ ReadFiles()

G4bool G4tgrFileReader::ReadFiles ( )

Definition at line 73 of file G4tgrFileReader.cc.

74{
75 std::vector<G4String> wl, wlnew;
76
77#ifdef G4VERBOSE
79 {
80 G4cout << " Number of geometry data files = " << theTextFiles.size()
81 << G4endl;
82 }
83#endif
84
85 if(theTextFiles.size() == 0)
86 {
87 G4Exception("G4tgrFileReader::ReadFiles()", "InvalidInput", FatalException,
88 "No files to read ...");
89 }
90
91 for(std::size_t ii = 0; ii < theTextFiles.size(); ++ii)
92 {
93#ifdef G4VERBOSE
95 {
96 G4cout << " Reading data file " << theTextFiles[ii] << G4endl;
97 }
98#endif
99
100 G4tgrFileIn fin = G4tgrFileIn::GetInstance(theTextFiles[ii]);
101
102 G4int nlines = 0;
103 for(;;)
104 {
105 ++nlines;
106 if(!fin.GetWordsInLine(wlnew))
107 {
108 break;
109 }
110 // Check if it is continuation line or first line
111 if(wlnew[0].c_str()[0] != ':')
112 {
113 wl.insert(wl.end(), wlnew.begin(), wlnew.end());
114#ifdef G4VERBOSE
116 {
117 G4tgrUtils::DumpVS(wl, "!!!! adding line");
118 }
119#endif
120 continue;
121 }
122 else
123 {
124 //----- Process previous tag
125#ifdef G4VERBOSE
127 {
128 G4tgrUtils::DumpVS(wl, "!!!! line read");
129 }
130#endif
131 if(nlines != 1) // first line has no previous tag
132 {
133 if(!theLineProcessor->ProcessLine(wl))
134 {
135 fin.DumpException("Tag not found: " + wl[0]);
136 }
137 }
138 wl = wlnew;
139 }
140 }
141
142 if(wl.size() != 0)
143 {
144 if(!theLineProcessor->ProcessLine(wl))
145 {
146 fin.DumpException("Tag not found: " + wl[0]);
147 }
148 }
149 }
150 return true;
151}
@ FatalException
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
int G4int
Definition G4Types.hh:85
#define G4endl
Definition G4ios.hh:67
G4GLOB_DLL std::ostream G4cout
G4int GetWordsInLine(std::vector< G4String > &wl)
static G4tgrFileIn & GetInstance(const G4String &name)
void DumpException(const G4String &sent)
virtual G4bool ProcessLine(const std::vector< G4String > &wl)
static G4int GetVerboseLevel()
static void DumpVS(const std::vector< G4String > &wl, const char *msg)

Referenced by G4tgbDetectorBuilder::ReadDetector().

◆ SetLineProcessor()

void G4tgrFileReader::SetLineProcessor ( G4tgrLineProcessor * lp)
inline

Definition at line 57 of file G4tgrFileReader.hh.

57{ theLineProcessor = lp; }

The documentation for this class was generated from the following files: