From e30c67570cc0926e869a4e30f72045baa6406f3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Brochet?= Date: Thu, 17 Sep 2015 09:53:19 +0200 Subject: [PATCH] Ensure that categories and cuts are unique. Fix #56 --- interface/Category.h | 4 ++++ src/Cut.cc | 3 +++ 2 files changed, 7 insertions(+) diff --git a/interface/Category.h b/interface/Category.h index 55bd8b7..c7f2d2f 100644 --- a/interface/Category.h +++ b/interface/Category.h @@ -91,6 +91,10 @@ class CategoryManager { public: template void new_category(const std::string& name, const std::string& description, const edm::ParameterSet& config) { + if (m_categories.count(name) > 0) { + throw edm::Exception(edm::errors::InsertFailure, "A category named '" + name + "' already exists."); + } + std::unique_ptr category(new T()); category->configure(config); m_categories.emplace(name, CategoryData(name, description, std::move(category), m_tree)); diff --git a/src/Cut.cc b/src/Cut.cc index f0d946c..eb82e27 100644 --- a/src/Cut.cc +++ b/src/Cut.cc @@ -2,6 +2,9 @@ #include void CutManager::new_cut(const std::string& name, const std::string& description) { + if (m_cuts.count(name) > 0) { + throw edm::Exception(edm::errors::InsertFailure, "A cut named '" + name + "' already exists."); + } m_cuts.emplace(name, Cut(name, description, m_category.tree)); }