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;
59  if constexpr (std::is_same<COL, COLUMN>::value) {
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
edm::soa::column_fillers
ColumnFillers< Args... > column_fillers(Args... iArgs)
Definition: ColumnFillers.h:81
edm
HLT enums.
Definition: AlignableModifier.h:19
gpuVertexFinder::soa
ZVertexSoA * soa
Definition: gpuVertexFinderImpl.h:24
edm::soa::ColumnFillers::m_fillers
Layout m_fillers
Definition: ColumnFillers.h:47
Exhume::I
const std::complex< double > I
Definition: I.h:8
edm::soa::ColumnFillers::tryValue
COLUMN::type tryValue(ELEMENT &&iEl)
Definition: ColumnFillers.h:55
edm::soa::value_for_column
col::Eta ::type value_for_column(Object const &x, col::Eta *)
Definition: KinematicColumns.h:24
gainCalibHelper::gainCalibPI::type
type
Definition: SiPixelGainCalibHelper.h:40
edm::soa::ColumnFillers
Definition: ColumnFillers.h:45
std
Definition: JetResolutionObject.h:76
relativeConstraints.value
value
Definition: relativeConstraints.py:53
edm::soa::ColumnFillers::value
COLUMN::type value(ELEMENT &&iEl, COLUMN *)
Definition: ColumnFillers.h:75
edm::soa::ColumnFillers::callFiller
decltype(auto) callFiller(ELEMENT &&iEl)
Definition: ColumnFillers.h:50
edm::soa::ColumnFillers::Layout
std::tuple< Args... > Layout
Definition: ColumnFillers.h:46
edm::soa::ColumnFillers::ColumnFillers
ColumnFillers(Args... iArgs)
Definition: ColumnFillers.h:72