00001 // 00002 // ******************************************************************** 00003 // * License and Disclaimer * 00004 // * * 00005 // * The Geant4 software is copyright of the Copyright Holders of * 00006 // * the Geant4 Collaboration. It is provided under the terms and * 00007 // * conditions of the Geant4 Software License, included in the file * 00008 // * LICENSE and available at http://cern.ch/geant4/license . These * 00009 // * include a list of copyright holders. * 00010 // * * 00011 // * Neither the authors of this software system, nor their employing * 00012 // * institutes,nor the agencies providing financial support for this * 00013 // * work make any representation or warranty, express or implied, * 00014 // * regarding this software system or assume any liability for its * 00015 // * use. Please see the license in the file LICENSE and URL above * 00016 // * for the full disclaimer and the limitation of liability. * 00017 // * * 00018 // * This code implementation is the result of the scientific and * 00019 // * technical work of the GEANT4 collaboration. * 00020 // * By using, copying, modifying or distributing the software (or * 00021 // * any work based on the software) you agree to acknowledge its * 00022 // * use in resulting scientific publications, and indicate your * 00023 // * acceptance of all terms of the Geant4 Software license. * 00024 // ******************************************************************** 00025 // 00026 // 00027 // $Id: G4tgrFileIn.hh 69803 2013-05-15 15:24:50Z gcosmo $ 00028 // 00029 // 00030 // class G4tgrFileIn 00031 // 00032 // Class description: 00033 // 00034 // Singleton for importing file descriptions. 00035 00036 // History: 00037 // - Created. P.Arce, CIEMAT (November 2007) 00038 // ------------------------------------------------------------------------- 00039 00040 #ifndef G4tgrFileIn_HH 00041 #define G4tgrFileIn_HH 00042 00043 #include "globals.hh" 00044 #include <vector> 00045 00046 class G4tgrFileIn 00047 { 00048 public: // with description 00049 00050 G4tgrFileIn(); 00051 ~G4tgrFileIn(); 00052 00053 static G4tgrFileIn& GetInstance( const G4String& name ); 00054 // Get the only instance opening the file 00055 00056 static G4tgrFileIn& GetInstanceOpened( const G4String& name ); 00057 // Get the only instance when file should be already opened 00058 00059 G4int GetWordsInLine( std::vector<G4String>& wl ); 00060 // Read a line and transform it to a vector of words 00061 00062 void ErrorInLine(); 00063 // Print out an error message indicating the line being read 00064 00065 // Access data members 00066 00067 G4int Nline() { return theLineNo[theCurrentFile]; } 00068 00069 const G4String& GetName() { return theName; } 00070 00071 void OpenNewFile( const char* filename ); 00072 G4bool EndOfFile(); 00073 void Close(); 00074 void DumpException( const G4String& sent ); 00075 00076 private: 00077 00078 G4tgrFileIn( const G4String& name ) : theCurrentFile(-1), theName(name) {} 00079 00080 private: 00081 00082 std::vector< std::ifstream* > theFiles; 00083 00084 std::vector<G4int> theLineNo; 00085 // Number of line being read 00086 00087 std::vector<G4String> theNames; 00088 00089 G4int theCurrentFile; 00090 // Index of file being read in theFiles 00091 00092 static std::vector<G4tgrFileIn*> theInstances; 00093 // Vector of class instances (each one identified by its name) 00094 00095 G4String theName; 00096 // Name of file 00097 }; 00098 00099 #endif