5#ifndef EVENTCONTAINERS_IDENTIFIABLECONTAINERMT_H
6#define EVENTCONTAINERS_IDENTIFIABLECONTAINERMT_H
19#include "Identifier/Identifier.h"
22#include "GaudiKernel/DataObject.h"
58 IDC_WriteHandleBase::ReleaseLock();
108 return std::bit_cast<const T*>(
m_itr->second );
112 return std::bit_cast<const T*>(
m_itr->second );
119 return m_itr!= it.m_itr;
124 return m_itr == it.m_itr;
142 friend class IDC_WriteHandle;
163 return m_link->indexFind(hashId);
204 return m_link->fullSize();
209 return m_link->fullSize();
216 return IdentifiableContainerBase::numberOfCollections();
220 static_assert(
sizeof(
const T*) ==
sizeof(
const void*) && std::is_pointer<const T*>::value);
222 const auto& void_vec =
m_link->getAllHashPtrPair();
223 return void_vec | std::views::transform([](
const auto& item) {
227 static_cast<const T*
>(item.second)
237 return IdentifiableContainerBase::GetAllCurrentHashes();
242 return const_iterator(
m_link->cbegin());
247 const_iterator
end()
const {
248 return const_iterator(
m_link->cend());
258 IDC_WriteHandle
lock;
259 lock.m_hashId = hash;
260 lock.m_IDC_ptr =
this;
269 return std::bit_cast<T*>(
m_link->removeCollection(hashId));
299 return std::bit_cast<const T* > (IdentifiableContainerBase::indexFindPtr(hashId));
308 if (! IdentifiableContainerBase::insert(hashId, coll)) [[
unlikely]]
return StatusCode::FAILURE;
309 return StatusCode::SUCCESS;
326 return IdentifiableContainerBase::fetchOrCreate(hashId);
333 return IdentifiableContainerBase::fetchOrCreate(hashIds);
341 return IdentifiableContainerBase::tryAddFromCache(hashId);
348 if (m_OnlineMode) [[
unlikely]]
return StatusCode::FAILURE;
350 auto p = std::bit_cast<const T* > (m_link->findIndexPtr(hashId));
351 collToRetrieve =
const_cast<T*
>(p);
352 return StatusCode::SUCCESS;
360 if (hashId >=
m_link->fullSize()) [[
unlikely]]
return StatusCode::FAILURE;
361 auto ptr = uptr.release();
362 bool b = IdentifiableContainerBase::insert(hashId, ptr);
364 return StatusCode::SUCCESS;
371 if (hashId >=
m_link->fullSize()) [[
unlikely]]
return StatusCode::FAILURE;
372 auto ptr = uptr.release();
373 bool b = IdentifiableContainerBase::insert(hashId, ptr);
375 return StatusCode::SUCCESS;
382 return m_link->addLock(hashId, ptr.release());
389 if (hashId >=
m_link->fullSize()) [[
unlikely]]
return StatusCode::FAILURE;
390 auto ptr = uptr.release();
391 bool b = IdentifiableContainerBase::insert(hashId, ptr);
394 return StatusCode::SUCCESS;
virtual void lock()=0
Interface to allow an object to lock itself when made const in SG.
virtual StatusCode naughtyRetrieve(IdentifierHash hashId, CscCalibDataCollection *&collToRetrieve) const=0
std::vector< hashPair >::const_iterator InternalConstItr
std::unique_ptr< I_InternalIDC > m_link
IdentifiableContainerBase(EventContainers::IdentifiableCacheBase *cache)
static void Swap(IDC_WriteHandle &a, IDC_WriteHandle &b) noexcept
IDC_WriteHandle(IDC_WriteHandle &&other)
IDC_WriteHandle(const IDC_WriteHandle &other)=delete
bool OnlineAndPresentInAnotherView()
This method is to avoid calling an expensive operation in the offline case.
IDC_WriteHandle & operator=(IDC_WriteHandle &&other) noexcept=delete
IDC_WriteHandle & operator=(const IDC_WriteHandle &other)=delete
StatusCode addOrDelete(std::unique_ptr< T > ptr)
IdentifiableContainerMT< T > * m_IDC_ptr
const T * operator*() const
EventContainers::I_InternalIDC::InternalConstItr m_itr
const_iterator(const_iterator &&)=default
bool operator==(const const_iterator &it) const
comparison operator
~const_iterator()=default
const_iterator(const const_iterator &)=default
const_iterator & operator++()
increment operator
const_iterator()
iterator constructor
const_iterator & operator=(const const_iterator &)=default
bool operator!=(const const_iterator &it) const
comparison operator
const T * operator->() const
IdentifierHash hashId() const
hashId of the pointed-to element
const_iterator(EventContainers::I_InternalIDC::InternalConstItr itr)
const_iterator end() const
return const_iterator for end of container
IDC_WriteHandle getWriteHandle(IdentifierHash hash)
StatusCode fetchOrCreate(const std::vector< IdentifierHash > &hashId)
T * removeCollection(IdentifierHash hashId)
remove collection from container for id hash, returning it (and ownership) to client
std::vector< std::atomic< constvoid * > >::size_type size_type
virtual bool hasExternalCache() const override final
virtual void cleanup() override final
reset m_hashids and call IdentifiableCache's cleanup
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
virtual std::vector< IdentifierHash > GetAllCurrentHashes() const override final
Returns a collection of all hashes availiable in this IDC.
virtual StatusCode naughtyRetrieve ATLAS_NOT_THREAD_SAFE(IdentifierHash hashId, T *&collToRetrieve) const override final
StatusCode addLock(std::unique_ptr< T > ptr, IdentifierHash hashId)
Like the other add methods but optimized for changing from the inprogress state.
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 ha...
virtual size_t fullSize() const override final
virtual size_t numberOfCollections() const override final
return number of collections
IdentifiableContainerMT(IdentifierHash hashMax)
constructor initializes the collection the hashmax, OFFLINE usages pattern
bool empty() const
return true if container is empty
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 incorpo...
EventContainers::IdentifiableCache< T > ICACHE
const_iterator indexFind(IdentifierHash hashId) const
~IdentifiableContainerMT()
IdentifiableContainerMT(ICACHE *cache)
constructor initializes with a link to a cache, ONLINE usage pattern
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 convenien...
auto GetAllHashPtrPair() const
T *const & const_reference
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,...
size_t size() const
Duplicate of fullSize for backwards compatability.
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,...
IdentifiableContainerMT(IdentifierHash hashMax, EventContainers::Mode)
const_iterator begin() const
return const_iterator for first entry
IdentifiableContainerMT< T > MyType
This is a "hash" representation of an Identifier.
::StatusCode StatusCode
StatusCode definition for legacy code.
void swap(ElementLinkVector< DOBJ > &lhs, ElementLinkVector< DOBJ > &rhs)
static void deleter(const void *p)