CMS 3D CMS Logo

RowView.h
Go to the documentation of this file.
1 #ifndef FWCore_SOA_RowView_h
2 #define FWCore_SOA_RowView_h
3 // -*- C++ -*-
4 //
5 // Package: FWCore/SOA
6 // Class : RowView
7 //
38 //
39 // Original Author: Chris Jones
40 // Created: Thu, 24 Aug 2017 16:49:17 GMT
41 //
42 
43 // system include files
44 #include <tuple>
45 #include <array>
46 
47 // user include files
50 
51 // forward declarations
52 
53 namespace edm {
54  namespace soa {
55 
56  template <typename... Args>
57  class RowView {
58  using Layout = std::tuple<Args...>;
59  std::array<void const*, sizeof...(Args)> m_values;
60 
61  public:
62  explicit RowView(std::array<void const*, sizeof...(Args)> const& iValues) : m_values{iValues} {}
63 
64  template <typename U>
65  typename U::type const& get() const {
66  return *(static_cast<typename U::type const*>(columnAddress<U>()));
67  }
68 
69  template <typename U>
70  void const* columnAddress() const {
72  }
73  };
74 
75  template <typename... Args>
77  using Layout = std::tuple<Args...>;
78  std::array<void*, sizeof...(Args)> m_values;
79 
80  public:
81  explicit MutableRowView(std::array<void*, sizeof...(Args)>& iValues) : m_values{iValues} {}
82 
83  template <typename U>
84  typename U::type& get() {
85  return *(static_cast<typename U::type*>(columnAddress<U>()));
86  }
87  template <typename U>
88  typename U::type const& get() const {
89  return *(static_cast<typename U::type const*>(columnAddress<U>()));
90  }
91 
92  template <typename U>
93  MutableRowView<Args...>& set(typename U::type const& iValue) {
94  get<U>() = iValue;
95  return *this;
96  }
97 
98  template <typename U>
99  void* columnAddress() {
101  }
102  template <typename U>
103  void const* columnAddress() const {
105  }
106 
107  template <typename O>
108  void copyValuesFrom(O const& iObj) {
109  copyValueFromImpl<0>(iObj);
110  }
111  template <typename O, typename... CArgs>
112  void copyValuesFrom(O const& iObj, ColumnFillers<CArgs...> iFiller) {
113  copyValuesUsingFiller<0>(iFiller, iObj, m_values);
114  }
115 
116  private:
117  template <int I, typename O>
118  void copyValueFromImpl(O const& iObj) {
119  if constexpr (I < sizeof...(Args)) {
120  using ColumnType = typename std::tuple_element<I, Layout>::type;
121  using Type = typename ColumnType::type;
122  auto ptr = static_cast<Type*>(m_values[I]);
123  *ptr = value_for_column(iObj, static_cast<ColumnType*>(nullptr));
124  copyValueFromImpl<I + 1>(iObj);
125  }
126  }
127 
128  template <int I, typename E, typename F>
129  static void copyValuesUsingFiller(F& iFiller, E const& iItem, std::array<void*, sizeof...(Args)>& oValues) {
130  if constexpr (I < sizeof...(Args)) {
131  using Layout = std::tuple<Args...>;
132  using ColumnType = typename std::tuple_element<I, Layout>::type;
133  using Type = typename ColumnType::type;
134  Type* pElement = static_cast<Type*>(oValues[I]);
135  *pElement = iFiller.value(iItem, static_cast<ColumnType*>(nullptr));
136  copyValuesUsingFiller<I + 1>(iFiller, iItem, oValues);
137  }
138  }
139  };
140 
141  } // namespace soa
142 } // namespace edm
143 
144 #endif
edm::soa::MutableRowView::copyValueFromImpl
void copyValueFromImpl(O const &iObj)
Definition: RowView.h:118
edm::soa::MutableRowView::copyValuesFrom
void copyValuesFrom(O const &iObj)
Definition: RowView.h:108
edm::soa::RowView
Definition: RowView.h:57
edm::soa::MutableRowView::get
U::type & get()
Definition: RowView.h:84
edm
HLT enums.
Definition: AlignableModifier.h:19
edm::soa::MutableRowView::copyValuesUsingFiller
static void copyValuesUsingFiller(F &iFiller, E const &iItem, std::array< void *, sizeof...(Args)> &oValues)
Definition: RowView.h:129
edm::soa::RowView::m_values
std::array< void const *, sizeof...(Args)> m_values
Definition: RowView.h:59
mps_check.array
array
Definition: mps_check.py:216
F
static uInt32 F(BLOWFISH_CTX *ctx, uInt32 x)
Definition: blowfish.cc:163
Exhume::I
const std::complex< double > I
Definition: I.h:8
susybsm::HSCParticleType::Type
Type
Definition: HSCParticle.h:20
edm::soa::MutableRowView::columnAddress
void * columnAddress()
Definition: RowView.h:99
edm::soa::MutableRowView::columnAddress
void const * columnAddress() const
Definition: RowView.h:103
edm::soa::RowView::Layout
std::tuple< Args... > Layout
Definition: RowView.h:58
ColumnFillers.h
edm::soa::MutableRowView::copyValuesFrom
void copyValuesFrom(O const &iObj, ColumnFillers< CArgs... > iFiller)
Definition: RowView.h:112
tablehelpers.h
edm::soa::RowView::columnAddress
void const * columnAddress() const
Definition: RowView.h:70
edm::soa::ColumnFillers
Definition: ColumnFillers.h:45
edm::soa::MutableRowView
Definition: RowView.h:76
edm::soa::MutableRowView::Layout
std::tuple< Args... > Layout
Definition: RowView.h:77
type
type
Definition: HCALResponse.h:21
edm::soa::MutableRowView::set
MutableRowView< Args... > & set(typename U::type const &iValue)
Definition: RowView.h:93
edm::soa::MutableRowView::get
U::type const & get() const
Definition: RowView.h:88
edm::soa::RowView::get
U::type const & get() const
Definition: RowView.h:65
edm::soa::impl::GetIndex
Definition: tablehelpers.h:38
edm::soa::MutableRowView::MutableRowView
MutableRowView(std::array< void *, sizeof...(Args)> &iValues)
Definition: RowView.h:81
edm::soa::MutableRowView::m_values
std::array< void *, sizeof...(Args)> m_values
Definition: RowView.h:78
edm::soa::RowView::RowView
RowView(std::array< void const *, sizeof...(Args)> const &iValues)
Definition: RowView.h:62