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

Last change on this file since 818 was 818, checked in by garnier, 16 years ago

import all except CVS

File size: 6.7 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 "G4VHCIOentry.hh"
40#include "G4DCIOcatalog.hh"
41#include "G4VDCIOentry.hh"
42
43#ifndef WIN32
44  #include "G4FileUtilities.hh"
45#endif
46
47// Forward Declaration to avoid circular dependencies.
48class G4PersistencyManager;
49
50typedef std::map<std::string, G4PersistencyManager*,std::less<std::string> > PMap;
51typedef std::map<int, std::string, std::less<int> > ObjMap;
52typedef std::map<std::string, std::string, std::less<std::string> > FileMap;
53
54enum StoreMode { kOn, kOff, kRecycle };
55
56typedef std::map<std::string, StoreMode, std::less<std::string> > StoreMap;
57typedef std::map<std::string, G4bool, std::less<std::string> >     BoolMap;
58
59// Forward Declarations:
60class G4PersistencyCenterMessenger;
61
62// Class Description:
63//   Class to handle loading of the G4PersistencyManager.
64
65class G4PersistencyCenter
66{
67    public: // With description
68      G4PersistencyCenter();
69      G4PersistencyCenter(const G4PersistencyCenter&);
70      // Constructor
71
72      ~G4PersistencyCenter();
73      // Destructor
74
75    public: // With description
76      static G4PersistencyCenter* GetPersistencyCenter();
77      // returns the pointer of singleton G4PersistencyCenter
78
79      void SelectSystem(std::string systemName);
80      // Select the persistency package
81
82      const std::string CurrentSystem() { return f_currentSystemName; };
83      // returns the current persistent package name
84
85      void SetHepMCObjyReaderFile(std::string file);
86      // Sets the name of HepMCObjyReader file name.  To be called by generator.
87
88      std::string CurrentHepMCObjyReaderFile();
89      // Sets the name of HepMCObjyReader file name.  To be called by generator.
90
91      void SetStoreMode(std::string objName, StoreMode mode);
92      // Sets the object store mode.  Modes are kOn, kOff or kRecycle.
93
94      void SetRetrieveMode(std::string objName, G4bool mode);
95      // Sets the object retrieve mode.  Modes are true or false.
96
97      StoreMode CurrentStoreMode(std::string objName);
98      // returns the current object store mode.
99
100      G4bool CurrentRetrieveMode(std::string objName);
101      // returns the current object store mode.
102
103      G4bool SetWriteFile(std::string objName, std::string writeFileName);
104      // Sets the output filename.
105
106      G4bool SetReadFile(std::string objName, std::string readFileName);
107      // Sets the input filename.
108
109      std::string CurrentWriteFile(std::string objName);
110      // returns the current output filename.
111
112      std::string CurrentReadFile(std::string objName);
113      // returns the current input filename.
114
115      std::string CurrentObject(std::string file);
116      // returns the current object type
117
118      void AddHCIOmanager(std::string detName, std::string colName);
119      // add a hits colleciton I/O manager to the catalog
120
121      std::string CurrentHCIOmanager();
122      // Returns a list of registered hits colleciton I/O managers
123
124      void AddDCIOmanager(std::string detName);
125      // add a digits colleciton I/O manager to the catalog
126
127      std::string CurrentDCIOmanager();
128      // Returns a list of registered digits colleciton I/O managers
129
130      void PrintAll();
131      // prints the current G4PersistencyCenter settings.
132
133      G4PersistencyManager* CurrentPersistencyManager() { return f_currentManager; };
134      // returns the pointer of the currnet G4PersistencyManager.
135
136      void SetPersistencyManager(G4PersistencyManager* pm, std::string name);
137      // returns the pointer of the currnet G4PersistencyManager.
138
139      G4PersistencyManager* GetPersistencyManager(std::string nam);
140      // returns the pointer of the currnet G4PersistencyManager with name.
141
142      void RegisterPersistencyManager(G4PersistencyManager* pm);
143      // registers the persistency manager to the runtime catalog.
144
145      void DeletePersistencyManager();
146      // deletes the current G4PersistencyManager.
147
148      void SetVerboseLevel(int v);
149      // Set verbose level.
150
151      int VerboseLevel() { return m_verbose; };
152      // Return verbose level.
153
154    private:
155      std::string PadString(std::string name, unsigned int width);
156      // truncate or pad a string up to the width.
157
158    private:
159      G4PersistencyCenterMessenger* f_G4PersistencyCenterMessenger;
160
161    private:
162      G4PersistencyCenterMessenger* f_theMessenger;
163      static G4PersistencyCenter*   f_thePointer;
164      G4PersistencyManager*         f_currentManager;
165      std::string                 f_currentSystemName;
166      PMap                          f_theCatalog;
167      ObjMap                        f_wrObj;
168      ObjMap                        f_rdObj;
169      FileMap                       f_writeFileName;
170      FileMap                       f_readFileName;
171      StoreMap                      f_writeFileMode;
172      BoolMap                       f_readFileMode;
173      G4int                         m_verbose;
174#ifndef WIN32
175      G4FileUtilities               f_ut;
176#endif
177}; // End of class G4PersistencyCenter
178
179#endif
180
Note: See TracBrowser for help on using the repository browser.