ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Control
xAODRootAccess
xAODRootAccess
tools
TDestructorRegistry.icc
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_TOOLS_TDESTRUCTORREGISTRY_ICC
6
#define XAODROOTACCESS_TOOLS_TDESTRUCTORREGISTRY_ICC
7
8
// System include(s):
9
#include <typeinfo>
10
#include <mutex>
11
12
// Local include(s):
13
#include "xAODRootAccess/tools/TDestructor.h"
14
15
namespace xAOD {
16
17
/// This function is used by the code to teach the registry about new
18
/// types that we want to be able to delete from a type agnostic piece
19
/// of code later on.
20
///
21
template< class T >
22
void TDestructorRegistry::add() {
23
24
// Get the type's ID:
25
const std::type_info& ti = typeid( T );
26
27
// Check if we already have a destructor for it:
28
{
29
// Get a "read lock":
30
std::shared_lock< std::shared_timed_mutex > lock( m_mutex );
31
if( m_types.find( &ti ) != m_types.end() ) {
32
// Yep, there's nothing to do...
33
return;
34
}
35
}
36
37
// Get a "write lock":
38
std::unique_lock< std::shared_timed_mutex > lock( m_mutex );
39
40
// Create a new destructor object.
41
m_types[ &ti ] = std::make_unique< TDestructor< T > >();
42
43
return;
44
}
45
46
} // namespace xAOD
47
48
#endif // XAODROOTACCESS_TOOLS_TDESTRUCTORREGISTRY_ICC
Generated on
for ATLAS Offline Software by
1.17.0