Geant4  10.03.p01
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
G4DCIOcatalog.cc
Go to the documentation of this file.
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: G4DCIOcatalog.cc
27 //
28 // History:
29 // '01.09.12 Youhei Morita Initial creation
30 
31 #include "G4DCIOcatalog.hh"
32 
33 // Addtional Include:
34 #include "G4VDCIOentry.hh"
35 
36 G4ThreadLocal G4DCIOcatalog* G4DCIOcatalog::f_thePointer = 0;
37 
38 // Implementation of Constructor #1
40  : m_verbose(0)
41 {}
42 
43 // Implementation of GetDCIOcatalog
45 {
46  if ( f_thePointer == 0 ) f_thePointer = new G4DCIOcatalog;
47  return f_thePointer;
48 }
49 
50 // Implementation of RegisterEntry
52 {
53  if ( m_verbose > 0 ) {
54  G4cout << "registering I/O manager entry \"" << d->GetName()
55  << "\" " << d << "." << G4endl;
56  }
57  if ( theCatalog.find(d->GetName()) != theCatalog.end() ) {
58  G4cout << "Redefining I/O Managers list " << d->GetName() << G4endl;
59  } else {
60  theCatalog[d->GetName()] = d;
61  }
62 }
63 
64 // Implementation of RegisterDCIOmanager
66 {
67  if ( m_verbose > 0 ) {
68  G4cout << "registering I/O manager \"" << d->DMname()
69  << "\" " << d << "." << G4endl;
70  }
71  if ( theStore.find(d->DMname()) != theStore.end() ) {
72  G4cout << "Redefining I/O Manager " << d->DMname() << G4endl;
73  } else {
74  theStore[d->DMname()] = d;
75  }
76 }
77 
78 // Implementation of GetEntry
80 {
81  if ( theCatalog.find(name) == theCatalog.end() ) {
82  G4cout << "Digit Collection I/O manager entry \"" << name
83  << "\" not found!" << G4endl;
84  return 0;
85  } else {
86  G4VDCIOentry* ds = theCatalog[name];
87  return ds;
88  }
89 }
90 
91 // Implementation of GetDCIOmanager
93 {
94  if ( theStore.find(name) == theStore.end() ) {
95  G4cout << "Digit Collection I/O manager \"" << name
96  << "\" not found!" << G4endl;
97  return 0;
98  } else {
99  G4VPDigitsCollectionIO* ds = theStore[name];
100  return ds;
101  }
102 }
103 
104 // Implementation of PrintEntries
106 {
107  G4cout << "I/O manager entries: ";
108  G4cout << theCatalog.size() << G4endl;
109  DCIOmap::const_iterator it;
110  for ( it=theCatalog.begin(); it != theCatalog.end(); it++ ) {
111  G4cout << " --- " << (*it).first << G4endl;
112  }
113 }
114 
115 // Implementation of CurrentDCIOmanager
117 {
118  std::string list = "";
119  DCIOstore::const_iterator it;
120  for ( it=theStore.begin(); it != theStore.end(); it++ ) {
121  list += (*it).first + " ";
122  }
123  return list;
124 }
125 
126 // Implementation of PrintDCIOmanager
128 {
129  G4cout << "I/O managers: ";
130  G4cout << theStore.size() << G4endl;
131  DCIOstore::const_iterator it;
132  for ( it=theStore.begin(); it != theStore.end(); it++ ) {
133  G4cout << " --- " << (*it).first
134  << ", " << (*it).second << "." << G4endl;
135  }
136 }
137 
138 // Implementation of GetDCIOmanager
140 {
141  int i = 0;
142  DCIOstore::const_iterator it;
143  for ( it=theStore.begin(); it != theStore.end(); it++ ) {
144  if (i++ == n) return (*it).second;
145  }
146  return 0;
147 }
148 
149 // End of G4DCIOcatalog.cc
150 
const XML_Char * name
Definition: expat.h:151
void PrintDCIOmanager()
G4VPDigitsCollectionIO * GetDCIOmanager(std::string name)
#define G4ThreadLocal
Definition: tls.hh:89
void RegisterDCIOmanager(G4VPDigitsCollectionIO *d)
std::string GetName()
Definition: G4VDCIOentry.hh:54
G4GLOB_DLL std::ostream G4cout
G4VDCIOentry * GetEntry(std::string name)
static G4DCIOcatalog * GetDCIOcatalog()
void RegisterEntry(G4VDCIOentry *d)
#define G4endl
Definition: G4ios.hh:61
std::string CurrentDCIOmanager()