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...
 
bool getMapped (key_type const &k, value_type &result) const
 
value_type const * getMapped (key_type const &k) 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...
 
ThreadSafeRegistry< KEY, T > & operator= (ThreadSafeRegistry< KEY, T > const &)=delete
 
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...
 
 ThreadSafeRegistry (ThreadSafeRegistry< KEY, T > const &)=delete
 

Static Public Member Functions

static ThreadSafeRegistryinstance ()
 

Private Member Functions

 ThreadSafeRegistry ()
 
 ~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 ( ThreadSafeRegistry< KEY, T > const &  )
delete

◆ ThreadSafeRegistry() [2/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 {}

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>
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().

◆ getMapped() [2/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.

◆ 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.

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

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

◆ 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.

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

110  {
111  for (auto const& item : c) {
113  }
114  }
bool insertMapped(value_type const &v)

◆ 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.

References relativeConstraints::empty.

123  {
124  return !empty();
125  }
bool empty() const
Return true if there are no contained value_type objects.

◆ operator=()

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

◆ 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.

References B2GTnPMonitor_cfi::item, and l1tGTMenu_BTagSeeds_cff::os.

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  }
size_type size() const
Return the number of contained value_type objects.

◆ 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.

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

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

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.