46 if ( fgInstance ==
nullptr ) {
55G4AccumulableManager::G4AccumulableManager(
G4bool isMaster)
59 if ( ( isMaster && fgMasterInstance ) || ( fgInstance ) ) {
63 <<
"G4AccumulableAnalysisManager already exists."
64 <<
"Cannot create another instance.";
65 G4Exception(
"G4AccumulableAnalysisManager::G4AccumulableAnalysisManager()",
68 if ( isMaster ) fgMasterInstance =
this;
76 for (
auto it : fAccumulablesToDelete ) {
86G4String G4AccumulableManager::GenerateName()
const
89 std::ostringstream os;
92 name.append(os.str());
99 if ( fMap.find(name) == fMap.end() )
return true;
102 description <<
" " <<
"Name " <<
name <<
" is already used." <<
G4endl;
103 description <<
" " <<
"Parameter will be not created/registered.";
104 G4String method(
"G4AccumulableManager::");
105 method.append(where);
117 auto name = accumulable->
GetName();
120 if ( ! CheckName(name,
"RegisterAccumulable") )
return false;
123 if ( ! name.length() ) {
124 name = GenerateName();
125 accumulable->
fName = name;
128 fMap[name] = accumulable;
129 fVector.push_back(accumulable);
138 auto it = fMap.find(name);
139 if ( it == fMap.end() ) {
142 description <<
" " <<
"accumulable " << name <<
" does not exist.";
143 G4Exception(
"G4AccumulableManager::GetAccumulable",
157 if ( id < 0 || id >=
G4int(fVector.size()) ) {
160 description <<
" " <<
"accumulable " <<
id <<
" does not exist.";
161 G4Exception(
"G4AccumulableManager::GetAccumulable",
178 if ( ! fgMasterInstance ) {
181 <<
" " <<
"No master G4AccumulableManager instance exists."
183 <<
" " <<
"Accumulables will not be merged.";
195 auto it = fVector.begin();
196 for (
auto itMaster : fgMasterInstance->fVector ) {
200 itMaster->Merge(*(*(it++)));
210 for (
auto it : fVector ) {
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
std::ostringstream G4ExceptionDescription
#define G4MUTEX_INITIALIZER
G4Accumulable< T > * GetAccumulable(const G4String &name, G4bool warn=true) const
virtual ~G4AccumulableManager()
static G4AccumulableManager * Instance()
G4bool RegisterAccumulable(G4Accumulable< T > &accumulable)
const char * name(G4int ptype)