1 // dear emacs this is -*- c++ -*-
4 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
8 #ifndef TrigNavigation_NavigationInit_icc
9 #define TrigNavigation_NavigationInit_icc
11 //#include "GaudiKernel/MsgStream.h"
12 #include <type_traits>
14 #include "AthContainers/ConstDataVector.h"
15 #include "TrigNavigation/Holder.h"
16 #include "TrigNavigation/Holder.icc"
18 #include "TrigNavigation/Navigation.h"
19 #include "TrigNavigation/Navigation.icc"
21 #include "TrigNavigation/NavigationCore.h"
22 #include "TrigNavigation/NavigationCore.icc"
24 #include "TrigNavigation/TypeMaps.h"
27 //#include "TrigNavigation/AccessProxy.h"
29 #include "TrigNavigation/TrigFeatureLink.h"
30 #include "TrigNavigation/NavigationTraits.h"
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;
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;
50 /////////////////////////////////////////////////////
51 template<class T, bool> struct acquire_featureLinkToObject;
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>;}
59 template<class T> struct acquire_featureLinkToObject<T, true>{
60 static typename FeatureLinkMethods<T>::fl2o do_it() {
64 /////////////////////////////////////////////////////
65 template<class T, bool FeatureIsContainer> struct acquire_getRecentFeatureConstDV;
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>>; }
75 struct acquire_getRecentFeatureConstDV<T, false> {
77 static type do_it() { return 0; }
80 /////////////////////////////////////////////////////
84 struct ConstDVCompatible{
85 typedef char yes[2];typedef char no[1];
88 // template<typename X, X>
93 // static auto f(Help<decltype(&C::resize),&C::resize>*) -> yes&;
94 static yes& f(decltype(&C::resize));
97 // static auto f(...) -> no&;
100 static const bool value = sizeof(f<T>(0)) == sizeof(yes);
105 /////////////////////////////////////////////////////
107 template<class T, bool FeatureIsContainer> struct acquire_attachFeatureConstDV;
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& );
113 static type do_it() {
114 return &HLT::Navigation::attachFeature<T>;
119 struct acquire_attachFeatureConstDV<T, false> {
121 static type do_it() { return 0; }
129 //struct O2FLMethod_1 {
130 // typedef TrigFeatureLink (HLT::NavigationCore::*o2fl_1)(const HLT::TriggerElement*, const std::string&, const T*);
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>;
139 template<class T> struct acquire_object2FeatureLink1<T, false> {
140 static typename FeatureLinkMethods<T>::o2fl_1 do_it() {
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>;
152 template<class T> struct acquire_object2FeatureLink2<T, true> {
153 static typename FeatureLinkMethods2<T>::o2fl_2 do_it() {
158 template<typename C, bool>
159 struct instantiate_dataelementlink;
162 struct instantiate_dataelementlink<C,true>{
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;
173 struct instantiate_dataelementlink<C,false>{
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;
183 template <class T, class C>
184 HLT::FeatureContainerInit<T, C>::FeatureContainerInit() {
185 HLT::TypeMaps::registerFeatureContainer<T, C>();
187 // staements below force generation of the specializations for the methods
189 bool (HLT::Navigation::*temp_attachFeature)( TriggerElement*, const T*,
190 Navigation::MemoryManagement, std::string&, const std::string& );
191 temp_attachFeature = &HLT::Navigation::attachFeature<T>;
194 bool (HLT::Navigation::*temp_associateExternalCollection)( const std::string& );
195 temp_associateExternalCollection = &HLT::Navigation::associateExternalCollection<T>;
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
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();
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>;
219 bool (HLT::NavigationCore::*temp_getFeature)( const TriggerElement*, const T*&, const std::string&, std::string&) const;
220 temp_getFeature = &HLT::NavigationCore::getFeature<T>;
223 //const T* (HLT::NavigationCore::*temp_featureLink2Object)( const TrigFeatureLink& );
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>;
230 typename FeatureLinkMethods<T>::o2fl_1 temp_object2FeatureLink;
231 temp_object2FeatureLink = acquire_object2FeatureLink1<T, std::is_same<T, C>::value>::do_it();
235 typename FeatureLinkMethods2<C>::o2fl_2 temp_object2FeatureLink2;
236 temp_object2FeatureLink2 = acquire_object2FeatureLink2<C, std::is_same<T, C>::value>::do_it();
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>;
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>;
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();
259 bool (HLT::NavigationCore::*temp_getRecentFeaturesLinks)( const TriggerElement*,
260 ElementLinkVector<C>&, const std::string& ) const;
261 temp_getRecentFeaturesLinks = &HLT::NavigationCore::getRecentFeaturesLinks<C,T>;
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>;
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();
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>;
282 bool (HLT::NavigationCore::*temp_getAllFeatures)(ElementLinkVector<C>&, const std::string& ) const;
283 temp_getAllFeatures = &HLT::NavigationCore::getAllFeatures<C,T>;
287 bool (HLT::Navigation::*temp_findOwners)(const T*, std::vector<const TriggerElement*>&, unsigned int);
288 temp_findOwners = &HLT::Navigation::findOwners<T>;
291 typedef const std::string const_string;
293 const_string (HLT::Navigation::*temp_getNextKey)( const std::string& );
294 temp_getNextKey = &HLT::Navigation::getNextKey<T>;
299 const_string (HLT::Navigation::*temp_getUniqueKey)( const std::string&);
300 temp_getUniqueKey = &HLT::Navigation::getUniqueKey<T>;
305 HLT::AuxInit<T>::AuxInit() {
306 HLT::TypeMaps::registerType<T>();