4 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
8 #ifndef TRIGNAVIGATION_HLTNAVIGATION_ICC
9 #define TRIGNAVIGATION_HLTNAVIGATION_ICC
12 /*****************************************************************************
14 * COMPILE TYPE OBJECTS REGISTRATION
16 *****************************************************************************/
18 #include <type_traits>
19 #include "TrigNavigation/Holder.h"
20 #include "CxxUtils/checker_macros.h"
21 #include "CxxUtils/no_sanitize_undefined.h"
24 /*****************************************************************************
28 *****************************************************************************/
31 __attribute__((__used__))
32 bool HLT::Navigation::attachFeature NO_SANITIZE_UNDEFINED ATLAS_NOT_THREAD_SAFE
33 ( TriggerElement* te, const T* feature,
34 MemoryManagement mmanagement, std::string& key,
35 const std::string& label ) {
37 CLID clid = ClassID_traits<T>::ID();
39 ATH_MSG_DEBUG("attachFeature: of clid: " << clid << "(" << ClassID_traits<T>::typeName() << ")"
40 << " to TE: " << te->getId()
41 << " label: \"" << label << "\""
42 << " memory management: " << mmanagement);
44 // get a holder for this type --- if that's new it will be created
46 ATH_MSG_VERBOSE("getting Holder for label: " << label);
47 HLTNavDetails::Holder<T>* holder = getHolder<T>(label, nextSubTypeIndex(clid,label));
48 ATH_MSG_VERBOSE("got Holder: " << holder);
51 ATH_MSG_WARNING("attachFeature: Holder missing for CLID: " << clid);
55 TriggerElement::ObjectIndex objectIndex = holder->add(feature, mmanagement == ObjectInStoreGate, key);
56 if ( not objectIndex.valid() )
58 te->addFeature(clid, objectIndex, false);
65 __attribute__((__used__))
66 bool HLT::Navigation::attachFeature ATLAS_NOT_THREAD_SAFE ( TriggerElement* te, const ConstDataVector<T>* feature,
67 MemoryManagement mmanagement, std::string& key,
68 const std::string& label ) {
69 return attachFeature (te, feature->asDataVector(),
70 mmanagement, key, label);
75 __attribute__((__used__))
76 bool HLT::Navigation::associateExternalCollection(const std::string& label) {
77 CLID clid = ClassID_traits<T>::ID();
79 ATH_MSG_DEBUG("associateExternalCollection: of clid: " << clid << "(" << ClassID_traits<T>::typeName() << ")"
80 << " label: \"" << label << "\"");
81 HLTNavDetails::Holder<T>* holder = getHolder<T>(label, nextSubTypeIndex(clid,label));
83 ATH_MSG_WARNING("associateExternalCollection: Holder missing for CLID: " << clid);
90 /////////////////////////////////////////////////////////////////////////////
92 __attribute__((__used__))
93 bool HLT::Navigation::findOwners(const T* obj, std::vector<const TriggerElement*>& owners, unsigned int id) {
94 std::lock_guard<std::recursive_mutex> lock(getMutex());
95 TriggerElementFactory& factory = getFactory();
96 TrigHolderStructure& holderstorage = getHolderStorage();
98 std::vector<TriggerElement*>::const_iterator it = factory.listOfProduced().begin();
99 std::vector<TriggerElement*>::const_iterator itEnd = factory.listOfProduced().end();
101 it = factory.listOfProduced(id).begin();
102 itEnd = factory.listOfProduced(id).end();
103 ATH_MSG_VERBOSE("findOwners will scann TEs of ID : " << id << " #: " << itEnd-it);
105 ATH_MSG_VERBOSE("findOwners will scann ALL TEs (slow):" << itEnd-it);
108 CLID clid = ClassID_traits<T>::ID();
110 auto holders_of_clid = holderstorage.getHoldersOfClid<HLTNavDetails::Holder<T> >(clid);
112 if(holders_of_clid.empty())
115 ATH_MSG_VERBOSE("findOwners features of this CLID present");
116 bool holderFound = false;
117 HLT::TriggerElement::ObjectIndex idx;
118 for(auto holder : holders_of_clid ) {
119 if ( holder->contains(obj, idx) ) {
121 ATH_MSG_VERBOSE("findOwners found holder owning the object " << *holder << " and index: " << idx);
128 for (; it != itEnd; ++it ) {
129 for ( const TriggerElement::FeatureAccessHelper& f : (*it)->getFeatureAccessHelpers() ) {
130 if ( f.getCLID() == clid && f.getIndex().isSameOrWithin(&idx) ) {
131 owners.push_back(*it);
132 ATH_MSG_VERBOSE("findOwners while looking in TE(id): " << *it <<"(" << (*it)->getId() << ")" <<
133 " and access helper " << f.getIndex() << " found owner");
142 __attribute__((__used__))
143 const std::string HLT::Navigation::getNextKey( const std::string& label ) {
144 CLID clid = ClassID_traits<T>::ID();
145 HLTNavDetails::Holder<T>* holder = getHolder<T>(label, nextSubTypeIndex(clid,label));
146 if (!holder) return ""; // should never happen, but who knows
148 return holder->getNextKey( );
152 __attribute__((__used__))
153 const std::string HLT::Navigation::getUniqueKey( const std::string& label ) {
154 CLID clid = ClassID_traits<T>::ID();
155 HLTNavDetails::Holder<T>* holder = getHolder<T>(label, nextSubTypeIndex(clid, label));
157 if (!holder) return ""; // should never happen, but who knows
159 return holder->getUniqueKey( );
163 #endif // TRIGNAVIGATION_HLTNAVIGATION_ICC