ATLAS Offline Software
Loading...
Searching...
No Matches
NavigationInit.icc
Go to the documentation of this file.
1// dear emacs this is -*- c++ -*-
2
3/*
4 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
5*/
6
7
8#ifndef TrigNavigation_NavigationInit_icc
9#define TrigNavigation_NavigationInit_icc
10
11//#include "GaudiKernel/MsgStream.h"
12#include <type_traits>
13
14#include "AthContainers/ConstDataVector.h"
15#include "TrigNavigation/Holder.h"
16#include "TrigNavigation/Holder.icc"
17
18#include "TrigNavigation/Navigation.h"
19#include "TrigNavigation/Navigation.icc"
20
21#include "TrigNavigation/NavigationCore.h"
22#include "TrigNavigation/NavigationCore.icc"
23
24#include "TrigNavigation/TypeMaps.h"
25#include "TrigNavigation/TrigFeatureLink.h"
26
27namespace HLT {
28 class TriggerElement;
29}
30
31template<class T>
32struct FeatureLinkMethods {
33 typedef const T* (HLT::NavigationCore::*fl2o)( const TrigFeatureLink& ) const;
34 typedef TrigFeatureLink (HLT::NavigationCore::*o2fl_1)(const HLT::TriggerElement*, const std::string&, const T*) const;
35};
36
37template<class T>
38struct FeatureLinkMethods2 {
39 typedef typename Container2Object<T>::type Contained;
40 typedef TrigFeatureLink (HLT::NavigationCore::*o2fl_2)(const HLT::TriggerElement*, const std::string&, const Contained*, const T* ) const;
41};
42
43
44
45 /////////////////////////////////////////////////////
46template<class T, bool> struct acquire_featureLinkToObject;
47template<class T>
48struct acquire_featureLinkToObject<T, false> {
49 // typename FF<T>::type;
50 static typename FeatureLinkMethods<T>::fl2o do_it() {
51 return &HLT::NavigationCore::featureLink2Object<T>;}
52};
53
54template<class T> struct acquire_featureLinkToObject<T, true>{
55 static typename FeatureLinkMethods<T>::fl2o do_it() {
56 return 0;}
57};
58
59 /////////////////////////////////////////////////////
60template<class T, bool FeatureIsContainer> struct acquire_getRecentFeatureConstDV;
61template<class T>
62struct acquire_getRecentFeatureConstDV<T, true> {
63 typedef bool (HLT::NavigationCore::*type)( const HLT::TriggerElement*,
64 const ConstDataVector<T>*&, const std::string&,
65 const HLT::TriggerElement*&, std::string& ) const;
66 static type do_it() { return &HLT::NavigationCore::getRecentFeature<ConstDataVector<T>>; }
67};
68
69template<class T>
70struct acquire_getRecentFeatureConstDV<T, false> {
71 typedef void* type;
72 static type do_it() { return 0; }
73
74};
75 /////////////////////////////////////////////////////
76
77
78template<typename T>
79struct ConstDVCompatible{
80 typedef char yes[2];typedef char no[1];
81
82 // ATR-13318
83 // template<typename X, X>
84 // struct Help{
85 // };
86
87 template<typename C>
88 // static auto f(Help<decltype(&C::resize),&C::resize>*) -> yes&;
89 static yes& f(decltype(&C::resize));
90
91 template<typename C>
92 // static auto f(...) -> no&;
93 static no& f(...);
94
95 static const bool value = sizeof(f<T>(0)) == sizeof(yes);
96};
97
98
99
100 /////////////////////////////////////////////////////
101
102template<class T, bool FeatureIsContainer> struct acquire_attachFeatureConstDV;
103template<class T>
104struct acquire_attachFeatureConstDV<T, true> {
105 typedef bool (HLT::Navigation::*type)( HLT::TriggerElement*, const ConstDataVector<T>*,
106 HLT::Navigation::MemoryManagement, std::string&, const std::string& );
107
108 static type do_it() {
109 return &HLT::Navigation::attachFeature<T>;
110 }
111};
112
113template<class T>
114struct acquire_attachFeatureConstDV<T, false> {
115 typedef void* type;
116 static type do_it() { return 0; }
117
118};
119
120
121
122
123//template<class T>
124//struct O2FLMethod_1 {
125// typedef TrigFeatureLink (HLT::NavigationCore::*o2fl_1)(const HLT::TriggerElement*, const std::string&, const T*);
126//};
127
128template<class T, bool> struct acquire_object2FeatureLink1;
129template<class T> struct acquire_object2FeatureLink1<T, true> {
130 static typename FeatureLinkMethods<T>::o2fl_1 do_it() {
131 return &HLT::NavigationCore::object2FeatureLink<T>;
132 }
133};
134template<class T> struct acquire_object2FeatureLink1<T, false> {
135 static typename FeatureLinkMethods<T>::o2fl_1 do_it() {
136 return 0;
137 }
138};
139
140//
141template<class T, bool> struct acquire_object2FeatureLink2;
142template<class T> struct acquire_object2FeatureLink2<T, false> {
143 static typename FeatureLinkMethods2<T>::o2fl_2 do_it() {
144 return &HLT::NavigationCore::object2FeatureLink<T>;
145 }
146};
147template<class T> struct acquire_object2FeatureLink2<T, true> {
148 static typename FeatureLinkMethods2<T>::o2fl_2 do_it() {
149 return 0;
150 }
151};
152
153template<typename C, bool>
154struct instantiate_dataelementlink;
155
156template<typename C>
157struct instantiate_dataelementlink<C,true>{
158 static void do_it(){
159 [[maybe_unused]]
160 bool (HLT::NavigationCore::*temp)(const HLT::TriggerElement*,DataLink<C>& link,
161 const std::string&, const HLT::TriggerElement*&, std::string&) const;
162 temp = &HLT::NavigationCore::getRecentFeatureDataOrElementLink<DataLink<C> >;
163 //std::cout << "DataLink version instantiated for " << ClassID_traits<C>::ID() << std::endl;
164 }
165};
166
167template<typename C>
168struct instantiate_dataelementlink<C,false>{
169 static void do_it(){
170 [[maybe_unused]]
171 bool (HLT::NavigationCore::*temp)(const HLT::TriggerElement*,ElementLink<C>& link,
172 const std::string&, const HLT::TriggerElement*&, std::string&) const;
173 temp = &HLT::NavigationCore::getRecentFeatureDataOrElementLink<ElementLink<C> >;
174 //std::cout << "ElementLink version instantiated for " << ClassID_traits<C>::typeName() << std::endl;
175 }
176};
177
178template <class T, class C>
179HLT::FeatureContainerInit<T, C>::FeatureContainerInit() {
180 HLT::TypeMaps::registerFeatureContainer<T, C>();
181
182 // staements below force generation of the specializations for the methods
183 [[maybe_unused]]
184 bool (HLT::Navigation::*temp_attachFeature)( TriggerElement*, const T*,
185 Navigation::MemoryManagement, std::string&, const std::string& );
186 temp_attachFeature = &HLT::Navigation::attachFeature<T>;
187
188 [[maybe_unused]]
189 bool (HLT::Navigation::*temp_associateExternalCollection)( const std::string& );
190 temp_associateExternalCollection = &HLT::Navigation::associateExternalCollection<T>;
191
192
193
194 [[maybe_unused]]
195 typename acquire_attachFeatureConstDV<T, std::is_same<T,C>::value && ConstDVCompatible<T>::value>::type temp_attachFeatureConstDV;
196 temp_attachFeatureConstDV = acquire_attachFeatureConstDV<T,
197 std::is_same<T,C>::value &&
198 ConstDVCompatible<T>::value
199 >::do_it();
200
201 // typename acquire_getRecentFeatureConstDV<T, std::is_same<T,C>::value>::type temp_getRecentFeatureConstDV;
202 // temp_getRecentFeatureConstDV = acquire_getRecentFeatureConstDV<T, std::is_same<T,C>::value>::do_it();
203
204
205 //
206 [[maybe_unused]]
207 bool (HLT::NavigationCore::*temp_getFeatures)( const TriggerElement*, std::vector< const T*>&,
208 const std::string&, std::map<const T*, std::string>* ) const;
209 temp_getFeatures = &HLT::NavigationCore::getFeatures<T>;
210
211
212 //
213 [[maybe_unused]]
214 bool (HLT::NavigationCore::*temp_getFeature)( const TriggerElement*, const T*&, const std::string&, std::string&) const;
215 temp_getFeature = &HLT::NavigationCore::getFeature<T>;
216
217
218 //const T* (HLT::NavigationCore::*temp_featureLink2Object)( const TrigFeatureLink& );
219 [[maybe_unused]]
220 typename FeatureLinkMethods<T>::fl2o temp_featureLink2Object;
221 temp_featureLink2Object = acquire_featureLinkToObject<T, std::is_same<T, C>::value>::do_it();//&HLT::NavigationCore::featureLink2Object<T>;
222
223 //
224 [[maybe_unused]]
225 typename FeatureLinkMethods<T>::o2fl_1 temp_object2FeatureLink;
226 temp_object2FeatureLink = acquire_object2FeatureLink1<T, std::is_same<T, C>::value>::do_it();
227
228 //
229 [[maybe_unused]]
230 typename FeatureLinkMethods2<C>::o2fl_2 temp_object2FeatureLink2;
231 temp_object2FeatureLink2 = acquire_object2FeatureLink2<C, std::is_same<T, C>::value>::do_it();
232
233 //
234 [[maybe_unused]]
235 bool (HLT::NavigationCore::*temp_getRecentFeatures)( const TriggerElement*,
236 std::vector< const T*>&, const std::string&,
237 std::map<const T*, std::string>* ) const;
238 temp_getRecentFeatures = &HLT::NavigationCore::getRecentFeatures<T>;
239
240 //
241 [[maybe_unused]]
242 bool (HLT::NavigationCore::*temp_getRecentFeature)( const TriggerElement*,
243 const T*&, const std::string&, const TriggerElement*&, std::string& ) const;
244 temp_getRecentFeature = &HLT::NavigationCore::getRecentFeature<T>;
245
246
247 [[maybe_unused]]
248 typename acquire_getRecentFeatureConstDV<T, std::is_same<T,C>::value and canTransfer<C>::value >::type temp_getRecentFeatureConstDV;
249 temp_getRecentFeatureConstDV = acquire_getRecentFeatureConstDV<T, std::is_same<T,C>::value and canTransfer<C>::value>::do_it();
250
251
252 //
253 [[maybe_unused]]
254 bool (HLT::NavigationCore::*temp_getRecentFeaturesLinks)( const TriggerElement*,
255 ElementLinkVector<C>&, const std::string& ) const;
256 temp_getRecentFeaturesLinks = &HLT::NavigationCore::getRecentFeaturesLinks<C,T>;
257
258
259 //
260 [[maybe_unused]]
261 bool (HLT::NavigationCore::*temp_getRecentFeatureLink)( const TriggerElement*,
262 ElementLink<C>&, const std::string&, const TriggerElement*&, std::string& ) const;
263 temp_getRecentFeatureLink = &HLT::NavigationCore::getRecentFeatureLink<C,T>;
264
265 //getRecentFeatureDataOrElementLink depends on what kind of feature we have
266 //therefore we need to outsource to helper
267 instantiate_dataelementlink<C,std::is_same<T,C>::value >::do_it();
268
269 //
270 [[maybe_unused]]
271 bool (HLT::NavigationCore::*temp_getFeaturesInRoI)( const TriggerElement*, std::vector<const T*>&,
272 const std::string&, std::map<const T*, std::string>* ) const;
273 temp_getFeaturesInRoI = &HLT::NavigationCore::getFeaturesInRoI<T>;
274
275 //
276 [[maybe_unused]]
277 bool (HLT::NavigationCore::*temp_getAllFeatures)(ElementLinkVector<C>&, const std::string& ) const;
278 temp_getAllFeatures = &HLT::NavigationCore::getAllFeatures<C,T>;
279
280 //
281 [[maybe_unused]]
282 bool (HLT::Navigation::*temp_findOwners)(const T*, std::vector<const TriggerElement*>&, unsigned int);
283 temp_findOwners = &HLT::Navigation::findOwners<T>;
284
285 //
286 typedef const std::string const_string;
287 [[maybe_unused]]
288 const_string (HLT::Navigation::*temp_getNextKey)( const std::string& );
289 temp_getNextKey = &HLT::Navigation::getNextKey<T>;
290
291
292 //
293 [[maybe_unused]]
294 const_string (HLT::Navigation::*temp_getUniqueKey)( const std::string&);
295 temp_getUniqueKey = &HLT::Navigation::getUniqueKey<T>;
296
297}
298
299template <class T>
300HLT::AuxInit<T>::AuxInit() {
301 HLT::TypeMaps::registerType<T>();
302}
303
304#endif