ATLAS Offline Software
Loading...
Searching...
No Matches
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
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}
MetaContSet m_metaSet
Definition MetaCont.h:82

Member Function Documentation

◆ entries()

template<typename T>
int MetaCont< T >::entries ( ) const
overridevirtual

Reimplemented from MetaContBase.

Definition at line 192 of file MetaCont.h.

192 {
194 return m_metaSet.size();
195}
std::mutex m_mut
Definition MetaCont.h:79

◆ erase()

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

Implements MetaContBase.

Definition at line 125 of file MetaCont.h.

125 {
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 {
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 {
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); }
T * get(const SourceID &sid) const
Definition MetaCont.h:165

◆ insert() [1/2]

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

Definition at line 133 of file MetaCont.h.

133 {
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}
virtual bool insert(const SourceID &sid, void *obj) override final
Definition MetaCont.h:117

◆ list()

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

Implements MetaContBase.

Definition at line 180 of file MetaCont.h.

180 {
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 ( ) const
finaloverridevirtual

Implements MetaContBase.

Definition at line 201 of file MetaCont.h.

201 {
203
205 for (const 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 {
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: