source: trunk/source/persistency/mctruth/include/G4PersistencyCenter.hh@ 1353

Last change on this file since 1353 was 1347, checked in by garnier, 15 years ago

geant4 tag 9.4

File size: 6.6 KB
Line 
1//
2// ********************************************************************
3// * License and Disclaimer *
4// * *
5// * The Geant4 software is copyright of the Copyright Holders of *
6// * the Geant4 Collaboration. It is provided under the terms and *
7// * conditions of the Geant4 Software License, included in the file *
8// * LICENSE and available at http://cern.ch/geant4/license . These *
9// * include a list of copyright holders. *
10// * *
11// * Neither the authors of this software system, nor their employing *
12// * institutes,nor the agencies providing financial support for this *
13// * work make any representation or warranty, express or implied, *
14// * regarding this software system or assume any liability for its *
15// * use. Please see the license in the file LICENSE and URL above *
16// * for the full disclaimer and the limitation of liability. *
17// * *
18// * This code implementation is the result of the scientific and *
19// * technical work of the GEANT4 collaboration. *
20// * By using, copying, modifying or distributing the software (or *
21// * any work based on the software) you agree to acknowledge its *
22// * use in resulting scientific publications, and indicate your *
23// * acceptance of all terms of the Geant4 Software license. *
24// ********************************************************************
25//
26// File: G4PersistencyCenter.hh
27//
28// History:
29// '01.08.10 Youhei Morita Initial creation (with "fadsclass3")
30
31#ifndef PERSISTENCY_CENTER_HH
32#define PERSISTENCY_CENTER_HH 1
33
34#include "G4Types.hh"
35#include <string>
36#include <vector>
37#include <map>
38#include "G4HCIOcatalog.hh"
39#include "G4DCIOcatalog.hh"
40
41#ifndef WIN32
42 #include "G4FileUtilities.hh"
43#endif
44
45// Forward Declaration to avoid circular dependencies.
46class G4PersistencyManager;
47
48typedef std::map<std::string, G4PersistencyManager*,std::less<std::string> > PMap;
49typedef std::map<int, std::string, std::less<int> > ObjMap;
50typedef std::map<std::string, std::string, std::less<std::string> > FileMap;
51
52enum StoreMode { kOn, kOff, kRecycle };
53
54typedef std::map<std::string, StoreMode, std::less<std::string> > StoreMap;
55typedef std::map<std::string, G4bool, std::less<std::string> > BoolMap;
56
57// Forward Declarations:
58class G4PersistencyCenterMessenger;
59
60// Class Description:
61// Class to handle loading of the G4PersistencyManager.
62
63class G4PersistencyCenter
64{
65 public: // With description
66 G4PersistencyCenter();
67 G4PersistencyCenter(const G4PersistencyCenter&);
68 // Constructor
69
70 ~G4PersistencyCenter();
71 // Destructor
72
73 public: // With description
74 static G4PersistencyCenter* GetPersistencyCenter();
75 // returns the pointer of singleton G4PersistencyCenter
76
77 void SelectSystem(std::string systemName);
78 // Select the persistency package
79
80 const std::string CurrentSystem() { return f_currentSystemName; };
81 // returns the current persistent package name
82
83 void SetHepMCObjyReaderFile(std::string file);
84 // Sets the name of HepMCObjyReader file name. To be called by generator.
85
86 std::string CurrentHepMCObjyReaderFile();
87 // Sets the name of HepMCObjyReader file name. To be called by generator.
88
89 void SetStoreMode(std::string objName, StoreMode mode);
90 // Sets the object store mode. Modes are kOn, kOff or kRecycle.
91
92 void SetRetrieveMode(std::string objName, G4bool mode);
93 // Sets the object retrieve mode. Modes are true or false.
94
95 StoreMode CurrentStoreMode(std::string objName);
96 // returns the current object store mode.
97
98 G4bool CurrentRetrieveMode(std::string objName);
99 // returns the current object store mode.
100
101 G4bool SetWriteFile(std::string objName, std::string writeFileName);
102 // Sets the output filename.
103
104 G4bool SetReadFile(std::string objName, std::string readFileName);
105 // Sets the input filename.
106
107 std::string CurrentWriteFile(std::string objName);
108 // returns the current output filename.
109
110 std::string CurrentReadFile(std::string objName);
111 // returns the current input filename.
112
113 std::string CurrentObject(std::string file);
114 // returns the current object type
115
116 void AddHCIOmanager(std::string detName, std::string colName);
117 // add a hits colleciton I/O manager to the catalog
118
119 std::string CurrentHCIOmanager();
120 // Returns a list of registered hits colleciton I/O managers
121
122 void AddDCIOmanager(std::string detName);
123 // add a digits colleciton I/O manager to the catalog
124
125 std::string CurrentDCIOmanager();
126 // Returns a list of registered digits colleciton I/O managers
127
128 void PrintAll();
129 // prints the current G4PersistencyCenter settings.
130
131 G4PersistencyManager* CurrentPersistencyManager() { return f_currentManager; };
132 // returns the pointer of the currnet G4PersistencyManager.
133
134 void SetPersistencyManager(G4PersistencyManager* pm, std::string name);
135 // returns the pointer of the currnet G4PersistencyManager.
136
137 G4PersistencyManager* GetPersistencyManager(std::string nam);
138 // returns the pointer of the currnet G4PersistencyManager with name.
139
140 void RegisterPersistencyManager(G4PersistencyManager* pm);
141 // registers the persistency manager to the runtime catalog.
142
143 void DeletePersistencyManager();
144 // deletes the current G4PersistencyManager.
145
146 void SetVerboseLevel(int v);
147 // Set verbose level.
148
149 int VerboseLevel() { return m_verbose; };
150 // Return verbose level.
151
152 private:
153 std::string PadString(std::string name, unsigned int width);
154 // truncate or pad a string up to the width.
155
156 private:
157 G4PersistencyCenterMessenger* f_G4PersistencyCenterMessenger;
158
159 private:
160 G4PersistencyCenterMessenger* f_theMessenger;
161 static G4PersistencyCenter* f_thePointer;
162 G4PersistencyManager* f_currentManager;
163 std::string f_currentSystemName;
164 PMap f_theCatalog;
165 ObjMap f_wrObj;
166 ObjMap f_rdObj;
167 FileMap f_writeFileName;
168 FileMap f_readFileName;
169 StoreMap f_writeFileMode;
170 BoolMap f_readFileMode;
171 G4int m_verbose;
172#ifndef WIN32
173 G4FileUtilities f_ut;
174#endif
175}; // End of class G4PersistencyCenter
176
177#endif
178
Note: See TracBrowser for help on using the repository browser.