47 if ( fgInstance ==
nullptr ) {
56 G4AccumulableManager::G4AccumulableManager(
G4bool isMaster)
60 if ( ( isMaster && fgMasterInstance ) || ( fgInstance ) ) {
64 <<
"G4AccumulableAnalysisManager already exists."
65 <<
"Cannot create another instance.";
66 G4Exception(
"G4AccumulableAnalysisManager::G4AccumulableAnalysisManager()",
69 if ( isMaster ) fgMasterInstance =
this;
77 for (
auto it : fAccumulablesToDelete ) {
87 G4String G4AccumulableManager::GenerateName()
const
90 std::ostringstream os;
100 if ( fMap.find(name) == fMap.end() )
return true;
103 description <<
" " <<
"Name " << name <<
" is already used." <<
G4endl;
104 description <<
" " <<
"Paremeter will be not created/registered.";
105 G4String method(
"G4AccumulableManager::");
106 method.append(where);
118 auto name = accumulable->
GetName();
121 if ( ! CheckName(name,
"RegisterAccumulable") )
return false;
124 if ( ! name.length() ) {
125 name = GenerateName();
129 fMap[
name] = accumulable;
130 fVector.push_back(accumulable);
139 auto it = fMap.find(name);
140 if ( it == fMap.end() ) {
143 description <<
" " <<
"accumulable " << name <<
" does not exist.";
144 G4Exception(
"G4AccumulableManager::GetAccumulable",
158 if ( id < 0 || id >=
G4int(fVector.size()) ) {
161 description <<
" " <<
"accumulable " <<
id <<
" does not exist.";
162 G4Exception(
"G4AccumulableManager::GetAccumulable",
179 if ( ! fgMasterInstance ) {
182 <<
" " <<
"No master G4AccumulableManager instance exists."
184 <<
" " <<
"Accumulables will not be merged.";
196 auto it = fVector.begin();
197 for (
auto itMaster : fgMasterInstance->fVector ) {
201 itMaster->Merge(*(*(it++)));
211 for (
auto it : fVector ) {
G4Accumulable< T > * GetAccumulable(const G4String &name, G4bool warn=true) const
std::ostringstream G4ExceptionDescription
#define G4MUTEX_INITIALIZER
static G4AccumulableManager * Instance()
G4bool RegisterAccumulable(G4Accumulable< T > &accumulable)
virtual ~G4AccumulableManager()
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
G4String & append(const G4String &)