1 #ifndef FWCore_Utilities_ThreadSafeRegistry_h 2 #define FWCore_Utilities_ThreadSafeRegistry_h 29 #pragma GCC visibility push(default) 33 template <
typename KEY,
typename T>
55 value_type
const*
getMapped(key_type
const&
k)
const;
78 size_type
size()
const;
81 void print(std::ostream& os)
const;
97 template <
typename KEY,
typename T,
typename E>
100 operator<< (std::ostream& os, ThreadSafeRegistry<KEY,T>
const& reg) {
105 template <
typename KEY,
typename T>
108 for (
auto const& item: c ) {
113 template <
typename KEY,
typename T>
116 for (
auto const& item: c) {
121 template <
typename KEY,
typename T>
125 std::lock_guard<std::mutex> guard(
mutex_);
126 return data_.empty();
129 template <
typename KEY,
typename T>
136 template <
typename KEY,
typename T>
140 std::lock_guard<std::mutex> guard(
mutex_);
144 template <
typename KEY,
typename T>
147 std::lock_guard<std::mutex> guard(
mutex_);
148 os <<
"Registry with " <<
size() <<
" entries\n";
149 for (
auto const& item:
data_) {
150 os << item.first <<
" " << item.second <<
'\n';
154 template <
typename KEY,
typename T>
160 template <
typename KEY,
typename T>
166 #pragma GCC visibility pop 167 #endif // FWCore_Utilities_ThreadSafeRegistry_h
static boost::mutex mutex
size_type size() const
Return the number of contained value_type objects.
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)
std::vector< value_type > vector_type
ThreadSafeRegistry< KEY, T > & operator=(ThreadSafeRegistry< KEY, T > const &)=delete
static ThreadSafeRegistry * instance()
bool getMapped(key_type const &k, value_type &result) const
void insertCollection(collection_type const &c)
void print(std::ostream &os) const
Print the contents of this registry to the given ostream.
bool notEmpty() const
Return true if there are any contained value_type objects.