CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
edm::detail::ThreadSafeRegistry< KEY, T > Class Template Reference

#include <ThreadSafeRegistry.h>

Public Types

typedef std::map< key_type, value_typecollection_type
 
typedef KEY key_type
 
typedef collection_type::size_type size_type
 
typedef T value_type
 
typedef std::vector< value_typevector_type
 

Public Member Functions

bool empty () const
 Return true if there are no contained value_type objects. More...
 
value_type const * getMapped (key_type const &k) const
 
bool getMapped (key_type const &k, value_type &result) const
 
void insertCollection (collection_type const &c)
 
void insertCollection (vector_type const &c)
 
bool insertMapped (value_type const &v)
 
bool notEmpty () const
 Return true if there are any contained value_type objects. More...
 
void print (std::ostream &os) const
 Print the contents of this registry to the given ostream. More...
 
size_type size () const
 Return the number of contained value_type objects. More...
 

Static Public Member Functions

static ThreadSafeRegistryinstance ()
 

Private Member Functions

ThreadSafeRegistry< KEY, T > & operator= (ThreadSafeRegistry< KEY, T > const &)=delete
 
 ThreadSafeRegistry ()
 
 ThreadSafeRegistry (ThreadSafeRegistry< KEY, T > const &)=delete
 
 ~ThreadSafeRegistry ()
 

Private Attributes

collection_type data_
 
std::mutex mutex_
 

Detailed Description

template<typename KEY, typename T>
class edm::detail::ThreadSafeRegistry< KEY, T >

Definition at line 34 of file ThreadSafeRegistry.h.

Member Typedef Documentation

◆ collection_type

template<typename KEY, typename T>
typedef std::map<key_type, value_type> edm::detail::ThreadSafeRegistry< KEY, T >::collection_type

Definition at line 38 of file ThreadSafeRegistry.h.

◆ key_type

template<typename KEY, typename T>
typedef KEY edm::detail::ThreadSafeRegistry< KEY, T >::key_type

Definition at line 36 of file ThreadSafeRegistry.h.

◆ size_type

template<typename KEY, typename T>
typedef collection_type::size_type edm::detail::ThreadSafeRegistry< KEY, T >::size_type

Definition at line 39 of file ThreadSafeRegistry.h.

◆ value_type

template<typename KEY, typename T>
typedef T edm::detail::ThreadSafeRegistry< KEY, T >::value_type

Definition at line 37 of file ThreadSafeRegistry.h.

◆ vector_type

template<typename KEY, typename T>
typedef std::vector<value_type> edm::detail::ThreadSafeRegistry< KEY, T >::vector_type

Definition at line 41 of file ThreadSafeRegistry.h.

Constructor & Destructor Documentation

◆ ThreadSafeRegistry() [1/2]

template<typename KEY , typename T >
edm::detail::ThreadSafeRegistry< KEY, T >::ThreadSafeRegistry ( )
private

Definition at line 143 of file ThreadSafeRegistry.h.

143 : data_() {}

◆ ~ThreadSafeRegistry()

template<typename KEY , typename T >
edm::detail::ThreadSafeRegistry< KEY, T >::~ThreadSafeRegistry ( )
private

Definition at line 146 of file ThreadSafeRegistry.h.

146 {}

◆ ThreadSafeRegistry() [2/2]

template<typename KEY, typename T>
edm::detail::ThreadSafeRegistry< KEY, T >::ThreadSafeRegistry ( ThreadSafeRegistry< KEY, T > const &  )
privatedelete

Member Function Documentation

◆ empty()

template<typename KEY , typename T >
bool edm::detail::ThreadSafeRegistry< KEY, T >::empty ( void  ) const
inline

Return true if there are no contained value_type objects.

Definition at line 117 of file ThreadSafeRegistry.h.

117  {
118  std::lock_guard<std::mutex> guard(mutex_);
119  return data_.empty();
120  }

◆ getMapped() [1/2]

template<typename KEY, typename T>
value_type const* edm::detail::ThreadSafeRegistry< KEY, T >::getMapped ( key_type const &  k) const

Retrieve a pointer to the value_type object with the given key. If there is no object associated with the given key 0 is returned.

◆ getMapped() [2/2]

template<typename KEY, typename T>
bool edm::detail::ThreadSafeRegistry< KEY, T >::getMapped ( key_type const &  k,
value_type result 
) const

Retrieve the value_type object with the given key. If we return 'true', then 'result' carries the value_type object. If we return 'false, no matching key was found, and the value of 'result' is undefined.

