ATLAS Offline Software
Classes | Public Types | Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | Friends | List of all members
IdentifiableContainerMT< T > Class Template Referenceabstract

#include <IdentifiableContainerMT.h>

Inherits DataObject, EventContainers::IdentifiableContainerBase, and EventContainers::IIdentifiableCont< T >.

Inherited by CscCalibDataContainer, CscDigitContainer, CscRawDataContainer, HGTD_RDO_Container, InDetRawDataContainer< CollectionT >, MdtCsmContainer, MdtDigitContainer, MmDigitContainer, Muon::MM_RawDataContainer, Muon::MuonCoinDataContainer< CollectionT >, Muon::MuonPrepDataContainer< CollectionT >, Muon::NSW_MMTP_RawDataContainer, Muon::NSW_PadTriggerDataContainer, Muon::STGC_RawDataContainer, Muon::MuonPrepDataContainer< CscPrepData >, Muon::MuonPrepDataContainer< MdtPrepData >, Muon::MuonPrepDataContainer< MMPrepData >, Muon::MuonPrepDataContainer< RpcPrepData >, Muon::MuonPrepDataContainer< sTgcPrepData >, Muon::MuonPrepDataContainer< TgcPrepData >, RpcDigitContainer, RpcPadContainer, SpacePointContainer, sTgcDigitContainer, TgcDigitContainer, TgcL1RdoContainer, TgcRdoContainer, TileRawDataContainer< TCOLLECTION >, TileRawDataContainer< TileBeamElemCollection >, TileRawDataContainer< TileCellCollection >, TileRawDataContainer< TileDigitsCollection >, TileRawDataContainer< TileHitCollection >, TileRawDataContainer< TileRawChannelCollection >, and Trk::PrepRawDataContainer< CollectionT >.

Collaboration diagram for IdentifiableContainerMT< T >:

Classes

class  const_iterator
 
class  IDC_WriteHandle
 

Public Types

typedef T IDENTIFIABLE
 
typedef EventContainers::IdentifiableCache< T > ICACHE
 
typedef IdentifiableContainerMT< T > MyType
 
typedef std::vector< std::atomic< const void * > >::size_type size_type
 
typedef T *& reference
 
typedef T *constconst_reference
 
typedef T * value_type
 
typedef T ** pointer
 
typedef T *constconst_pointer
 
typedef T base_value_type
 
typedef std::vector< IdentifierHashHash_Container
 

Public Member Functions

 IdentifiableContainerMT (IdentifierHash hashMax)
 constructor initializes the collection the hashmax, OFFLINE usages pattern More...
 
 IdentifiableContainerMT (IdentifierHash hashMax, EventContainers::Mode)
 
 IdentifiableContainerMT (ICACHE *cache)
 constructor initializes with a link to a cache, ONLINE usage pattern More...
 
 ~IdentifiableContainerMT ()
 
virtual bool hasExternalCache () const override final
 
virtual const T * indexFindPtr (IdentifierHash hashId) const override final
 return pointer on the found entry or null if out of range using hashed index - fast version, does not call cnv if object not there More...
 
const_iterator indexFind (IdentifierHash hashId) const
 
virtual StatusCode addCollection (const T *coll, IdentifierHash hashId) override final
 insert collection into container with id hash if IDC should not take ownership of collection, set ownsColl to false More...
 
virtual StatusCode addOrDelete (std::unique_ptr< T >, IdentifierHash hashId) override final
 Tries to add the item to the cache, if the item already exists then it is deleted This is a convenience method for online multithreaded scenarios. More...
 
virtual StatusCode addOrDelete (std::unique_ptr< const T >, IdentifierHash hashId) override final
 
StatusCode addOrDelete (std::unique_ptr< T >, IdentifierHash hashId, bool &deleted)
 identical to previous excepts allows counting of deletions More...
 
StatusCode addLock (std::unique_ptr< T > ptr, IdentifierHash hashId)
 Like the other add methods but optimized for changing from the inprogress state. More...
 
virtual bool tryAddFromCache (IdentifierHash hashId) override final
 Looks in the cache to see if item already exists if not it returns false, If it does exist it incorporates it into the IDC view but changing the mask. More...
 
StatusCode fetchOrCreate (IdentifierHash hashId)
 Tries will look for item in cache, if it doesn't exist will call the cache IMAKER If cache doesn't have an IMAKER then this fails. More...
 
StatusCode fetchOrCreate (const std::vector< IdentifierHash > &hashId)
 
virtual StatusCode naughtyRetrieve ATLAS_NOT_THREAD_SAFE (IdentifierHash hashId, T *&collToRetrieve) const override final
 
