1 #ifndef FWCore_Utilities_ThreadSafeRegistry_h 2 #define FWCore_Utilities_ThreadSafeRegistry_h 29 #pragma GCC visibility push(default) 33 template <
typename KEY,
typename T>
86 void print(std::ostream&
os)
const;
96 template <
typename KEY,
typename T,
typename E>
97 inline std::ostream& operator<<(std::ostream& os, ThreadSafeRegistry<KEY, T>
const& reg) {
102 template <
typename KEY,
typename T>
104 for (
auto const&
item :
c) {
105 insertMapped(
item.second);
109 template <
typename KEY,
typename T>
111 for (
auto const&
item :
c) {
116 template <
typename KEY,
typename T>
118 std::lock_guard<std::mutex> guard(mutex_);
119 return data_.empty();
122 template <
typename KEY,
typename T>
127 template <
typename KEY,
typename T>
129 std::lock_guard<std::mutex> guard(mutex_);
133 template <
typename KEY,
typename T>
135 std::lock_guard<std::mutex> guard(mutex_);
136 os <<
"Registry with " << size() <<
" entries\n";
137 for (
auto const&
item : data_) {
138 os <<
item.first <<
" " <<
item.second <<
'\n';
142 template <
typename KEY,
typename T>
145 template <
typename KEY,
typename T>
150 #pragma GCC visibility pop 151 #endif // FWCore_Utilities_ThreadSafeRegistry_h
bool empty() const
Return true if there are no contained value_type objects.
std::map< key_type, value_type > collection_type
collection_type::size_type size_type
bool insertMapped(value_type const &v)
size_type size() const
Return the number of contained value_type objects.
std::vector< value_type > vector_type
bool getMapped(key_type const &k, value_type &result) const
static ThreadSafeRegistry * instance()
void print(std::ostream &os) const
Print the contents of this registry to the given ostream.
void insertCollection(collection_type const &c)
bool notEmpty() const
Return true if there are any contained value_type objects.
ThreadSafeRegistry< KEY, T > & operator=(ThreadSafeRegistry< KEY, T > const &)=delete