Geant4-11
Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Attributes | Static Private Attributes
G4tgrFileReader Class Reference

#include <G4tgrFileReader.hh>

Public Member Functions

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

Static Public Member Functions

static G4tgrFileReaderGetInstance ()
 

Protected Member Functions

 G4tgrFileReader ()
 

Private Attributes

G4tgrLineProcessortheLineProcessor = nullptr
 
std::vector< G4StringtheTextFiles
 

Static Private Attributes

static G4ThreadLocal G4tgrFileReadertheInstance = nullptr
 

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}
G4tgrLineProcessor * theLineProcessor
static G4ThreadLocal G4tgrFileReader * theInstance

References theInstance, and theLineProcessor.

◆ G4tgrFileReader()

G4tgrFileReader::G4tgrFileReader ( )
protected

Definition at line 50 of file G4tgrFileReader.cc.

References theLineProcessor.

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); }
std::vector< G4String > theTextFiles
string fname
Definition: test.py:308

References test::fname, and theTextFiles.

Referenced by G4tgbVolumeMgr::AddTextFile().

◆ GetInstance()

G4tgrFileReader * G4tgrFileReader::GetInstance ( )
static

Definition at line 63 of file G4tgrFileReader.cc.

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

References G4tgrFileReader(), and theInstance.

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

◆ GetLineProcessor()

G4tgrLineProcessor * G4tgrFileReader::GetLineProcessor ( ) const
inline

Definition at line 58 of file G4tgrFileReader.hh.

58{ return theLineProcessor; }

References 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
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 {
134 {
135 fin.DumpException("Tag not found: " + wl[0]);
136 }
137 }
138 wl = wlnew;
139 }
140 }
141
142 if(wl.size() != 0)
143 {
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)
Definition: G4Exception.cc:35
int G4int
Definition: G4Types.hh:85
#define G4endl
Definition: G4ios.hh:57
G4GLOB_DLL std::ostream G4cout
G4int GetWordsInLine(std::vector< G4String > &wl)
Definition: G4tgrFileIn.cc:137
static G4tgrFileIn & GetInstance(const G4String &name)
Definition: G4tgrFileIn.cc:68
void DumpException(const G4String &sent)
Definition: G4tgrFileIn.cc:434
virtual G4bool ProcessLine(const std::vector< G4String > &wl)
static G4int GetVerboseLevel()
static void DumpVS(const std::vector< G4String > &wl, const char *msg)
Definition: G4tgrUtils.cc:153

References G4tgrFileIn::DumpException(), G4tgrUtils::DumpVS(), FatalException, G4cout, G4endl, G4Exception(), G4tgrFileIn::GetInstance(), G4tgrMessenger::GetVerboseLevel(), G4tgrFileIn::GetWordsInLine(), G4tgrLineProcessor::ProcessLine(), theLineProcessor, and theTextFiles.

Referenced by G4tgbDetectorBuilder::ReadDetector().

◆ SetLineProcessor()

void G4tgrFileReader::SetLineProcessor ( G4tgrLineProcessor lp)
inline

Definition at line 57 of file G4tgrFileReader.hh.

57{ theLineProcessor = lp; }

References theLineProcessor.

Field Documentation

◆ theInstance

G4ThreadLocal G4tgrFileReader * G4tgrFileReader::theInstance = nullptr
staticprivate

Definition at line 66 of file G4tgrFileReader.hh.

Referenced by GetInstance(), and ~G4tgrFileReader().

◆ theLineProcessor

G4tgrLineProcessor* G4tgrFileReader::theLineProcessor = nullptr
private

◆ theTextFiles

std::vector<G4String> G4tgrFileReader::theTextFiles
private

Definition at line 68 of file G4tgrFileReader.hh.

Referenced by AddTextFile(), and ReadFiles().


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