Skip to content
Snippets Groups Projects
Commit ea505c56 authored by Andre Sailer's avatar Andre Sailer
Browse files

DetectorData: Warn if a second object (e.g., constant) is created, as insert...

DetectorData: Warn if a second object (e.g., constant) is created, as insert will not overwrite the existing one
parent 212f4afd
No related branches found
No related tags found
No related merge requests found
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#define DD4HEP_DDCORE_DETECTORDATA_H #define DD4HEP_DDCORE_DETECTORDATA_H
// Framework includes // Framework includes
#include "DD4hep/Printout.h"
#include "DD4hep/Detector.h" #include "DD4hep/Detector.h"
#include "DD4hep/ObjectExtensions.h" #include "DD4hep/ObjectExtensions.h"
#include "DD4hep/detail/VolumeManagerInterna.h" #include "DD4hep/detail/VolumeManagerInterna.h"
...@@ -64,8 +65,12 @@ namespace dd4hep { ...@@ -64,8 +65,12 @@ namespace dd4hep {
if (e.isValid()) { if (e.isValid()) {
std::string n = e.name(); std::string n = e.name();
std::pair<iterator, bool> r = this->insert(std::make_pair(n, e.ptr())); std::pair<iterator, bool> r = this->insert(std::make_pair(n, e.ptr()));
if (!throw_on_doubles || r.second) if (!throw_on_doubles || r.second) {
if (not r.second) {
printout(WARNING,"Detector","+++ Object '%s' is already defined and new one will be ignored", n.c_str());
}
return; return;
}
throw InvalidObjectError("Attempt to add an already existing object:" + std::string(e.name()) + "."); throw InvalidObjectError("Attempt to add an already existing object:" + std::string(e.name()) + ".");
} }
throw InvalidObjectError("Attempt to add an invalid object."); throw InvalidObjectError("Attempt to add an invalid object.");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment