ATLAS Offline Software
TDestructorRegistry.cxx
Go to the documentation of this file.
1 // Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
2 
3 // ROOT include(s):
4 #include <TError.h>
5 
6 // Framework include(s):
9 
10 // Local include(s):
13 
14 namespace xAOD {
15 
17 
18  static TDestructorRegistry obj ATLAS_THREAD_SAFE; // this class is thread-safe
19  return obj;
20  }
21 
22  const TVirtualDestructor*
23  TDestructorRegistry::get( const std::type_info& ti ) const {
24 
25  // Get a "read lock":
26  std::shared_lock< std::shared_timed_mutex > lock( m_mutex );
27 
28  // Look for this type:
29  Map_t::const_iterator itr = m_types.find( &ti );
30  if( itr != m_types.end() ) {
31  return itr->second.get();
32  }
33 
34  // We didn't find it:
35  ::Error( "xAOD::TDestructorRegistry::get",
36  XAOD_MESSAGE( "Destructor not known for type %s" ),
37  SG::normalizedTypeinfoName( ti ).c_str() );
38  return nullptr;
39  }
40 
42  : m_types(), m_mutex() {
43 
44  }
45 
46 } // namespace xAOD
SG::normalizedTypeinfoName
std::string normalizedTypeinfoName(const std::type_info &info)
Convert a type_info to a normalized string representation (matching the names used in the root dictio...
Definition: normalizedTypeinfoName.cxx:120
xAOD::TDestructorRegistry::TDestructorRegistry
TDestructorRegistry()
Hide the constructor of the type.
Definition: TDestructorRegistry.cxx:41
xAOD::TDestructorRegistry::m_types
Map_t m_types
Internal map of known destructor objects.
Definition: TDestructorRegistry.h:53
xAOD
ICaloAffectedTool is abstract interface for tools checking if 4 mom is in calo affected region.
Definition: ICaloAffectedTool.h:24
XAOD_MESSAGE
#define XAOD_MESSAGE(MESSAGE)
Simple macro for printing error/verbose messages.
Definition: Control/xAODRootAccess/xAODRootAccess/tools/Message.h:19
TDestructorRegistry.h
xAOD::TVirtualDestructor
Base class for the templated destructor types.
Definition: TDestructor.h:25
Message.h
xAOD::TDestructorRegistry
Application-wide registry of destructor objects.
Definition: TDestructorRegistry.h:31
xAOD::TDestructorRegistry::instance
static TDestructorRegistry & instance()
Function accessing the singleton instance of this type.
Definition: TDestructorRegistry.cxx:16
normalizedTypeinfoName.h
Convert a type_info to a normalized string representation (matching the names used in the root dictio...
xAOD::TDestructorRegistry::m_mutex
std::shared_timed_mutex m_mutex
Mutex for the destructor map.
Definition: TDestructorRegistry.h:60
ATLAS_THREAD_SAFE
#define ATLAS_THREAD_SAFE
Definition: checker_macros.h:211
checker_macros.h
Define macros for attributes used to control the static checker.
python.PyAthena.obj
obj
Definition: PyAthena.py:132
xAOD::TDestructorRegistry::get
const TVirtualDestructor * get(const std::type_info &ti) const
Get the destructor for a given type.
Definition: TDestructorRegistry.cxx:23