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.

00065 {
00066   delete theLineProcessor;
00067   delete theInstance;
00068 }

G4tgrFileReader::G4tgrFileReader (  )  [protected]

Definition at line 57 of file G4tgrFileReader.cc.

00058 {
00059   theLineProcessor = new G4tgrLineProcessor;
00060 }


Member Function Documentation

void G4tgrFileReader::AddTextFile ( const G4String fname  )  [inline]

Definition at line 62 of file G4tgrFileReader.hh.

Referenced by G4tgbVolumeMgr::AddTextFile().

00062 { theTextFiles.push_back( fname ); }

G4tgrFileReader * G4tgrFileReader::GetInstance (  )  [static]

Definition at line 72 of file G4tgrFileReader.cc.

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

00073 {
00074   if( !theInstance ) {
00075     theInstance = new G4tgrFileReader;
00076   }
00077   return theInstance;
00078 }

G4tgrLineProcessor* G4tgrFileReader::GetLineProcessor (  )  const [inline]

Definition at line 64 of file G4tgrFileReader.hh.

00064 { return theLineProcessor; }

G4bool G4tgrFileReader::ReadFiles (  ) 

Definition at line 81 of file G4tgrFileReader.cc.

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

Referenced by G4tgbDetectorBuilder::ReadDetector().

00082 {
00083 
00084   std::vector< G4String > wl,wlnew;
00085     
00086 #ifdef G4VERBOSE
00087   if( G4tgrMessenger::GetVerboseLevel() >= 2 )
00088   {
00089     G4cout << "   Number of geometry data files = " << theTextFiles.size()
00090            << G4endl;
00091   }
00092 #endif
00093 
00094   if( theTextFiles.size() == 0 )
00095   {
00096     G4Exception("G4tgrFileReader::ReadFiles()", "InvalidInput",
00097                 FatalException, "No files to read ...");
00098   }
00099 
00100   for( size_t ii = 0; ii < theTextFiles.size(); ii++ )
00101   {
00102 #ifdef G4VERBOSE
00103     if( G4tgrMessenger::GetVerboseLevel() >= 1 )
00104     {
00105       G4cout << "   Reading data file " << theTextFiles[ii] << G4endl;
00106     }
00107 #endif
00108     
00109     G4tgrFileIn fin = G4tgrFileIn::GetInstance( theTextFiles[ii] );
00110     
00111     G4int nlines = 0;
00112     for(;;)
00113     {
00114       nlines++;
00115       if(! fin.GetWordsInLine( wlnew ) )  { break; }
00116       // Check if it is continuation line or first line
00117       if( wlnew[0].c_str()[0] != ':' )
00118       {
00119         wl.insert( wl.end(), wlnew.begin(), wlnew.end() );
00120 #ifdef G4VERBOSE
00121         if( G4tgrMessenger::GetVerboseLevel() >= 4 )
00122         {
00123           G4tgrUtils::DumpVS(wl, "!!!! adding line");
00124         }
00125 #endif
00126         continue;
00127       }
00128       else
00129       {
00130         //----- Process previous tag
00131 #ifdef G4VERBOSE
00132         if( G4tgrMessenger::GetVerboseLevel() >= 4 )
00133         {
00134           G4tgrUtils::DumpVS(wl, "!!!! line read");
00135         }
00136 #endif
00137         if( nlines != 1)   // first line has no previous tag
00138         {
00139           if( ! theLineProcessor->ProcessLine( wl ) )
00140           {
00141             fin.DumpException( "Tag not found: " + wl[0]);
00142           }
00143         }
00144         wl = wlnew;
00145       }
00146     }
00147     
00148     if( wl.size() != 0 )
00149     {
00150       if( ! theLineProcessor->ProcessLine( wl ) )
00151       {
00152         fin.DumpException( "Tag not found: " + wl[0]);
00153       }
00154     }
00155   }  
00156   return 1;
00157 }

void G4tgrFileReader::SetLineProcessor ( G4tgrLineProcessor lp  )  [inline]

Definition at line 63 of file G4tgrFileReader.hh.

00063 { theLineProcessor = lp; }


The documentation for this class was generated from the following files:
Generated on Mon May 27 17:53:30 2013 for Geant4 by  doxygen 1.4.7