[Rivet-svn] r1784 - in trunk: . src

blackhole at projects.hepforge.org blackhole at projects.hepforge.org
Mon Aug 31 08:25:18 BST 2009


Author: buckley
Date: Mon Aug 31 08:25:18 2009
New Revision: 1784

Log:
Exit with error if addProjection is used twice from the same parent to register distinct projections with the same name.

Modified:
   trunk/ChangeLog
   trunk/src/ProjectionHandler.cc

Modified: trunk/ChangeLog
==============================================================================
--- trunk/ChangeLog	Sat Aug 29 20:45:00 2009	(r1783)
+++ trunk/ChangeLog	Mon Aug 31 08:25:18 2009	(r1784)
@@ -1,3 +1,8 @@
+2009-08-31  Andy Buckley  <andy at insectnation.org>
+
+	* Exit with an error message if addProjection is used twice from
+	the same parent with distinct projections.
+
 2009-08-28  Andy Buckley  <andy at insectnation.org>
 
 	* Changed naming convention for analysis plugin libraries, since

Modified: trunk/src/ProjectionHandler.cc
==============================================================================
--- trunk/src/ProjectionHandler.cc	Sat Aug 29 20:45:00 2009	(r1783)
+++ trunk/src/ProjectionHandler.cc	Mon Aug 31 08:25:18 2009	(r1784)
@@ -29,9 +29,9 @@
 
 
   void ProjectionHandler::clear() {
-    for (ProjHandles::iterator ph = _projs.begin(); ph != _projs.end(); ++ph) {
-      getLog() << Log::TRACE << "Deleting projection at " << *ph << endl;
-      delete *ph;
+    foreach (ProjHandles::value_type& ph, _projs) {
+      getLog() << Log::TRACE << "Deleting projection at " << ph << endl;
+      delete ph;
     }
     _projs.clear();
     _namedprojs.clear();
@@ -113,8 +113,15 @@
       }
     }
 
-    // If we found no match, add passed Projection to _projs and the
-    // ProjApplier* => name location in the associative container.
+    // If there is no match, check that the same parent hasn't already used this name for something else
+    if (_namedprojs[&parent].find(name) != _namedprojs[&parent].end()) {
+      getLog() << Log::ERROR << parent.name() << " has already tried to register a different projection "
+               << "with name " << name << endl;
+      exit(1);
+    }
+
+    // If we found no match, and the name is free, add the passed Projection to _projs, and
+    // add the ProjApplier* => name location to the associative container.
     getLog() << Log::TRACE << "Registered new projection at " << &proj << endl;
     _projs.push_back(&proj);
     _namedprojs[&parent][name] = &proj;


More information about the Rivet-svn mailing list