ATLAS Offline Software
Public Types | Public Member Functions | Private Types | Private Attributes | List of all members
MetaCont< T > Class Template Reference

#include <MetaCont.h>

Inheritance diagram for MetaCont< T >:
Collaboration diagram for MetaCont< T >:

Public Types

typedef T Payload_t
 
typedef SG::SourceID SourceID
 

Public Member Functions

 MetaCont ()
 
 ~MetaCont ()
 
virtual bool insert (const SourceID &sid, void *obj) override final
 
virtual size_t erase (const SourceID &sid) override final
 
virtual int entries () const override
 
virtual bool valid (const SourceID &sid) const override final
 
virtual std::vector< SourceIDsources () const override final
 
virtual void list (std::ostringstream &stream) const override final
 
bool insert (const SourceID &sid, T *t)
 
bool find (const SourceID &sid, T *&t) const
 various Get methods More...
 
T * get (const SourceID &sid) const
 
void * getAsVoid (const SourceID &sid) const override final
 

Private Types

typedef std::map< SourceID, T * > MetaContSet
 

Private Attributes

std::mutex m_mut
 
MetaContSet m_metaSet
 

Detailed Description

template<typename T>
class MetaCont< T >

Definition at line 48 of file MetaCont.h.

Member Typedef Documentation

◆ MetaContSet

template<typename T >
typedef std::map<SourceID,T*> MetaCont< T >::MetaContSet
private

Definition at line 81 of file MetaCont.h.

◆ Payload_t

template<typename T >
typedef T MetaCont< T >::Payload_t

Definition at line 50 of file MetaCont.h.

◆ SourceID

Definition at line 26 of file MetaCont.h.

Constructor & Destructor Documentation

◆ MetaCont()

template<typename T >
MetaCont< T >::MetaCont ( )
inline

Definition at line 53 of file MetaCont.h.

53 {};

◆ ~MetaCont()

template<typename T >
MetaCont< T >::~MetaCont

Definition at line 107 of file MetaCont.h.

107  {
108  for (auto t : m_metaSet) {
109  delete t.second;
110  }
111  m_metaSet.clear();
112 }

Member Function Documentation

◆ entries()

template<typename T >
int MetaCont< T >::entries
overridevirtual

Reimplemented from MetaContBase.

Definition at line 192 of file MetaCont.h.

192  {
193  std::lock_guard<std::mutex> lock(m_mut);
194  return m_metaSet.size();
195 }

◆ erase()

template<typename T >
size_t MetaCont< T >::erase ( const SourceID sid)
finaloverridevirtual

Implements MetaContBase.

Definition at line 125 of file MetaCont.h.

125  {
126  std::lock_guard<std::mutex> lock(m_mut);
127  return m_metaSet.erase(sid);
128 }

◆ find()

template<typename T >
bool MetaCont< T >::find ( const SourceID sid,
T *&  t 
) const

various Get methods

Definition at line 149 of file MetaCont.h.

149  {
150  std::lock_guard<std::mutex> lock(m_mut);
151 
152  typename MetaContSet::const_iterator itr = m_metaSet.find(sid);
153  if (itr != m_metaSet.end()) {
154  t=itr->second;
155  return true;
156  }
157 
158  return false;
159 }

◆ get()

template<typename T >
T * MetaCont< T >::get ( const SourceID sid) const

Definition at line 165 of file MetaCont.h.

165  {
166  std::lock_guard<std::mutex> lock(m_mut);
167 
168  typename MetaContSet::const_iterator itr = m_metaSet.find(sid);
169  if (itr != m_metaSet.end()) {
170  return itr->second;
171  }
172 
173  return nullptr;
174 }

◆ getAsVoid()

template<typename T >
void* MetaCont< T >::getAsVoid ( const SourceID sid) const
inlinefinaloverridevirtual

Implements MetaContBase.

Definition at line 75 of file MetaCont.h.

75 { return get(sid); }

◆ insert() [1/2]

template<typename T >
bool MetaCont< T >::insert ( const SourceID sid,
T *  t 
)

Definition at line 133 of file MetaCont.h.

133  {
134  std::lock_guard<std::mutex> lock(m_mut);
135  return m_metaSet.insert(std::make_pair(sid,t)).second;
136 }

◆ insert() [2/2]

template<typename T >
bool MetaCont< T >::insert ( const SourceID sid,
void *  obj 
)
finaloverridevirtual

Implements MetaContBase.

Definition at line 117 of file MetaCont.h.

117  {
118  T* t = static_cast<T*>(obj);
119  return insert(sid, t);
120 }

◆ list()

template<typename T >
void MetaCont< T >::list ( std::ostringstream &  stream) const
finaloverridevirtual

Implements MetaContBase.

Definition at line 180 of file MetaCont.h.

180  {
181  std::lock_guard<std::mutex> lock(m_mut);
182  // To Do: perhaps extend this output?
183  stream << "MetaCont with size : [" << m_metaSet.size() << "]" << std::endl;
184  for(const auto& mapel : m_metaSet) {
185  stream << "... Key : " << mapel.first << std::endl;
186  }
187 }

◆ sources()

template<typename T >
std::vector< MetaContBase::SourceID > MetaCont< T >::sources
finaloverridevirtual

Implements MetaContBase.

Definition at line 201 of file MetaCont.h.

201  {
202  std::lock_guard<std::mutex> lock(m_mut);
203 
204  std::vector<MetaContBase::SourceID> r;
205  for (auto ent : m_metaSet) {
206  r.push_back(ent.first);
207  }
208 
209  return r;
210 }

◆ valid()

template<typename T >
bool MetaCont< T >::valid ( const SourceID sid) const
finaloverridevirtual

Implements MetaContBase.

Definition at line 141 of file MetaCont.h.

141  {
142  std::lock_guard<std::mutex> lock(m_mut);
143  return m_metaSet.find(sid)!=m_metaSet.end();
144 }

Member Data Documentation

◆ m_metaSet

template<typename T >
MetaContSet MetaCont< T >::m_metaSet
private

Definition at line 82 of file MetaCont.h.

◆ m_mut

template<typename T >
std::mutex MetaCont< T >::m_mut
mutableprivate

Definition at line 79 of file MetaCont.h.


The documentation for this class was generated from the following file:
beamspotman.r
def r
Definition: beamspotman.py:676
MetaCont::get
T * get(const SourceID &sid) const
Definition: MetaCont.h:165
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
AthenaPoolTestWrite.stream
string stream
Definition: AthenaPoolTestWrite.py:12
MetaCont::insert
virtual bool insert(const SourceID &sid, void *obj) override final
Definition: MetaCont.h:117
MetaCont::m_metaSet
MetaContSet m_metaSet
Definition: MetaCont.h:82
MetaCont::m_mut
std::mutex m_mut
Definition: MetaCont.h:79
python.PyAthena.obj
obj
Definition: PyAthena.py:132
TSU::T
unsigned long long T
Definition: L1TopoDataTypes.h:35