ATLAS Offline Software
TypeMaps.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef TRIGNAVIGATION_TYPEMAPS_H
6 #define TRIGNAVIGATION_TYPEMAPS_H
7 
8 #include <map>
9 #include <string>
10 #include <memory>
11 
12 #include "GaudiKernel/ClassID.h"
13 
15 
16 #include "TrigNavigation/Holder.h"
18 
19 namespace HLT {
23  class TypeMaps {
24  public:
25  typedef std::map<CLID, std::unique_ptr<const HLTNavDetails::ITypeProxy>> CLIDtoTypeProxyMap;
26  typedef std::map<CLID, std::unique_ptr<const HLTNavDetails::IHolder>> CLIDtoHolderMap;
27  typedef std::map<std::string, CLID> NametoCLIDMap;
28 
29  static const CLIDtoTypeProxyMap& proxies() { return m_proxies; }
30  static const CLIDtoHolderMap& holders() { return m_holders; }
31  static const NametoCLIDMap& type2clid() { return m_type2clid; }
32 
33  // The registration methods are invoked at compile-time and we use
34  // a const_cast to fill the otherwise read-only type maps.
35  template<class T>
36  static constexpr void registerType ATLAS_NOT_THREAD_SAFE () {
37  auto& nc_proxies = const_cast<CLIDtoTypeProxyMap&>(m_proxies);
38  auto& nc_types = const_cast<NametoCLIDMap&>(m_type2clid);
39  nc_proxies[ClassID_traits<T>::ID()] = std::make_unique<HLTNavDetails::TypeProxy<T>>();
41  }
42 
43  template<class T, class C>
44  static constexpr void registerFeatureContainer ATLAS_NOT_THREAD_SAFE () {
45  auto& nc_holders = const_cast<CLIDtoHolderMap&>(m_holders);
46  nc_holders[ClassID_traits<T>::ID()] = std::make_unique<HLTNavDetails::HolderImp<T, C>>();
47  HLT::TypeMaps::registerType<T>();
48  HLT::TypeMaps::registerType<C>();
49  }
50 
51  private:
52  // statically filled by the above registration methods, otherwise const:
53  inline static const CLIDtoTypeProxyMap m_proxies;
54  inline static const CLIDtoHolderMap m_holders;
55  inline static const NametoCLIDMap m_type2clid;
56  };
57 }
58 
59 #endif
HLT::TypeMaps::m_proxies
static const CLIDtoTypeProxyMap m_proxies
Definition: TypeMaps.h:53
HLT::TypeMaps::holders
static const CLIDtoHolderMap & holders()
Definition: TypeMaps.h:30
HLT::TypeMaps::CLIDtoHolderMap
std::map< CLID, std::unique_ptr< const HLTNavDetails::IHolder > > CLIDtoHolderMap
Definition: TypeMaps.h:26
HLT::TypeMaps::m_holders
static const CLIDtoHolderMap m_holders
Definition: TypeMaps.h:54
HLT::TypeMaps::NametoCLIDMap
std::map< std::string, CLID > NametoCLIDMap
Definition: TypeMaps.h:27
ClassID_traits::ID
static const CLID & ID()
the CLID of T
Definition: Control/AthenaKernel/AthenaKernel/ClassID_traits.h:50
ClassID_traits::typeName
static const std::string & typeName()
the demangled type name of T
Definition: Control/AthenaKernel/AthenaKernel/ClassID_traits.h:56
HLT::TypeMaps::ATLAS_NOT_THREAD_SAFE
static constexpr void registerFeatureContainer ATLAS_NOT_THREAD_SAFE()
Definition: TypeMaps.h:44
HLT
It used to be useful piece of code for replacing actual SG with other store of similar functionality ...
Definition: HLTResultReader.h:26
HLT::TypeMaps::CLIDtoTypeProxyMap
std::map< CLID, std::unique_ptr< const HLTNavDetails::ITypeProxy > > CLIDtoTypeProxyMap
Definition: TypeMaps.h:25
Holder.h
HLT::TypeMaps
Type registration of holder, proxies and name/CLID mappings.
Definition: TypeMaps.h:23
HLT::TypeMaps::ATLAS_NOT_THREAD_SAFE
static constexpr void registerType ATLAS_NOT_THREAD_SAFE()
Definition: TypeMaps.h:36
HLT::TypeMaps::type2clid
static const NametoCLIDMap & type2clid()
Definition: TypeMaps.h:31
HLT::TypeMaps::proxies
static const CLIDtoTypeProxyMap & proxies()
Definition: TypeMaps.h:29
checker_macros.h
Define macros for attributes used to control the static checker.
TypeProxy.h
HLT::TypeMaps::m_type2clid
static const NametoCLIDMap m_type2clid
Definition: TypeMaps.h:55