CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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_type
collection_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...
 
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 &)
 
 ThreadSafeRegistry ()
 
 ThreadSafeRegistry (ThreadSafeRegistry< KEY, T > const &)
 
 ~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

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.

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

Definition at line 36 of file ThreadSafeRegistry.h.

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.

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

Definition at line 37 of file ThreadSafeRegistry.h.

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

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

Definition at line 155 of file ThreadSafeRegistry.h.

155  :
156  data_()
157  { }
template<typename KEY , typename T >
edm::detail::ThreadSafeRegistry< KEY, T >::~ThreadSafeRegistry ( )
private

Definition at line 161 of file ThreadSafeRegistry.h.

162  { }
template<typename KEY, typename T>
edm::detail::ThreadSafeRegistry< KEY, T >::ThreadSafeRegistry ( ThreadSafeRegistry< KEY, T > const &  )
private

Member Function Documentation

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 124 of file ThreadSafeRegistry.h.

124  {
125  std::lock_guard<std::mutex> guard(mutex_);
126  return data_.empty();
127  }
template<typename KEY, typename T>
template 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().

template<typename KEY, typename T>
template HLTConfigDataRegistry::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.

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 107 of file ThreadSafeRegistry.h.

107  {
108  for (auto const& item: c ) {
109  insertMapped(item.second);
110  }
111  }
bool insertMapped(value_type const &v)
template<typename KEY , typename T >
void edm::detail::ThreadSafeRegistry< KEY, T >::insertCollection ( vector_type const &  c)

Definition at line 115 of file ThreadSafeRegistry.h.

115  {
116  for (auto const& item: c) {
117  insertMapped(item);
118  }
119  }
bool insertMapped(value_type const &v)
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().

template<typename KEY, typename T>
template ThreadSafeRegistry< HLTConfigDataRegistry::key_type, HLTConfigDataRegistry::value_type > * edm::detail::ThreadSafeRegistry< KEY, T >::instance ( )
static
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 132 of file ThreadSafeRegistry.h.

References relativeConstraints::empty.

132  {
133  return !empty();
134  }
bool empty() const
Return true if there are no contained value_type objects.
template<typename KEY, typename T>
ThreadSafeRegistry<KEY,T>& edm::detail::ThreadSafeRegistry< KEY, T >::operator= ( ThreadSafeRegistry< KEY, T > const &  )
private
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 146 of file ThreadSafeRegistry.h.

References findQualityFiles::size.

146  {
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';
151  }
152  }
size_type size() const
Return the number of contained value_type objects.
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 139 of file ThreadSafeRegistry.h.

139  {
140  std::lock_guard<std::mutex> guard(mutex_);
141  return data_.size();
142  }

Member Data Documentation

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

Definition at line 94 of file ThreadSafeRegistry.h.

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

Definition at line 93 of file ThreadSafeRegistry.h.