Geant4  10.03.p01
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 51 of file G4tgrFileReader.hh.

Constructor & Destructor Documentation

G4tgrFileReader::~G4tgrFileReader ( )
virtual

Definition at line 64 of file G4tgrFileReader.cc.

65 {
66  delete theLineProcessor;
67  delete theInstance;
68 }
G4tgrFileReader::G4tgrFileReader ( )
protected

Definition at line 57 of file G4tgrFileReader.cc.

58 {
59  theLineProcessor = new G4tgrLineProcessor;
60 }

Here is the caller graph for this function:

Member Function Documentation

void G4tgrFileReader::AddTextFile ( const G4String fname)
inline

Definition at line 62 of file G4tgrFileReader.hh.

62 { theTextFiles.push_back( fname ); }

Here is the caller graph for this function:

G4tgrFileReader * G4tgrFileReader::GetInstance ( )
static

Definition at line 72 of file G4tgrFileReader.cc.

73 {
74  if( !theInstance ) {
75  theInstance = new G4tgrFileReader;
76  }
77  return theInstance;
78 }

Here is the call graph for this function:

Here is the caller graph for this function:

G4tgrLineProcessor* G4tgrFileReader::GetLineProcessor ( ) const
inline

Definition at line 64 of file G4tgrFileReader.hh.

64 { return theLineProcessor; }
G4bool G4tgrFileReader::ReadFiles ( )

Definition at line 81 of file G4tgrFileReader.cc.

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

Here is the call graph for this function:

Here is the caller graph for this function:

void G4tgrFileReader::SetLineProcessor ( G4tgrLineProcessor lp)
inline

Definition at line 63 of file G4tgrFileReader.hh.

63 { theLineProcessor = lp; }

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