ATLAS Offline Software
Loading...
Searching...
No Matches
xAOD::TDestructorRegistry Class Reference

Application-wide registry of destructor objects. More...

#include <TDestructorRegistry.h>

Collaboration diagram for xAOD::TDestructorRegistry:

Public Member Functions

const TVirtualDestructorget (const std::type_info &ti) const
 Get the destructor for a given type.
template<class T>
void add ()
 Add a new destructor object.

Static Public Member Functions

static TDestructorRegistryinstance ()
 Function accessing the singleton instance of this type.

Private Types

typedef std::map< const std::type_info *, std::unique_ptr< TVirtualDestructor > > Map_t
 Type of the internal map.

Private Member Functions

 TDestructorRegistry ()
 Hide the constructor of the type.
 TDestructorRegistry (const TDestructorRegistry &)=delete
 Hide the copy-constructor.

Private Attributes

Map_t m_types
 Internal map of known destructor objects.
std::shared_timed_mutex m_mutex
 Mutex for the destructor map.

Detailed Description

Application-wide registry of destructor objects.

This registry is used to keep track of how to destruct objects that are kept in the transient store, and don't have a ROOT dictionary available for them.

Author
Attila Krasznahorkay Attil.nosp@m.a.Kr.nosp@m.aszna.nosp@m.hork.nosp@m.ay@ce.nosp@m.rn.c.nosp@m.h

Definition at line 31 of file TDestructorRegistry.h.

Member Typedef Documentation

◆ Map_t

typedef std::map< const std::type_info*, std::unique_ptr< TVirtualDestructor > > xAOD::TDestructorRegistry::Map_t
private

Type of the internal map.

Definition at line 51 of file TDestructorRegistry.h.

Constructor & Destructor Documentation

◆ TDestructorRegistry() [1/2]

xAOD::TDestructorRegistry::TDestructorRegistry ( )
private

Hide the constructor of the type.

Definition at line 41 of file TDestructorRegistry.cxx.

42 : m_types(), m_mutex() {
43
44 }
Map_t m_types
Internal map of known destructor objects.
std::shared_timed_mutex m_mutex
Mutex for the destructor map.

◆ TDestructorRegistry() [2/2]

xAOD::TDestructorRegistry::TDestructorRegistry ( const TDestructorRegistry & )
privatedelete

Hide the copy-constructor.

Member Function Documentation

◆ add()

template<class T>
void xAOD::TDestructorRegistry::add ( )

Add a new destructor object.

◆ get()

const TVirtualDestructor * xAOD::TDestructorRegistry::get ( const std::type_info & ti) const

Get the destructor for a given type.

Definition at line 23 of file TDestructorRegistry.cxx.

23 {
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 }
#define XAOD_MESSAGE(MESSAGE)
Simple macro for printing error/verbose messages.
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...

◆ instance()

TDestructorRegistry & xAOD::TDestructorRegistry::instance ( )
static

Function accessing the singleton instance of this type.

Definition at line 16 of file TDestructorRegistry.cxx.

16 {
17
18 static TDestructorRegistry obj ATLAS_THREAD_SAFE; // this class is thread-safe
19 return obj;
20 }
#define ATLAS_THREAD_SAFE
TDestructorRegistry()
Hide the constructor of the type.

Member Data Documentation

◆ m_mutex

std::shared_timed_mutex xAOD::TDestructorRegistry::m_mutex
mutableprivate

Mutex for the destructor map.

This type is used because the registry is filled mostly at the very beginning of a job, and is just read from there on. For the reading the clients don't need exclusive locks on the store.

Definition at line 60 of file TDestructorRegistry.h.

◆ m_types

Map_t xAOD::TDestructorRegistry::m_types
private

Internal map of known destructor objects.

Definition at line 53 of file TDestructorRegistry.h.


The documentation for this class was generated from the following files: