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