Referenced by HLTConfigProvider::getDataFrom().

◆ insertCollection() [1/2]

template<typename KEY , typename T >
void edm::detail::ThreadSafeRegistry< KEY, T >::insertCollection ( collection_type const &  c)

put the value_type objects in the given collection into the registry.

Definition at line 103 of file ThreadSafeRegistry.h.

103  {
104  for (auto const& item : c) {
105  insertMapped(item.second);
106  }
107  }

References HltBtagPostValidation_cff::c, and B2GTnPMonitor_cfi::item.

◆ insertCollection() [2/2]

template<typename KEY , typename T >
void edm::detail::ThreadSafeRegistry< KEY, T >::insertCollection ( vector_type const &  c)

Definition at line 110 of file ThreadSafeRegistry.h.

110  {
111  for (auto const& item : c) {
113  }
114  }

References HltBtagPostValidation_cff::c, and B2GTnPMonitor_cfi::item.

◆ insertMapped()

template<typename KEY, typename T>
template bool edm::detail::ThreadSafeRegistry< KEY, T >::insertMapped ( value_type const &  v)

Insert the given value_type object into the registry. If there was already a value_type object with the same key, we don't change it. This should be OK, since it should have the same contents if the key is the same. Return 'true' if we really added the new value_type object, and 'false' if the value_type object was already present.

Referenced by HLTConfigProvider::getDataFrom().

◆ instance()

template<typename KEY, typename T>
template ThreadSafeRegistry< HLTConfigDataRegistry::key_type, HLTConfigDataRegistry::value_type > * edm::detail::ThreadSafeRegistry< KEY, T >::instance ( )
static

◆ notEmpty()

template<typename KEY , typename T >
bool edm::detail::ThreadSafeRegistry< KEY, T >::notEmpty ( ) const
inline

Return true if there are any contained value_type objects.

Definition at line 123 of file ThreadSafeRegistry.h.

123  {
124  return !empty();
125  }

References relativeConstraints::empty.

◆ operator=()

template<typename KEY, typename T>
ThreadSafeRegistry<KEY, T>& edm::detail::ThreadSafeRegistry< KEY, T >::operator= ( ThreadSafeRegistry< KEY, T > const &  )
privatedelete

◆ print()

template<typename KEY , typename T >
void edm::detail::ThreadSafeRegistry< KEY, T >::print ( std::ostream &  os) const

Print the contents of this registry to the given ostream.

Definition at line 134 of file ThreadSafeRegistry.h.

134  {
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';
139  }
140  }

References B2GTnPMonitor_cfi::item, and findQualityFiles::size.

Referenced by edm::detail::operator<<().

◆ size()

template<typename KEY , typename T >
ThreadSafeRegistry< KEY, T >::size_type edm::detail::ThreadSafeRegistry< KEY, T >::size ( void  ) const
inline

Return the number of contained value_type objects.

Definition at line 128 of file ThreadSafeRegistry.h.

128  {
129  std::lock_guard<std::mutex> guard(mutex_);
130  return data_.size();
131  }

Referenced by ntupleDataFormat._Collection::__iter__(), and ntupleDataFormat._Collection::__len__().

Member Data Documentation

◆ data_

template<typename KEY, typename T>
collection_type edm::detail::ThreadSafeRegistry< KEY, T >::data_
private

Definition at line 93 of file ThreadSafeRegistry.h.

◆ mutex_

template<typename KEY, typename T>
std::mutex edm::detail::ThreadSafeRegistry< KEY, T >::mutex_
mutableprivate

Definition at line 92 of file ThreadSafeRegistry.h.

edm::detail::ThreadSafeRegistry::empty
bool empty() const
Return true if there are no contained value_type objects.
Definition: ThreadSafeRegistry.h:117
edm::detail::ThreadSafeRegistry::insertMapped
bool insertMapped(value_type const &v)
edm::detail::ThreadSafeRegistry::size
size_type size() const
Return the number of contained value_type objects.
Definition: ThreadSafeRegistry.h:128
edm::detail::ThreadSafeRegistry::mutex_
std::mutex mutex_
Definition: ThreadSafeRegistry.h:92
B2GTnPMonitor_cfi.item
item
Definition: B2GTnPMonitor_cfi.py:147
HltBtagPostValidation_cff.c
c
Definition: HltBtagPostValidation_cff.py:31
edm::detail::ThreadSafeRegistry::data_
collection_type data_
Definition: ThreadSafeRegistry.h:93