File indexing completed on 2025-01-18 09:57:51
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031 #ifndef G4AccumulableManager_h
0032 #define G4AccumulableManager_h 1
0033
0034 #include "G4Accumulable.hh"
0035 #include "globals.hh"
0036
0037 #include <map>
0038 #include <vector>
0039
0040 class G4AccumulableManager;
0041 class G4AnalysisManagerState;
0042 class G4VAccumulable;
0043 template <class T>
0044 class G4ThreadLocalSingleton;
0045
0046 class G4AccumulableManager
0047 {
0048 friend class G4ThreadLocalSingleton<G4AccumulableManager>;
0049
0050 public:
0051 virtual ~G4AccumulableManager();
0052
0053
0054 static G4AccumulableManager* Instance();
0055
0056
0057
0058
0059
0060 template <typename T>
0061 G4Accumulable<T>*
0062 CreateAccumulable(const G4String& name, T value,
0063 G4MergeMode mergeMode = G4MergeMode::kAddition);
0064
0065 template <typename T>
0066 G4Accumulable<T>*
0067 CreateAccumulable(T value,
0068 G4MergeMode mergeMode = G4MergeMode::kAddition);
0069
0070
0071
0072
0073 template <typename T>
0074 G4bool RegisterAccumulable(G4Accumulable<T>& accumulable);
0075
0076 G4bool RegisterAccumulable(G4VAccumulable* accumulable);
0077
0078
0079
0080
0081
0082 template <typename T>
0083 G4Accumulable<T>* GetAccumulable(const G4String& name, G4bool warn = true) const;
0084
0085 G4VAccumulable* GetAccumulable(const G4String& name, G4bool warn = true) const;
0086
0087
0088
0089 template <typename T>
0090 G4Accumulable<T>* GetAccumulable(G4int id, G4bool warn = true) const;
0091
0092 G4VAccumulable* GetAccumulable(G4int id, G4bool warn = true) const;
0093 G4int GetNofAccumulables() const;
0094
0095
0096 std::vector<G4VAccumulable*>::iterator Begin();
0097 std::vector<G4VAccumulable*>::iterator End();
0098 std::vector<G4VAccumulable*>::const_iterator BeginConst() const;
0099 std::vector<G4VAccumulable*>::const_iterator EndConst() const;
0100
0101
0102 void Merge();
0103 void Reset();
0104
0105 private:
0106
0107 G4AccumulableManager();
0108
0109
0110
0111 G4String GenerateName() const;
0112
0113 G4bool CheckName(const G4String& name, const G4String& where) const;
0114
0115 template <typename T>
0116 G4Accumulable<T>* GetAccumulable(G4VAccumulable* accumulable, G4bool warn) const;
0117
0118
0119 const G4String kBaseName = "accumulable";
0120
0121
0122 inline static G4AccumulableManager* fgMasterInstance { nullptr };
0123
0124
0125 std::vector<G4VAccumulable*> fVector;
0126 std::map<G4String, G4VAccumulable*> fMap;
0127 std::vector<G4VAccumulable*> fAccumulablesToDelete;
0128 };
0129
0130 #include "G4AccumulableManager.icc"
0131
0132 #endif
0133