T * removeCollection (IdentifierHash hashId)
 remove collection from container for id hash, returning it (and ownership) to client More...
 
virtual void cleanup () override final
 reset m_hashids and call IdentifiableCache's cleanup More...
 
virtual size_t fullSize () const override final
 return full size of container More...
 
size_t size () const
 Duplicate of fullSize for backwards compatability. More...
 
void prepareItr () const
 
virtual size_t numberOfCollections () const override final
 return number of collections More...
 
const std::vector< EventContainers::hashPair< T > > & GetAllHashPtrPair () const
 
virtual std::vector< IdentifierHashGetAllCurrentHashes () const override final
 Returns a collection of all hashes availiable in this IDC. More...
 
const_iterator begin () const
 return const_iterator for first entry More...
 
const_iterator end () const
 return const_iterator for end of container More...
 
bool empty () const
 return true if container is empty More...
 
IDC_WriteHandle getWriteHandle (IdentifierHash hash)
 
virtual StatusCode naughtyRetrieve (IdentifierHash hashId, T *&collToRetrieve) const =0
 

Protected Types

typedef EventContainers::IdentifiableCacheBase IdentifiableCacheBase
 

Protected Member Functions

bool insert (IdentifierHash hashId, const void *ptr)
 
void Wait () const
 
bool tryAddFromCache (IdentifierHash hashId, EventContainers::IDC_WriteHandleBase &lock)
 
void cleanup (deleter_f *deleter)
 
void ResetMask ()
 

Protected Attributes

bool m_OnlineMode
 
std::unique_ptr< I_InternalIDC > m_link
 

Friends

class IDC_WriteHandle
 

Detailed Description

template<class T>
class IdentifiableContainerMT< T >

Definition at line 29 of file IdentifiableContainerMT.h.

Member Typedef Documentation

◆ base_value_type

template<class T >
typedef T IdentifiableContainerMT< T >::base_value_type

Definition at line 78 of file IdentifiableContainerMT.h.

◆ const_pointer

template<class T >
typedef T* const* IdentifiableContainerMT< T >::const_pointer

Definition at line 77 of file IdentifiableContainerMT.h.

◆ const_reference

template<class T >
typedef T* const& IdentifiableContainerMT< T >::const_reference

Definition at line 74 of file IdentifiableContainerMT.h.

◆ Hash_Container

Definition at line 18 of file IdentifiableContainerBase.h.

◆ ICACHE

Definition at line 70 of file IdentifiableContainerMT.h.

◆ IDENTIFIABLE

template<class T >
typedef T IdentifiableContainerMT< T >::IDENTIFIABLE

Definition at line 69 of file IdentifiableContainerMT.h.

◆ IdentifiableCacheBase

Definition at line 25 of file IdentifiableContainerBase.h.

◆ MyType

template<class T >
typedef IdentifiableContainerMT<T> IdentifiableContainerMT< T >::MyType

Definition at line 71 of file IdentifiableContainerMT.h.

◆ pointer

template<class T >
typedef T** IdentifiableContainerMT< T >::pointer

Definition at line 76 of file IdentifiableContainerMT.h.

◆ reference

template<class T >
typedef T*& IdentifiableContainerMT< T >::reference

Definition at line 73 of file IdentifiableContainerMT.h.

◆ size_type

template<class T >
typedef std::vector<std::atomic<const void*> >::size_type IdentifiableContainerMT< T >::size_type

Definition at line 72 of file IdentifiableContainerMT.h.

◆ value_type

template<class T >
typedef T* IdentifiableContainerMT< T >::value_type

Definition at line 75 of file IdentifiableContainerMT.h.

Constructor & Destructor Documentation

◆ IdentifiableContainerMT() [1/3]

template<class T >
IdentifiableContainerMT< T >::IdentifiableContainerMT ( IdentifierHash  hashMax)

constructor initializes the collection the hashmax, OFFLINE usages pattern

Definition at line 271 of file IdentifiableContainerMT.h.

271  : IdentifiableContainerBase(maxHash)
272 {
273 }

◆ IdentifiableContainerMT() [2/3]

template<class T >
IdentifiableContainerMT< T >::IdentifiableContainerMT ( IdentifierHash  hashMax,
EventContainers::Mode  mode 
)

Definition at line 276 of file IdentifiableContainerMT.h.

276  :
278 {
279 }

◆ IdentifiableContainerMT() [3/3]

template<class T >
IdentifiableContainerMT< T >::IdentifiableContainerMT ( ICACHE cache)

constructor initializes with a link to a cache, ONLINE usage pattern

