CMS 3D CMS Logo

ColumnFillers.h
Go to the documentation of this file.
1 #ifndef FWCore_SOA_ColumnFillers_h
2 #define FWCore_SOA_ColumnFillers_h
3 // -*- C++ -*-
4 //
5 // Package: FWCore/SOA
6 // Class : ColumnFillers
7 //
29 //
30 // Original Author: Chris Jones
31 // Created: Thu, 24 Aug 2017 22:22:42 GMT
32 //
33 
34 // system include files
35 
36 // user include files
37 
38 // forward declarations
39 #include <tuple>
40 
41 namespace edm {
42  namespace soa {
43 
44  template <typename... Args>
45  class ColumnFillers {
46  using Layout = std::tuple<Args...>;
48 
49  template <int I, typename ELEMENT>
50  decltype(auto) callFiller(ELEMENT&& iEl) {
51  return std::get<I>(m_fillers).m_f(iEl);
52  }
53 
54  template <int I, typename COLUMN, typename ELEMENT>
55  typename COLUMN::type tryValue(ELEMENT&& iEl) {
56  if constexpr (I < sizeof...(Args)) {
57  using Pair = typename std::tuple_element<I, Layout>::type;
58  using COL = typename Pair::Column_type;
60  return callFiller<I>(iEl);
61  } else {
62  //try another filler to see if it matches
63  return tryValue<I + 1, COLUMN>(iEl);
64  }
65  } else {
66  //no matches so call overload function
67  return value_for_column(iEl, static_cast<COLUMN*>(nullptr));
68  }
69  }
70 
71  public:
72  ColumnFillers(Args... iArgs) : m_fillers(std::forward<Args>(iArgs)...) {}
73 
74  template <typename ELEMENT, typename COLUMN>
75  typename COLUMN::type value(ELEMENT&& iEl, COLUMN*) {
76  return tryValue<0, COLUMN>(iEl);
77  }
78  };
79 
80  template <typename... Args>
81  ColumnFillers<Args...> column_fillers(Args... iArgs) {
82  return ColumnFillers<Args...>(std::forward<Args>(iArgs)...);
83  }
84 
85  } // namespace soa
86 } // namespace edm
87 
88 #endif
COLUMN::type value(ELEMENT &&iEl, COLUMN *)
Definition: ColumnFillers.h:75
ColumnFillers< Args... > column_fillers(Args... iArgs)
Definition: ColumnFillers.h:81
const std::complex< double > I
Definition: I.h:8
ColumnFillers(Args... iArgs)
Definition: ColumnFillers.h:72
decltype(auto) callFiller(ELEMENT &&iEl)
Definition: ColumnFillers.h:50
HLT enums.
col::Eta ::type value_for_column(Object const &x, col::Eta *)
COLUMN::type tryValue(ELEMENT &&iEl)
Definition: ColumnFillers.h:55
std::tuple< Args... > Layout
Definition: ColumnFillers.h:46