ATLAS Offline Software
DVLInfo.cxx
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-2017 CERN for the benefit of the ATLAS collaboration
5 */
6 
7 // $Id: DVLInfo.cxx 470529 2011-11-24 23:54:22Z ssnyder $
20 #ifndef XAOD_STANDALONE
22 #endif
23 #include <typeinfo>
24 #include <string>
25 #include <memory>
26 #include <unordered_map>
27 
28 
30 using AthContainers_detail::lock_guard;
31 
32 
33 namespace DataModel_detail {
34 
35 
39 typedef std::unordered_map<const std::type_info*, DVLInfoBase*>
41 dvl_tinfo_map_t* s_dvl_tinfo_map ATLAS_THREAD_SAFE = 0;
43 
44 struct dvlmapdel {
45  ~dvlmapdel() { delete s_dvl_tinfo_map; }
47 
48 
49 
50 
59 DVLInfoBase::DVLInfoBase (const std::type_info& tinfo,
60  const std::type_info& elt_tinfo)
61  : m_tinfo (tinfo),
62  m_elt_tinfo (elt_tinfo)
63 {
64  lock_guard<mutex> lock (s_dvl_tinfo_mutex);
65  if (s_dvl_tinfo_map == 0)
66  s_dvl_tinfo_map = new dvl_tinfo_map_t;
67  (*s_dvl_tinfo_map)[&tinfo] = this;
68 }
69 
70 
76 DVLInfoBase* DVLInfoBase::find (const std::type_info& tinfo)
77 {
78  lock_guard<mutex> lock (s_dvl_tinfo_mutex);
79  if (!s_dvl_tinfo_map)
80  return 0;
81  dvl_tinfo_map_t::iterator i = s_dvl_tinfo_map->find (&tinfo);
82  if (i != s_dvl_tinfo_map->end())
83  return i->second;
84  return 0;
85 }
86 
87 
88 #ifdef XAOD_STANDALONE
90 {
91  return 0;
92 }
93 
94 CLID DVLInfoBase::clid() const
95 {
96  return CLID_NULL;
97 }
98 #else
99 
106 {
107  const std::type_info* ti = CLIDRegistry::CLIDToTypeinfo (clid);
108  if (ti)
109  return DVLInfoBase::find (*ti);
110  return 0;
111 }
112 
113 
118 {
120 }
121 #endif
122 
123 
124 } // namespace DataModel_detail
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
DataModel_detail::s_dvlmapdel
struct DataModel_detail::dvlmapdel s_dvlmapdel
DataModel_detail::DVLInfoBase::tinfo
const std::type_info & tinfo() const
Return the type_info for the container.
CLIDRegistry::typeinfoToCLID
static CLID typeinfoToCLID(const std::type_info &ti)
Return the CLID corresponding to a type_info.
Definition: CLIDRegistry.cxx:148
DataModel_detail::DVLInfoBase::DVLInfoBase
DVLInfoBase(const std::type_info &tinfo, const std::type_info &elt_tinfo)
Constructor.
Definition: DVLInfo.cxx:59
BeamSpot::mutex
std::mutex mutex
Definition: InDetBeamSpotVertex.cxx:18
CLIDRegistry::CLIDToTypeinfo
static const std::type_info * CLIDToTypeinfo(CLID clid)
Translate between CLID and type_info.
Definition: CLIDRegistry.cxx:136
DVLInfo.h
Holder to implement conversion copies for DataVector/DataList.
DataModel_detail::dvlmapdel::~dvlmapdel
~dvlmapdel()
Definition: DVLInfo.cxx:45
DataModel_detail::DVLInfoBase::clid
CLID clid() const
Return the CLID for the container.
Definition: DVLInfo.cxx:117
DataModel_detail::DVLInfoBase
Definition: DVLInfo.h:68
DataModel_detail::DVLInfoBase::m_tinfo
const std::type_info & m_tinfo
The type_info of the container.
Definition: DVLInfo.h:182
DataModel_detail::dvl_tinfo_map_t
std::unordered_map< const std::type_info *, DVLInfoBase * > dvl_tinfo_map_t
Maps from tinfo pointers and CLID to DVLInfo instances.
Definition: DVLInfo.cxx:40
lumiFormat.i
int i
Definition: lumiFormat.py:85
DataModel_detail::s_dvl_tinfo_mutex
mutex s_dvl_tinfo_mutex
Definition: DVLInfo.cxx:42
DataModel_detail::DVLInfoBase::find
static DVLInfoBase * find(const std::type_info &tinfo)
Find the DVLInfo for the container tinfo.
Definition: DVLInfo.cxx:76
CLID
uint32_t CLID
The Class ID type.
Definition: Event/xAOD/xAODCore/xAODCore/ClassID_traits.h:47
DataModel_detail
Definition: CompareAndPrint.h:15
threading.h
Threading definitions.
DataModel_detail::dvlmapdel
Definition: DVLInfo.cxx:44
CLIDRegistry.h
a static registry of CLID->typeName entries. NOT for general use. Use ClassIDSvc instead.
DataModel_detail::ATLAS_THREAD_SAFE
dvl_tinfo_map_t *s_dvl_tinfo_map ATLAS_THREAD_SAFE
Definition: DVLInfo.cxx:41