Definition at line 283 of file IdentifiableContainerMT.h.

284 {
285 }

◆ ~IdentifiableContainerMT()

template<class T >
IdentifiableContainerMT< T >::~IdentifiableContainerMT ( )
inline

Definition at line 153 of file IdentifiableContainerMT.h.

Member Function Documentation

◆ addCollection()

template<class T >
StatusCode IdentifiableContainerMT< T >::addCollection ( const T *  coll,
IdentifierHash  hashId 
)
finaloverridevirtual

insert collection into container with id hash if IDC should not take ownership of collection, set ownsColl to false

Implements EventContainers::IIdentifiableCont< T >.

Definition at line 300 of file IdentifiableContainerMT.h.

301 {
302  // update m_hashids
303  if (ATH_UNLIKELY(! IdentifiableContainerBase::insert(hashId, coll))) return StatusCode::FAILURE;
304  return StatusCode::SUCCESS;
305 
306 }

◆ addLock()

template<class T >
StatusCode IdentifiableContainerMT< T >::addLock ( std::unique_ptr< T >  ptr,
IdentifierHash  hashId 
)

Like the other add methods but optimized for changing from the inprogress state.

Definition at line 375 of file IdentifiableContainerMT.h.

376 {
377  return m_link->addLock(hashId, ptr.release());
378 }

◆ addOrDelete() [1/3]

template<class T >
virtual StatusCode IdentifiableContainerMT< T >::addOrDelete ( std::unique_ptr< const T >  ,
IdentifierHash  hashId 
)
finaloverridevirtual

◆ addOrDelete() [2/3]

template<class T >
StatusCode IdentifiableContainerMT< T >::addOrDelete ( std::unique_ptr< T >  uptr,
IdentifierHash  hashId 
)
finaloverridevirtual

Tries to add the item to the cache, if the item already exists then it is deleted This is a convenience method for online multithreaded scenarios.

Implements EventContainers::IIdentifiableCont< T >.

Definition at line 353 of file IdentifiableContainerMT.h.

354 {
355  if(ATH_UNLIKELY(hashId >= m_link->fullSize())) return StatusCode::FAILURE;
356  auto ptr = uptr.release();
357  bool b = IdentifiableContainerBase::insert(hashId, ptr);
358  if(!b) delete ptr;
359  return StatusCode::SUCCESS;
360 }

◆ addOrDelete() [3/3]

template<class T >
StatusCode IdentifiableContainerMT< T >::addOrDelete ( std::unique_ptr< T >  uptr,
IdentifierHash  hashId,
bool &  deleted 
)

identical to previous excepts allows counting of deletions

Definition at line 382 of file IdentifiableContainerMT.h.

383 {
384  if(ATH_UNLIKELY(hashId >= m_link->fullSize())) return StatusCode::FAILURE;
385  auto ptr = uptr.release();
386  bool b = IdentifiableContainerBase::insert(hashId, ptr);
387  if(!b) delete ptr;
388  deleted = !b;
389  return StatusCode::SUCCESS;
390 }

◆ ATLAS_NOT_THREAD_SAFE()

template<class T >
virtual StatusCode naughtyRetrieve IdentifiableContainerMT< T >::ATLAS_NOT_THREAD_SAFE ( IdentifierHash  hashId,
T *&  collToRetrieve 
) const
finaloverridevirtual

◆ begin()

template<class T >
const_iterator IdentifiableContainerMT< T >::begin ( ) const
inline

return const_iterator for first entry

Definition at line 236 of file IdentifiableContainerMT.h.

236  {
237  return const_iterator(m_link->cbegin());
238  }

◆ cleanup() [1/2]

template<class T >
void IdentifiableContainerMT< T >::cleanup
finaloverridevirtual

reset m_hashids and call IdentifiableCache's cleanup

Implements EventContainers::IIdentifiableCont< T >.

Definition at line 312 of file IdentifiableContainerMT.h.

313 {
314  IdentifiableContainerBase::cleanup(void_unique_ptr::Deleter<T>::deleter);
315 }

◆ cleanup() [2/2]

void IdentifiableContainerBase::cleanup ( deleter_f deleter)
protectedinherited

Definition at line 38 of file IdentifiableContainerBase.cxx.

38  {
39  if(m_OnlineMode) throw std::runtime_error("Not implemented in online mode");
40  m_link->cleanUp(deleter);
41  }

◆ empty()

template<class T >
bool IdentifiableContainerMT< T >::empty ( ) const
inline

return true if container is empty

Definition at line 247 of file IdentifiableContainerMT.h.

247  {
248  return numberOfCollections()==0;
249  }

