ATLAS Offline Software
PhysicsAnalysis/D3PDMaker/D3PDMakerUtils/D3PDMakerUtils/Types.h
Go to the documentation of this file.
1 // This file's extension implies that it's C, but it's really -*- C++ -*-.
2 /*
3  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
4 */
23 #ifndef D3PDMAKERUTILS_TYPES_H
24 #define D3PDMAKERUTILS_TYPES_H
25 
26 
27 #include <typeinfo>
28 #include <cstdlib>
29 #include <tuple>
30 
31 
32 namespace D3PD {
33 
34 
38 class NoType {};
39 
40 
42 template <class T>
43 struct WrapType
44 {
45  using type = T;
46 };
47 
48 
60 template <class... TYPES>
61 using Types = std::tuple<WrapType<TYPES>...>;
62 
63 
70 template <class T, int N>
71 struct SelectType
72 {
73  typedef T type;
74 };
75 
76 
78 template <int N, class... TYPES>
79 struct SelectType<Types<TYPES...>, N>
80 {
81  using type = typename std::tuple_element_t<N, Types<TYPES...> >::type;
82 };
83 
84 
91 template <class T0>
92 const std::type_info& multiTypeInfo (Types<T0>*, size_t which)
93 {
94  if (which == 0) return typeid (T0);
95  std::abort();
96 }
97 
98 
99 template <class T0, class... TYPES>
100 const std::type_info& multiTypeInfo (Types<T0, TYPES...>*, size_t which)
101 {
102  if (which == 0) return typeid (T0);
103  return multiTypeInfo (static_cast<Types<TYPES...>*>(nullptr), which-1);
104 }
105 
106 
107 template <class T>
108 const std::type_info& multiTypeInfo (T*, size_t /*which*/)
109 {
110  return typeid (T);
111 }
112 
113 
114 template <class T>
116 {
117  using type = T;
118 };
119 
120 
121 template <class T0, class... TYPES>
122 struct ButFirstType<Types<T0, TYPES...> >
123 {
124  using type = Types<TYPES...>;
125 };
126 
127 
128 template <class T>
130 
131 
132 } // namespace D3PD
133 
134 
135 
136 #endif // not D3PDMAKERUTILS_TYPES_H
D3PD::SelectType< Types< TYPES... >, N >::type
typename std::tuple_element_t< N, Types< TYPES... > >::type type
Definition: PhysicsAnalysis/D3PDMaker/D3PDMakerUtils/D3PDMakerUtils/Types.h:81
D3PD::SelectType
Select one type out of the tuple.
Definition: PhysicsAnalysis/D3PDMaker/D3PDMakerUtils/D3PDMakerUtils/Types.h:72
D3PD::multiTypeInfo
const std::type_info & multiTypeInfo(Types< T0 > *, size_t which)
Return one type_info from a tuple.
Definition: PhysicsAnalysis/D3PDMaker/D3PDMakerUtils/D3PDMakerUtils/Types.h:92
JetTiledMap::N
@ N
Definition: TiledEtaPhiMap.h:44
D3PD::Types
std::tuple< WrapType< TYPES >... > Types
A simple tuple of multiple types.
Definition: PhysicsAnalysis/D3PDMaker/D3PDMakerUtils/D3PDMakerUtils/Types.h:61
D3PD
Block filler tool for noisy FEB information.
Definition: InnerDetector/InDetMonitoring/InDetGlobalMonitoring/macros/EnhancedPrimaryVertexMonitoring/TrigD3PD/ChainGroup.h:21
D3PD::ButFirstType
Definition: PhysicsAnalysis/D3PDMaker/D3PDMakerUtils/D3PDMakerUtils/Types.h:116
python.Utils.unixtools.which
def which(filename, env=os.environ)
UNIX-style which ---------------------------------------------------------—.
Definition: unixtools.py:39
D3PD::ButFirstType< Types< T0, TYPES... > >::type
Types< TYPES... > type
Definition: PhysicsAnalysis/D3PDMaker/D3PDMakerUtils/D3PDMakerUtils/Types.h:124
D3PD::ButFirstType::type
T type
Definition: PhysicsAnalysis/D3PDMaker/D3PDMakerUtils/D3PDMakerUtils/Types.h:117
D3PD::ButFirstType_t
typename ButFirstType< T >::type ButFirstType_t
Definition: PhysicsAnalysis/D3PDMaker/D3PDMakerUtils/D3PDMakerUtils/Types.h:129
D3PD::WrapType
Helper so that Types<> will be an empty class.
Definition: PhysicsAnalysis/D3PDMaker/D3PDMakerUtils/D3PDMakerUtils/Types.h:44
D3PD::SelectType::type
T type
Definition: PhysicsAnalysis/D3PDMaker/D3PDMakerUtils/D3PDMakerUtils/Types.h:73
D3PD::WrapType::type
T type
Definition: PhysicsAnalysis/D3PDMaker/D3PDMakerUtils/D3PDMakerUtils/Types.h:45
D3PD::NoType
Placeholder for empty type.
Definition: PhysicsAnalysis/D3PDMaker/D3PDMakerUtils/D3PDMakerUtils/Types.h:38