ATLAS Offline Software
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 $
16 #ifndef EVENTCONTAINERS_IDENTIFIABLECACHE_H
17 #define EVENTCONTAINERS_IDENTIFIABLECACHE_H
18 
19 
21 
22 
23 namespace EventContainers {
24 
25 
26 template <class T>
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:
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 
54  {
56  }
57 
58  // Return payload if there, null if not there.
60  {
61  return reinterpret_cast<const T*> (IdentifiableCacheBase::find (hash));
62  }
63 
65  {
66  return reinterpret_cast<const T*> (IdentifiableCacheBase::findWait (hash));
67  }
68 
69  const T* get (IdentifierHash hash)
70  {
71  return reinterpret_cast<const T*> (IdentifiableCacheBase::get (hash));
72  }
73 
74  std::pair<bool, const void*> add (IdentifierHash hash, const T* p)
75  {
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(){
86  }
87 };
88 
89 
90 } // namespace EventContainers
91 
92 
93 #endif // not EVENTCONTAINERS_IDENTIFIABLECACHE_H
IdentifiableCacheBase.h
EventContainers::IdentifiableCacheBase::findWait
const void * findWait(IdentifierHash hash)
Retrieve ptr, will wait if there is something in progress.
Definition: IdentifiableCacheBase.cxx:123
EventContainers::IdentifiableCacheBase
Definition: IdentifiableCacheBase.h:26
EventContainers::IdentifiableCacheBase::get
const void * get(IdentifierHash hash)
Try to make payload if not there.
Definition: IdentifiableCacheBase.cxx:136
EventContainers::IdentifiableCache::add
std::pair< bool, const void * > add(IdentifierHash hash, const T *p)
Definition: IdentifiableCache.h:74
EventContainers::IdentifiableCache::findWait
const T * findWait(IdentifierHash hash)
Definition: IdentifiableCache.h:64
EventContainers::IdentifiableCache::Maker::make
virtual std::unique_ptr< T > make(IdentifierHash hash) const =0
EventContainers::IdentifiableCache::~IdentifiableCache
~IdentifiableCache()
Definition: IdentifiableCache.h:53
EventContainers
Definition: T_AthenaPoolCreateFuncs.h:33
EventContainers::IdentifiableCache::get
const T * get(IdentifierHash hash)
Definition: IdentifiableCache.h:69
EventContainers::IdentifiableCache::IdentifiableCache
IdentifiableCache(IdentifierHash maxHash, const Maker *maker)
Definition: IdentifiableCache.h:43
void_unique_ptr::Deleter
Definition: deleter.h:22
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
EventContainers::IdentifiableCache::clearCache
void clearCache()
Definition: IdentifiableCache.h:84
EventContainers::IdentifiableCache::find
const T * find(IdentifierHash hash)
Definition: IdentifiableCache.h:59
EventContainers::IdentifiableCache::add
std::pair< bool, const void * > add(IdentifierHash hash, std::unique_ptr< T > p)
Definition: IdentifiableCache.h:79
EventContainers::IdentifiableCache::Maker
Definition: IdentifiableCache.h:35
EventContainers::IdentifiableCache::Maker::typelessMake
virtual void_unique_ptr typelessMake(IdentifierHash hash) const
Definition: IdentifiableCache.h:39
EventContainers::IdentifiableCacheBase::clear
void clear(deleter_f *deleter)
Definition: IdentifiableCacheBase.cxx:59
EventContainers::IdentifiableCache::IdentifiableCache
IdentifiableCache(IdentifierHash maxHash, const Maker *maker, size_t lockBucketSize)
Definition: IdentifiableCache.h:48
void_unique_ptr
Definition: deleter.h:16
CaloCondBlobAlgs_fillNoiseFromASCII.hash
dictionary hash
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:109
EventContainers::IdentifiableCacheBase::find
const void * find(IdentifierHash hash) noexcept
Return payload if there, null if not there.
Definition: IdentifiableCacheBase.cxx:102
EventContainers::IdentifiableCacheBase::add
std::pair< bool, const void * > add(IdentifierHash hash, const void *p) noexcept
Definition: IdentifiableCacheBase.cxx:204
EventContainers::IdentifiableCacheBase::IMaker
Definition: IdentifiableCacheBase.h:39
IdentifierHash
This is a "hash" representation of an Identifier. This encodes a 32 bit index which can be used to lo...
Definition: IdentifierHash.h:25
EventContainers::IdentifiableCache
Definition: IdentifiableCache.h:29
EventContainers::IdentifiableCacheBase::cleanUp
void cleanUp(deleter_f *deleter)
Definition: IdentifiableCacheBase.cxx:78