◆ end()

template<class T >
const_iterator IdentifiableContainerMT< T >::end ( ) const
inline

return const_iterator for end of container

Definition at line 242 of file IdentifiableContainerMT.h.

242  {
243  return const_iterator(m_link->cend());
244  }

◆ fetchOrCreate() [1/2]

template<class T >
StatusCode IdentifiableContainerMT< T >::fetchOrCreate ( const std::vector< IdentifierHash > &  hashId)

Definition at line 326 of file IdentifiableContainerMT.h.

327 {
328  return IdentifiableContainerBase::fetchOrCreate(hashIds);
329 }

◆ fetchOrCreate() [2/2]

template<class T >
StatusCode IdentifiableContainerMT< T >::fetchOrCreate ( IdentifierHash  hashId)

Tries will look for item in cache, if it doesn't exist will call the cache IMAKER If cache doesn't have an IMAKER then this fails.

Definition at line 319 of file IdentifiableContainerMT.h.

320 {
321  return IdentifiableContainerBase::fetchOrCreate(hashId);
322 }

◆ fullSize()

template<class T >
virtual size_t IdentifiableContainerMT< T >::fullSize ( ) const
inlinefinaloverridevirtual

return full size of container

Implements EventContainers::IIdentifiableCont< T >.

Definition at line 204 of file IdentifiableContainerMT.h.

204  {
205  return m_link->fullSize();
206  }

◆ GetAllCurrentHashes()

template<class T >
virtual std::vector<IdentifierHash> IdentifiableContainerMT< T >::GetAllCurrentHashes ( ) const
inlinefinaloverridevirtual

Returns a collection of all hashes availiable in this IDC.

If this is an "offline" mode IDC then this is identical to the cache If this is an "online" mode IDC then this is the items that both exist in the cache and have a postive mask element

Implements EventContainers::IIdentifiableCont< T >.

Definition at line 231 of file IdentifiableContainerMT.h.

231  {
232  return IdentifiableContainerBase::GetAllCurrentHashes();
233  }

◆ GetAllHashPtrPair()

template<class T >
const std::vector< EventContainers::hashPair<T> >& IdentifiableContainerMT< T >::GetAllHashPtrPair ( ) const
inline

Definition at line 220 of file IdentifiableContainerMT.h.

220  {
221  static_assert(sizeof(const T*) == sizeof(const void*) && std::is_pointer<const T*>::value);
222  static_assert(sizeof(EventContainers::hashPair<T>) == sizeof(EventContainers::hashPair<void>));
223  return reinterpret_cast<const std::vector < EventContainers::hashPair<T> >&>
224  (m_link->getAllHashPtrPair());
225  }

◆ getWriteHandle()

template<class T >
IDC_WriteHandle IdentifiableContainerMT< T >::getWriteHandle ( IdentifierHash  hash)
inline

Definition at line 251 of file IdentifiableContainerMT.h.

252  {
253  IDC_WriteHandle lock;
254  lock.m_hashId = hash;
255  lock.m_IDC_ptr = this;
256  return lock;
257  }

◆ hasExternalCache()

template<class T >
virtual bool IdentifiableContainerMT< T >::hasExternalCache ( ) const
inlinefinaloverridevirtual

Implements EventContainers::IIdentifiableCont< T >.

Definition at line 155 of file IdentifiableContainerMT.h.

155 { return m_OnlineMode; }

◆ indexFind()

template<class T >
const_iterator IdentifiableContainerMT< T >::indexFind ( IdentifierHash  hashId) const
inline

Definition at line 163 of file IdentifiableContainerMT.h.

163  {
164  return m_link->indexFind(hashId);
165  }

◆ indexFindPtr()

template<class T >
const T * IdentifiableContainerMT< T >::indexFindPtr ( IdentifierHash  hashId) const
finaloverridevirtual

return pointer on the found entry or null if out of range using hashed index - fast version, does not call cnv if object not there

return valuetype on the found entry or null if out of range using hashed index - fast version, does not call cnv if object not there

Implements EventContainers::IIdentifiableCont< T >.

Definition at line 292 of file IdentifiableContainerMT.h.

293 {
294  return reinterpret_cast<const T* > (IdentifiableContainerBase::indexFindPtr(hashId));
295 }

◆ insert()

bool EventContainers::IdentifiableContainerBase::insert ( IdentifierHash  hashId,
const void *  ptr 
)
inlineprotectedinherited

Definition at line 28 of file IdentifiableContainerBase.h.

28 { return m_link->insert(hashId, ptr); }

◆ naughtyRetrieve()

