Geant4-11
G4AccumulableManager.hh
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
27// The common implementation of analysis manager classes.
28
29// Author: Ivana Hrivnacova, 07/09/2015 (ivana@ipno.in2p3.fr)
30
31#ifndef G4AccumulableManager_h
32#define G4AccumulableManager_h 1
33
34#include "G4Accumulable.hh"
35#include "globals.hh"
36
37#include <map>
38#include <vector>
39
42class G4VAccumulable;
43template <class T>
45
47{
49
50 public:
51 virtual ~G4AccumulableManager();
52
53 // Static methods
55
56 // Methods
57
58 // Create accumulables
59 //
60 template <typename T>
64
65 template <typename T>
69
70 // Register existing accumulables
71 //
72 // templated accumulable
73 template <typename T>
75 // user defined accumulable
77
78 // Access registered accumulables
79 //
80 // Via name
81 // templated accumulable
82 template <typename T>
83 G4Accumulable<T>* GetAccumulable(const G4String& name, G4bool warn = true) const;
84 // user defined accumulable
85 G4VAccumulable* GetAccumulable(const G4String& name, G4bool warn = true) const;
86
87 // Via id (in the order of registering)
88 // templated accumulable
89 template <typename T>
91 // user defined accumulable
92 G4VAccumulable* GetAccumulable(G4int id, G4bool warn = true) const;
94
95 // Via vector iterators
96 std::vector<G4VAccumulable*>::iterator Begin();
97 std::vector<G4VAccumulable*>::iterator End();
98 std::vector<G4VAccumulable*>::const_iterator BeginConst() const;
99 std::vector<G4VAccumulable*>::const_iterator EndConst() const;
100
101 // Methods applied to all accumulables
102 void Merge();
103 void Reset();
104
105 private:
106 // Hide singleton ctor
108
109 // Methods
110 // Generate generic accumulable name: accumulableN, where N is the actual number of accumulables
111 G4String GenerateName() const;
112 // Check if a name is already used in a map and print a warning
113 G4bool CheckName(const G4String& name, const G4String& where) const;
114
115 template <typename T>
117
118 // Constants
119 const G4String kBaseName = "accumulable";
120
121 // Static data members
122 inline static G4AccumulableManager* fgMasterInstance { nullptr };
123
124 // Data members
125 std::vector<G4VAccumulable*> fVector;
126 std::map<G4String, G4VAccumulable*> fMap;
127 std::vector<G4VAccumulable*> fAccumulablesToDelete;
128 };
129
131
132#endif
133
G4MergeMode
Definition: G4MergeMode.hh:40
bool G4bool
Definition: G4Types.hh:86
int G4int
Definition: G4Types.hh:85
G4String GenerateName() const
G4Accumulable< T > * GetAccumulable(G4VAccumulable *accumulable, G4bool warn) const
std::vector< G4VAccumulable * > fVector
G4Accumulable< T > * GetAccumulable(const G4String &name, G4bool warn=true) const
std::map< G4String, G4VAccumulable * > fMap
G4Accumulable< T > * CreateAccumulable(const G4String &name, T value, G4MergeMode mergeMode=G4MergeMode::kAddition)
std::vector< G4VAccumulable * >::iterator Begin()
G4int GetNofAccumulables() const
static G4AccumulableManager * Instance()
std::vector< G4VAccumulable * >::const_iterator EndConst() const
std::vector< G4VAccumulable * > fAccumulablesToDelete
G4bool RegisterAccumulable(G4Accumulable< T > &accumulable)
std::vector< G4VAccumulable * >::iterator End()
G4Accumulable< T > * GetAccumulable(G4int id, G4bool warn=true) const
static G4AccumulableManager * fgMasterInstance
G4Accumulable< T > * CreateAccumulable(T value, G4MergeMode mergeMode=G4MergeMode::kAddition)
std::vector< G4VAccumulable * >::const_iterator BeginConst() const
G4bool CheckName(const G4String &name, const G4String &where) const
const char * name(G4int ptype)