1 #ifndef fhiclcpp_ParameterSetRegistry_h 2 #define fhiclcpp_ParameterSetRegistry_h 13 #include "hep_concurrency/RecursiveMutex.h" 17 #include <unordered_map> 21 class ParameterSetRegistry;
24 class HashParameterSetID;
48 unordered_map<ParameterSetID, ParameterSet, detail::HashParameterSetID>;
49 using key_type =
typename collection_type::key_type;
52 using size_type =
typename collection_type::size_type;
56 static void importFrom(sqlite3*
db);
57 static void exportTo(sqlite3*
db);
58 static void stageIn();
68 template <
class FwdIt>
69 static std::enable_if_t<
70 std::is_same_v<typename std::iterator_traits<FwdIt>::value_type,
72 put(FwdIt begin, FwdIt
end);
75 template <
class FwdIt>
76 static std::enable_if_t<
77 std::is_same_v<typename std::iterator_traits<FwdIt>::value_type,
79 put(FwdIt begin, FwdIt
end);
96 sqlite3_stmt* stmt_{
nullptr};
98 static hep::concurrency::RecursiveMutex
mutex_;
104 hep::concurrency::RecursiveMutexSentry sentry{mutex_, __func__};
105 return instance_().registry_.empty();
111 hep::concurrency::RecursiveMutexSentry sentry{mutex_, __func__};
112 return instance_().registry_.size();
120 hep::concurrency::RecursiveMutexSentry sentry{mutex_, __func__};
121 return instance_().registry_.emplace(
ps.id(),
ps).first->first;
125 template <
class FwdIt>
128 std::is_same_v<typename std::iterator_traits<FwdIt>::value_type,
mapped_type>>
131 for (;
b !=
e; ++
b) {
137 template <
class FwdIt>
141 std::is_same_v<typename std::iterator_traits<FwdIt>::value_type,
144 hep::concurrency::RecursiveMutexSentry sentry{mutex_, __func__};
145 instance_().registry_.insert(
b,
e);
153 put(c.cbegin(), c.cend());
159 hep::concurrency::RecursiveMutexSentry sentry{mutex_, __func__};
160 return instance_().registry_;
167 hep::concurrency::RecursiveMutexSentry sentry{mutex_, __func__};
168 auto it = instance_().find_(
id);
169 if (
it == instance_().registry_.cend()) {
171 <<
"with ID " <<
id.to_string() <<
" in the registry.";
179 hep::concurrency::RecursiveMutexSentry sentry{mutex_, __func__};
181 auto it = instance_().find_(
id);
182 if (
it != instance_().registry_.cend()) {
192 hep::concurrency::RecursiveMutexSentry sentry{mutex_, __func__};
193 auto const& reg = instance_().registry_;
194 return reg.find(
id) != reg.cend();
::xsd::cxx::tree::id< char, ncname > id
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
size_t operator()(ParameterSetID const &id) const
static bool has(ParameterSetID const &id)
static hep::concurrency::RecursiveMutex mutex_
typename collection_type::const_iterator const_iterator
void throwOnSQLiteFailure(int rc, char *msg=nullptr)
typename collection_type::value_type value_type
typedef void(XMLCALL *XML_ElementDeclHandler)(void *userData
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