ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Event
EventContainers
EventContainers
IdentifiableCache.h
Go to the documentation of this file.
1
// This file's extension implies that it's C, but it's really -*- C++ -*-.
2
3
/*
4
Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
5
*/
6
7
// $Id: IdentifiableCache.h 791541 2017-01-09 10:43:53Z smh $
14
15
16
#ifndef EVENTCONTAINERS_IDENTIFIABLECACHE_H
17
#define EVENTCONTAINERS_IDENTIFIABLECACHE_H
18
19
20
#include "
EventContainers/IdentifiableCacheBase.h
"
21
#include <bit>
22
23
namespace
EventContainers
{
24
25
26
template
<
class
T>
27
class
IdentifiableCache
28
:
public
IdentifiableCacheBase
29
{
30
public
:
31
32
33
class
Maker
34
:
public
IMaker
35
{
36
public
:
37
virtual
std::unique_ptr<T>
make
(
IdentifierHash
hash)
const
= 0;
38
private
:
39
virtual
void_unique_ptr
typelessMake
(
IdentifierHash
hash)
const
40
{
return
void_unique_ptr
(
make
(hash)); }
41
};
42
43
IdentifiableCache
(
IdentifierHash
maxHash,
const
Maker* maker)
44
:
IdentifiableCacheBase
(maxHash, maker)
45
{
46
}
47
48
IdentifiableCache
(
IdentifierHash
maxHash,
const
Maker* maker,
size_t
lockBucketSize)
49
:
IdentifiableCacheBase
(maxHash, maker, lockBucketSize)
50
{
51
}
52
53
~IdentifiableCache
()
54
{
55
IdentifiableCacheBase::cleanUp
(
void_unique_ptr::Deleter<T>::deleter
);
56
}
57
58
// Return payload if there, null if not there.
59
const
T*
find
(
IdentifierHash
hash)
60
{
61
return
std::bit_cast<const T*> (
IdentifiableCacheBase::find
(hash));
62
}
63
64
const
T*
findWait
(
IdentifierHash
hash)
65
{
66
return
std::bit_cast<const T*> (
IdentifiableCacheBase::findWait
(hash));
67
}
68
69
const
T*
get
(
IdentifierHash
hash)
70
{
71
return
std::bit_cast<const T*> (
IdentifiableCacheBase::get
(hash));
72
}
73
74
std::pair<bool, const void*>
add
(
IdentifierHash
hash,
const
T* p)
75
{
76
return
IdentifiableCacheBase::add
(hash, p);
77
}
78
79
std::pair<bool, const void*>
add
(
IdentifierHash
hash, std::unique_ptr<T> p)
80
{
81
return
IdentifiableCacheBase::add
(hash,
void_unique_ptr
(std::move(p)));
82
}
83
84
void
clearCache
(){
85
IdentifiableCacheBase::clear
(
void_unique_ptr::Deleter<T>::deleter
);
86
}
87
};
88
89
90
}
// namespace EventContainers
91
92
93
#endif
// not EVENTCONTAINERS_IDENTIFIABLECACHE_H
IdentifiableCacheBase.h
EventContainers::IdentifiableCacheBase::void_unique_ptr
Definition
IdentifiableCacheBase.h:18
EventContainers::IdentifiableCacheBase::get
const void * get(IdentifierHash hash)
Try to make payload if not there.
Definition
IdentifiableCacheBase.cxx:135
EventContainers::IdentifiableCacheBase::cleanUp
void cleanUp(deleter_f *deleter)
Definition
IdentifiableCacheBase.cxx:78
EventContainers::IdentifiableCacheBase::clear
void clear(deleter_f *deleter)
Definition
IdentifiableCacheBase.cxx:59
EventContainers::IdentifiableCacheBase::IdentifiableCacheBase
IdentifiableCacheBase(IdentifierHash maxHash, const IMaker *maker)
Definition
IdentifiableCacheBase.cxx:28
EventContainers::IdentifiableCacheBase::add
std::pair< bool, const void * > add(IdentifierHash hash, const void *p) noexcept
Definition
IdentifiableCacheBase.cxx:203
EventContainers::IdentifiableCacheBase::findWait
const void * findWait(IdentifierHash hash)
Retrieve ptr, will wait if there is something in progress.
Definition
IdentifiableCacheBase.cxx:122
EventContainers::IdentifiableCacheBase::find
const void * find(IdentifierHash hash) noexcept
Return payload if there, null if not there.
Definition
IdentifiableCacheBase.cxx:101
EventContainers::IdentifiableCache::Maker
Definition
IdentifiableCache.h:35
EventContainers::IdentifiableCache::Maker::make
virtual std::unique_ptr< T > make(IdentifierHash hash) const =0
EventContainers::IdentifiableCache::Maker::typelessMake
virtual void_unique_ptr typelessMake(IdentifierHash hash) const
Definition
IdentifiableCache.h:39
EventContainers::IdentifiableCache::add
std::pair< bool, const void * > add(IdentifierHash hash, std::unique_ptr< T > p)
Definition
IdentifiableCache.h:79
EventContainers::IdentifiableCache::add
std::pair< bool, const void * > add(IdentifierHash hash, const T *p)
Definition
IdentifiableCache.h:74
EventContainers::IdentifiableCache::IdentifiableCache
IdentifiableCache(IdentifierHash maxHash, const Maker *maker)
Definition
IdentifiableCache.h:43
EventContainers::IdentifiableCache::~IdentifiableCache
~IdentifiableCache()
Definition
IdentifiableCache.h:53
EventContainers::IdentifiableCache::IdentifiableCache
IdentifiableCache(IdentifierHash maxHash, const Maker *maker, size_t lockBucketSize)
Definition
IdentifiableCache.h:48
EventContainers::IdentifiableCache::clearCache
void clearCache()
Definition
IdentifiableCache.h:84
EventContainers::IdentifiableCache::findWait
const T * findWait(IdentifierHash hash)
Definition
IdentifiableCache.h:64
EventContainers::IdentifiableCache::get
const T * get(IdentifierHash hash)
Definition
IdentifiableCache.h:69
EventContainers::IdentifiableCache::find
const T * find(IdentifierHash hash)
Definition
IdentifiableCache.h:59
IdentifierHash
This is a "hash" representation of an Identifier.
Definition
IdentifierHash.h:25
EventContainers
Definition
T_AthenaPoolCreateFuncs.h:33
EventContainers::IdentifiableCacheBase::IMaker
Definition
IdentifiableCacheBase.h:36
void_unique_ptr::Deleter::deleter
static void deleter(const void *p)
Definition
deleter.h:24
Generated on
for ATLAS Offline Software by
1.17.0