Geant4  10.03.p01
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
G4XmlRFileManager Class Reference

#include <G4XmlRFileManager.hh>

Inheritance diagram for G4XmlRFileManager:
Collaboration diagram for G4XmlRFileManager:

Public Member Functions

 G4XmlRFileManager (const G4AnalysisManagerState &state)
 
 ~G4XmlRFileManager ()
 
virtual G4bool OpenRFile (const G4String &fileName)
 
tools::raxml * GetRFile (const G4String &fileName) const
 
- Public Member Functions inherited from G4BaseFileManager
 G4BaseFileManager (const G4AnalysisManagerState &state)
 
virtual ~G4BaseFileManager ()
 
virtual G4bool SetFileName (const G4String &fileName)
 
G4String GetFileName () const
 
G4String GetFullFileName (const G4String &baseFileName="", G4bool isPerThread=true) const
 
G4String GetHnFileName (const G4String &hnType, const G4String &hnName) const
 
G4String GetNtupleFileName (const G4String &ntupleName) const
 
G4String GetNtupleFileName (G4int ntupleFileNumber) const
 
G4String GetPlotFileName () const
 
G4String GetFileType () const
 

Additional Inherited Members

- Protected Member Functions inherited from G4BaseFileManager
G4String TakeOffExtension (G4String &name) const
 
- Protected Attributes inherited from G4BaseFileManager
const G4AnalysisManagerStatefState
 
G4String fFileName
 

Detailed Description

Definition at line 44 of file G4XmlRFileManager.hh.

Constructor & Destructor Documentation

G4XmlRFileManager::G4XmlRFileManager ( const G4AnalysisManagerState state)
explicit

Definition at line 36 of file G4XmlRFileManager.cc.

37  : G4BaseFileManager(state),
38  fReadFactory(0),
39  fRFiles()
40 {
41 }
G4BaseFileManager(const G4AnalysisManagerState &state)
G4XmlRFileManager::~G4XmlRFileManager ( )

Definition at line 44 of file G4XmlRFileManager.cc.

45 {
46  for (G4int i=0; i<G4int(fRFiles.size()); ++i) {
47  delete fRFiles[i];
48  }
49  delete fReadFactory;
50 }
int G4int
Definition: G4Types.hh:78

Member Function Documentation

tools::raxml * G4XmlRFileManager::GetRFile ( const G4String fileName) const

Definition at line 115 of file G4XmlRFileManager.cc.

116 {
117  // Get full file name (add only extension)
118  G4bool isPerThread = false;
119  G4String name = GetFullFileName(fileName, isPerThread);
120 
121  std::map<G4String, tools::raxml*>::const_iterator it
122  = fRFiles.find(name);
123  if ( it != fRFiles.end() )
124  return it->second;
125  else {
126  return nullptr;
127  }
128 }
const XML_Char * name
Definition: expat.h:151
bool G4bool
Definition: G4Types.hh:79
G4String GetFullFileName(const G4String &baseFileName="", G4bool isPerThread=true) const

Here is the call graph for this function:

G4bool G4XmlRFileManager::OpenRFile ( const G4String fileName)
virtual

Definition at line 57 of file G4XmlRFileManager.cc.

58 {
59  // Get full file name (add only extension)
60  G4bool isPerThread = false;
61  G4String name = GetFullFileName(fileName, isPerThread);
62 
63 #ifdef G4VERBOSE
64  if ( fState.GetVerboseL4() )
65  fState.GetVerboseL4()->Message("open", "read analysis file", name);
66 #endif
67 
68  G4bool verbose = false;
69 
70  // create factory (if it does not yet exist)
71  if ( ! fReadFactory ) {
72  fReadFactory = new tools::xml::default_factory();
73  }
74 
75  // create new file
76  tools::raxml* newFile
77  = new tools::raxml(*fReadFactory, G4cout, verbose);
78 
79  // clear objects
80  // (this should not be needed when starting a new raxml)
81  std::vector<tools::raxml_out>& objs = newFile->objects();
82  objs.clear();
83 
84  G4bool compressed = false;
85  if ( ! newFile->load_file(name, compressed) ) {
86  G4ExceptionDescription description;
87  description << " " << "Cannot open file " << name;
88  G4Exception("G4XmlRFileManager::OpenRFile()",
89  "Analysis_WR001", JustWarning, description);
90  delete newFile;
91  return false;
92  }
93 
94  // add file in a map and delete the previous file if it exists
95  std::map<G4String, tools::raxml*>::iterator it
96  = fRFiles.find(name);
97  if ( it != fRFiles.end() ) {
98  delete it->second;
99  it->second = newFile;
100  }
101  else {
102  fRFiles[name] = newFile;
103  }
104 
105 #ifdef G4VERBOSE
106  if ( fState.GetVerboseL1() )
108  ->Message("open", "read analysis file", name);
109 #endif
110 
111  return true;
112 }
void Message(const G4String &action, const G4String &object, const G4String &objectName, G4bool success=true) const
const XML_Char * name
Definition: expat.h:151
const G4AnalysisManagerState & fState
std::ostringstream G4ExceptionDescription
Definition: globals.hh:76
G4GLOB_DLL std::ostream G4cout
const G4AnalysisVerbose * GetVerboseL4() const
bool G4bool
Definition: G4Types.hh:79
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
G4String GetFullFileName(const G4String &baseFileName="", G4bool isPerThread=true) const
const G4AnalysisVerbose * GetVerboseL1() const

Here is the call graph for this function:


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