1 #ifndef fhiclcpp_ParameterSetRegistry_h 2 #define fhiclcpp_ParameterSetRegistry_h 17 #include <unordered_map> 21 class ParameterSetRegistry;
24 class HashParameterSetID;
47 unordered_map<ParameterSetID, ParameterSet, detail::HashParameterSetID>;
48 using key_type =
typename collection_type::key_type;
51 using size_type =
typename collection_type::size_type;
55 static void importFrom(sqlite3* db);
56 static void exportTo(sqlite3* db);
57 static void stageIn();
67 template <
class FwdIt>
68 static std::enable_if_t<
69 std::is_same<typename std::iterator_traits<FwdIt>::value_type,
74 template <
class FwdIt>
75 static std::enable_if_t<
76 std::is_same<typename std::iterator_traits<FwdIt>::value_type,
95 sqlite3_stmt* stmt_{
nullptr};
103 std::lock_guard<decltype(mutex_)> lock{mutex_};
104 return instance_().registry_.empty();
110 std::lock_guard<decltype(mutex_)> lock{mutex_};
111 return instance_().registry_.size();
119 std::lock_guard<decltype(mutex_)> lock{mutex_};
120 return instance_().registry_.emplace(ps.id(), ps).first->first;
124 template <
class FwdIt>
127 std::is_same<typename std::iterator_traits<FwdIt>::value_type,
131 for (; b !=
e; ++b) {
137 template <
class FwdIt>
141 std::is_same<typename std::iterator_traits<FwdIt>::value_type,
144 std::lock_guard<decltype(mutex_)> lock{mutex_};
145 instance_().registry_.insert(b,
e);
153 put(c.cbegin(), c.cend());
159 std::lock_guard<decltype(mutex_)> lock{mutex_};
160 return instance_().registry_;
167 std::lock_guard<decltype(mutex_)> lock{mutex_};
168 auto it = instance_().find_(
id);
169 if (it == instance_().registry_.cend()) {
171 <<
"with ID " <<
id.to_string() <<
" in the registry.";
179 std::lock_guard<decltype(mutex_)> lock{mutex_};
181 auto it = instance_().find_(
id);
182 if (it != instance_().registry_.cend()) {
192 std::lock_guard<decltype(mutex_)> lock{mutex_};
193 auto const& reg = instance_().registry_;
194 return reg.find(
id) != reg.cend();
typename collection_type::size_type size_type
static ParameterSetID const & put(ParameterSet const &ps)
static collection_type const & get() noexcept
std::hash< std::string > hash_
std::string to_string(Protection p)
typename collection_type::mapped_type mapped_type
std::vector< evd::details::RawDigitInfo_t >::const_iterator begin(RawDigitCacheDataClass const &cache)
size_t operator()(ParameterSetID const &id) const
static bool has(ParameterSetID const &id)
static std::recursive_mutex mutex_
std::string value(boost::any const &)
typename collection_type::const_iterator const_iterator
std::vector< evd::details::RawDigitInfo_t >::const_iterator end(RawDigitCacheDataClass const &cache)
typename collection_type::value_type value_type
void throwOnSQLiteFailure(sqlite3 *db, char *msg=nullptr)
cet::coded_exception< error, detail::translate > exception
typename collection_type::key_type key_type
static ParameterSetRegistry & instance_()
std::unordered_map< ParameterSetID, ParameterSet, detail::HashParameterSetID > collection_type