ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Trigger
TrigSteer
ViewAlgs
ViewAlgs
IDCCacheCreatorBase.h
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#ifndef ViewAlgs_IDCCacheCreatorBase_h
6
#define ViewAlgs_IDCCacheCreatorBase_h
7
8
#include "
AthenaBaseComps/AthReentrantAlgorithm.h
"
9
#include <atomic>
10
#include "
EventContainers/IdentifiableValueCache.h
"
11
#include "
EventContainers/IdentifiableCache.h
"
12
13
class
IDCCacheCreatorBase
:
public
AthReentrantAlgorithm
{
14
public
:
16
IDCCacheCreatorBase
(
const
std::string &name,ISvcLocator *pSvcLocator);
18
virtual
~IDCCacheCreatorBase
()=
default
;
19
protected
:
20
template
<
bool
checkKey = true,
typename
T>
21
StatusCode
createContainer
(
const
SG::WriteHandleKey<T>
& ,
long
unsigned
int
,
const
EventContext& )
const
;
22
template
<
bool
checkKey = true,
typename
T,
typename
X>
23
StatusCode
createValueContainer
(
const
SG::WriteHandleKey<T>
& ,
long
unsigned
int
,
const
EventContext&,
const
X& defaultValue )
const
;
24
mutable
std::atomic_flag m_disableWarningCheck
ATLAS_THREAD_SAFE
= ATOMIC_FLAG_INIT;
25
bool
isInsideView
(
const
EventContext&)
const
;
26
StatusCode
checkInsideViewOnce
(
const
EventContext&)
const
;
27
};
28
29
30
template
<
bool
checkKey,
typename
T>
31
StatusCode
IDCCacheCreatorBase::createContainer
(
const
SG::WriteHandleKey<T>
& containerKey,
long
unsigned
int
size
,
const
EventContext& ctx)
const
{
32
static_assert
(std::is_base_of<EventContainers::IdentifiableCacheBase, T>::value,
"Expects a IdentifiableCache Class"
);
33
if
constexpr
(checkKey){
34
if
(containerKey.
key
().empty()){
35
ATH_MSG_DEBUG
(
"Creation of container "
<< containerKey.
key
() <<
" is disabled (no name specified)"
);
36
return
StatusCode::SUCCESS;
37
}
38
}
39
SG::WriteHandle<T>
ContainerCacheKey(containerKey, ctx);
40
ATH_CHECK
( ContainerCacheKey.
recordNonConst
( std::make_unique<T>(
IdentifierHash
(
size
),
nullptr
) ));
41
ATH_MSG_DEBUG
(
"Container "
<< containerKey.
key
() <<
" created to hold "
<<
size
);
42
return
StatusCode::SUCCESS;
43
}
44
45
template
<
bool
checkKey,
typename
T,
typename
X>
46
StatusCode
IDCCacheCreatorBase::createValueContainer
(
const
SG::WriteHandleKey<T>
& containerKey,
long
unsigned
int
size
,
const
EventContext& ctx,
const
X& defaultValue)
const
{
47
static_assert
(std::is_base_of<IdentifiableValueCache<X>, T>::value,
"Expects a IdentifiableValueCache Class"
);
48
if
constexpr
(checkKey){
49
if
(containerKey.
key
().empty()){
50
ATH_MSG_DEBUG
(
"Creation of container "
<< containerKey.
key
() <<
" is disabled (no name specified)"
);
51
return
StatusCode::SUCCESS;
52
}
53
}
54
SG::WriteHandle<T>
ContainerCacheKey(containerKey, ctx);
55
ATH_CHECK
( ContainerCacheKey.
recordNonConst
( std::make_unique<T>(
size
, defaultValue) ));
56
ATH_MSG_DEBUG
(
"ValueContainer "
<< containerKey.
key
() <<
" created to hold "
<<
size
);
57
return
StatusCode::SUCCESS;
58
}
59
60
#endif
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition
AthMsgStreamMacros.h:29
AthReentrantAlgorithm.h
IdentifiableCache.h
IdentifiableValueCache.h
size
size_t size() const
Number of registered mappings.
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition
AthReentrantAlgorithm.h:74
IDCCacheCreatorBase::createValueContainer
StatusCode createValueContainer(const SG::WriteHandleKey< T > &, long unsigned int, const EventContext &, const X &defaultValue) const
Definition
IDCCacheCreatorBase.h:46
IDCCacheCreatorBase::ATLAS_THREAD_SAFE
std::atomic_flag m_disableWarningCheck ATLAS_THREAD_SAFE
Definition
IDCCacheCreatorBase.h:24
IDCCacheCreatorBase::IDCCacheCreatorBase
IDCCacheCreatorBase(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
Definition
IDCCacheCreatorBase.cxx:15
IDCCacheCreatorBase::checkInsideViewOnce
StatusCode checkInsideViewOnce(const EventContext &) const
Definition
IDCCacheCreatorBase.cxx:21
IDCCacheCreatorBase::isInsideView
bool isInsideView(const EventContext &) const
Definition
IDCCacheCreatorBase.cxx:8
IDCCacheCreatorBase::~IDCCacheCreatorBase
virtual ~IDCCacheCreatorBase()=default
Destructor.
IDCCacheCreatorBase::createContainer
StatusCode createContainer(const SG::WriteHandleKey< T > &, long unsigned int, const EventContext &) const
Definition
IDCCacheCreatorBase.h:31
IdentifierHash
This is a "hash" representation of an Identifier.
Definition
IdentifierHash.h:25
SG::VarHandleKey::key
const std::string & key() const
Return the StoreGate ID for the referenced object.
Definition
AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:141
SG::WriteHandleKey
Property holding a SG store/key/clid from which a WriteHandle is made.
Definition
StoreGate/StoreGate/WriteHandleKey.h:40
SG::WriteHandle
Definition
StoreGate/StoreGate/WriteHandle.h:73
SG::WriteHandle::recordNonConst
StatusCode recordNonConst(std::unique_ptr< T > data)
Record a non-const object to the store.
Generated on
for ATLAS Offline Software by
1.17.0