ATLAS Offline Software
Loading...
Searching...
No Matches
EDM_MasterSearch.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
5#ifndef TRIGSTORAGEDEFINITIONS_EDM_MASTERSEARCH
6#define TRIGSTORAGEDEFINITIONS_EDM_MASTERSEARCH
7
9
10// Since due to the functional nature of template programming we need to pass all results/arguments
11// "by reference" (what in normal C++ would be void func(arg1& a1, arg2* a2) we are creating
12// overall holder structes that hold all arguments and all results that we want from the loop
13// in a sense this is similar to how main() takes an argv parameter.
14
15// Our result structure holds a list of bools (implemented as value type) that indicate in which
16// package list the queried type was found and a search_result that gives back the type_info
17// if the element was found in any of the packages or a special "NOT_KNOWN_TO_THE_EDM" error type.
18template<typename NewList = HLT::TypeInformation::newlist,
19 typename SearchResult = HLT::TypeInformation::nil>
20struct my_result{
21 using list = NewList;
22 using search_result = SearchResult;
23};
24
25
26// Argument structure that hold two arguments:
27// 1) a template meta-function (functor) that hold the search method with which we query a typemap
28// 2) a type for which we want to seach for
29template<template<class E, class L, int I> class Functor, typename T>
30struct my_arg {
31 template<class E, class L, int I> struct functor {
32 static constexpr bool result = Functor<E,L,I>::result;
33 };
34
35 using type = T;
36};
37
38// This is the meta-function that we want to execute on each package typemap
39template<typename element, typename last_result, typename arg, bool isLast>
41
42 // Perform the search
44 typename arg::type,
45 typename element::map,
46 arg::template functor >::type;
47
48 // Did we find the type ?
50 static constexpr bool is_found = !std::is_same_v<ErrorType, result_type>;
51
52 // Add it to the list
53 using added = last_result::list::template add<std::bool_constant<is_found>>::go::done;
54
55 // If we did not find the result we just keep our current result and do not replace it
56 using result = std::conditional_t<is_found, result_type, typename last_result::search_result>;
57
58 // Return the error type if still nil otherwise result
59 using type = std::conditional_t<
60 std::is_same_v<result, HLT::TypeInformation::nil>,
63};
64
65// Structure that actually implements the loop over all package EDMs
66template<typename MASTER_EDM, template <class,class,int> class functor, typename which> struct master_search{
68 MASTER_EDM,
72};
73
74
75#endif
bool add(const std::string &hname, TKey *tobj)
Definition fastadd.cxx:55
HLT::TypeInformation::for_each_type_c< MASTER_EDM, my_functor, my_result<>, my_arg< functor, which > >::type result
static constexpr bool result
std::conditional_t< std::is_same_v< result, HLT::TypeInformation::nil >, my_result< added, ErrorType >, my_result< added, result > > type
HLT::TypeInformation::ERROR_THE_FOLLOWING_TYPE_IS_NOT_KNOWN_TO_THE_EDM< typename arg::type > ErrorType
std::conditional_t< is_found, result_type, typename last_result::search_result > result
static constexpr bool is_found
last_result::list::template add< std::bool_constant< is_found > >::go::done added
HLT::TypeInformation::map_search< typename arg::type, typename element::map, arg::template functor >::type result_type
SearchResult search_result