ATLAS Offline Software
THolderCache.h
Go to the documentation of this file.
1 // Dear emacs, this is -*- c++ -*-
2 //
3 // Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
4 //
5 #ifndef XAODROOTACCESS_THOLDERCACHE_H
6 #define XAODROOTACCESS_THOLDERCACHE_H
7 
8 // System include(s):
9 #include <map>
10 #include <shared_mutex>
11 #include <utility>
12 
13 // Forward declaration(s):
14 namespace std {
15  class type_info;
16 }
17 class TClass;
18 
19 namespace xAOD {
20 
21  namespace Internal {
22 
31  class THolderCache {
32 
33  public:
35  static THolderCache& instance();
36 
38  std::pair< bool, ::TClass* >
39  getClass( const std::type_info& ti ) const;
41  void addClass( const std::type_info& ti, ::TClass* cl );
42 
44  int getRef( void* ptr ) const;
46  int incRef( void* ptr );
48  int decRef( void* ptr );
49 
50  private:
52  THolderCache();
54  THolderCache( const THolderCache& ) = delete;
55 
57  std::map< const std::type_info*, TClass* > m_typeMap;
59  std::map< void*, int > m_refMap;
60 
62  mutable std::shared_timed_mutex m_typeMapMutex;
64  mutable std::shared_timed_mutex m_refMapMutex;
65 
66  }; // class THolderCache
67 
68  } // namespace Internal
69 
70 } // namespace xAOD
71 
72 #endif // XAODROOTACCESS_THOLDERCACHE_H
xAOD::Internal::THolderCache::getRef
int getRef(void *ptr) const
Get the reference count of an object in memory.
Definition: THolderCache.cxx:58
xAOD::Internal::THolderCache::m_refMap
std::map< void *, int > m_refMap
The reference count map.
Definition: THolderCache.h:59
xAOD
ICaloAffectedTool is abstract interface for tools checking if 4 mom is in calo affected region.
Definition: ICaloAffectedTool.h:24
xAOD::Internal::THolderCache::addClass
void addClass(const std::type_info &ti, ::TClass *cl)
Add the dictionary for a given type.
Definition: THolderCache.cxx:49
dbg::ptr
void * ptr(T *p)
Definition: SGImplSvc.cxx:74
xAOD::Internal::THolderCache::getClass
std::pair< bool, ::TClass * > getClass(const std::type_info &ti) const
Get the dictionary for a given type info.
Definition: THolderCache.cxx:35
xAOD::Internal::THolderCache
Singleton, thread-safe THolder cache.
Definition: THolderCache.h:31
xAOD::Internal::THolderCache::m_typeMap
std::map< const std::type_info *, TClass * > m_typeMap
The type map.
Definition: THolderCache.h:57
xAOD::Internal::THolderCache::THolderCache
THolderCache(const THolderCache &)=delete
Delete the copy constructor.
xAOD::Internal::THolderCache::m_typeMapMutex
std::shared_timed_mutex m_typeMapMutex
Mutex for the type map.
Definition: THolderCache.h:62
xAOD::Internal::THolderCache::instance
static THolderCache & instance()
Singleton accessor.
Definition: THolderCache.cxx:29
xAOD::Internal::THolderCache::incRef
int incRef(void *ptr)
Increment the reference count of an object in memory.
Definition: THolderCache.cxx:72
xAOD::Internal::THolderCache::THolderCache
THolderCache()
Hide the constructor of the class from the outside.
Definition: THolderCache.cxx:105
xAOD::Internal::THolderCache::decRef
int decRef(void *ptr)
Decrease the reference count of an object in memory.
Definition: THolderCache.cxx:81
dq_make_web_display.cl
cl
print [x.__class__ for x in toList(dqregion.getSubRegions()) ]
Definition: dq_make_web_display.py:26
xAOD::Internal::THolderCache::m_refMapMutex
std::shared_timed_mutex m_refMapMutex
Mutex for the reference count map.
Definition: THolderCache.h:64