template<class T >
virtual StatusCode EventContainers::IIdentifiableCont< T >::naughtyRetrieve ( IdentifierHash  hashId,
T *&  collToRetrieve 
) const
pure virtualinherited

◆ numberOfCollections()

template<class T >
virtual size_t IdentifiableContainerMT< T >::numberOfCollections ( ) const
inlinefinaloverridevirtual

return number of collections

Implements EventContainers::IIdentifiableCont< T >.

Definition at line 216 of file IdentifiableContainerMT.h.

216  {
217  return IdentifiableContainerBase::numberOfCollections();
218  }

◆ prepareItr()

template<class T >
void IdentifiableContainerMT< T >::prepareItr ( ) const
inline

Definition at line 213 of file IdentifiableContainerMT.h.

213 { m_link->wait(); }

◆ removeCollection()

template<class T >
T * IdentifiableContainerMT< T >::removeCollection ( IdentifierHash  hashId)

remove collection from container for id hash, returning it (and ownership) to client

Definition at line 262 of file IdentifiableContainerMT.h.

263 {
264  return reinterpret_cast<T*>(m_link->removeCollection(hashId));
265 }

◆ ResetMask()

void EventContainers::IdentifiableContainerBase::ResetMask ( )
protectedinherited

◆ size()

template<class T >
size_t IdentifiableContainerMT< T >::size ( ) const
inline

Duplicate of fullSize for backwards compatability.

Definition at line 209 of file IdentifiableContainerMT.h.

209  {
210  return m_link->fullSize();
211  }

◆ tryAddFromCache() [1/2]

template<class T >
bool IdentifiableContainerMT< T >::tryAddFromCache ( IdentifierHash  hashId)
finaloverridevirtual

Looks in the cache to see if item already exists if not it returns false, If it does exist it incorporates it into the IDC view but changing the mask.

Implements EventContainers::IIdentifiableCont< T >.

Definition at line 334 of file IdentifiableContainerMT.h.

335 {
336  return IdentifiableContainerBase::tryAddFromCache(hashId);
337 }

◆ tryAddFromCache() [2/2]

bool EventContainers::IdentifiableContainerBase::tryAddFromCache ( IdentifierHash  hashId,
EventContainers::IDC_WriteHandleBase lock 
)
inlineprotectedinherited

Definition at line 30 of file IdentifiableContainerBase.h.

30  {
31  return m_link->tryAddFromCache(hashId, lock); }

◆ Wait()

void EventContainers::IdentifiableContainerBase::Wait ( ) const
inlineprotectedinherited

Definition at line 29 of file IdentifiableContainerBase.h.

29 { m_link->wait(); }

Friends And Related Function Documentation

◆ IDC_WriteHandle

template<class T >
friend class IDC_WriteHandle
friend

Definition at line 143 of file IdentifiableContainerMT.h.

Member Data Documentation

◆ m_link

std::unique_ptr<I_InternalIDC> EventContainers::IdentifiableContainerBase::m_link
protectedinherited

Definition at line 26 of file IdentifiableContainerBase.h.

◆ m_OnlineMode

bool EventContainers::IdentifiableContainerBase::m_OnlineMode
protectedinherited

Definition at line 24 of file IdentifiableContainerBase.h.


The documentation for this class was generated from the following file:
IdentifiableContainerMT::IDC_WriteHandle
friend class IDC_WriteHandle
Definition: IdentifiableContainerMT.h:143
EventContainers::IdentifiableContainerBase::IdentifiableContainerBase
IdentifiableContainerBase(EventContainers::IdentifiableCacheBase *cache)
Definition: IdentifiableContainerBase.cxx:15
athena.value
value
Definition: athena.py:122
ATH_UNLIKELY
#define ATH_UNLIKELY(x)
Definition: AthUnlikelyMacros.h:17
EventContainers::hashPair
Definition: I_InternalIDC.h:25
void_unique_ptr::Deleter
Definition: deleter.h:22
EventContainers::IdentifiableContainerBase::m_link
std::unique_ptr< I_InternalIDC > m_link
Definition: IdentifiableContainerBase.h:26
IdentifiableContainerMT::numberOfCollections
virtual size_t numberOfCollections() const override final
return number of collections
Definition: IdentifiableContainerMT.h:216
Preparation.mode
mode
Definition: Preparation.py:96
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:77
CaloCondBlobAlgs_fillNoiseFromASCII.hash
dictionary hash
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:109
EventContainers::IdentifiableContainerBase::m_OnlineMode
bool m_OnlineMode
Definition: IdentifiableContainerBase.h:24
TSU::T
unsigned long long T
Definition: L1TopoDataTypes.h:35