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):
63  m_values{iValues} {}
64 
65  template<typename U>
66  typename U::type const& get() const {
67  return *(static_cast<typename U::type const*>(columnAddress<U>()));
68  }
69 
70  template<typename U>
71  void const* columnAddress() const {
73  }
74 
75 };
76 
77 template <typename... Args>
79  using Layout = std::tuple<Args...>;
80  std::array<void*, sizeof...(Args)> m_values;
81 
82 public:
83  explicit MutableRowView( std::array<void*, sizeof...(Args)>& iValues):
84  m_values{iValues} {}
85 
86  template<typename U>
87  typename U::type& get() {
88  return *(static_cast<typename U::type*>(columnAddress<U>()));
89  }
90  template<typename U>
91  typename U::type const& get() const {
92  return *(static_cast<typename U::type const*>(columnAddress<U>()));
93  }
94 
95  template<typename U>
96  MutableRowView<Args...>& set( typename U::type const& iValue) {
97  get<U>() = iValue;
98  return *this;
99  }
100 
101  template<typename U>
102  void * columnAddress() {
104  }
105  template<typename U>
106  void const * columnAddress() const {
108  }
109 
110 
111  template<typename O>
112  void copyValuesFrom(O const& iObj) {
113  copyValueFromImpl<0>(iObj);
114  }
115  template<typename O, typename... CArgs>
116  void copyValuesFrom(O const& iObj, ColumnFillers<CArgs...> iFiller) {
117  copyValuesUsingFiller<0>(iFiller, iObj, m_values);
118  }
119 
120 private:
121  template<int I, typename O>
122  void copyValueFromImpl(O const& iObj) {
123  if constexpr(I < sizeof...(Args)) {
124  using ColumnType = typename std::tuple_element<I,Layout>::type;
125  using Type = typename ColumnType::type;
126  auto ptr = static_cast<Type*>(m_values[I]);
127  *ptr =value_for_column(iObj, static_cast<ColumnType*>(nullptr));
128  copyValueFromImpl<I+1>(iObj);
129  }
130  }
131 
132  template<int I, typename E, typename F>
133  static void copyValuesUsingFiller(F& iFiller, E const& iItem, std::array<void *, sizeof...(Args)>& oValues) {
134  if constexpr(I < sizeof...(Args)) {
135  using Layout = std::tuple<Args...>;
136  using ColumnType = typename std::tuple_element<I,Layout>::type;
137  using Type = typename ColumnType::type;
138  Type* pElement = static_cast<Type*>(oValues[I]);
139  *pElement = iFiller.value(iItem, static_cast<ColumnType*>(nullptr));
140  copyValuesUsingFiller<I+1>(iFiller,iItem, oValues);
141  }
142  }
143 };
144 
145 }
146 }
147 
148 
149 #endif
type
Definition: HCALResponse.h:21
void copyValuesFrom(O const &iObj)
Definition: RowView.h:112
MutableRowView(std::array< void *, sizeof...(Args)> &iValues)
Definition: RowView.h:83
void const * columnAddress() const
Definition: RowView.h:106
void copyValuesFrom(O const &iObj, ColumnFillers< CArgs... > iFiller)
Definition: RowView.h:116
std::tuple< Args... > Layout
Definition: RowView.h:58
void const * columnAddress() const
Definition: RowView.h:71
#define constexpr
const std::complex< double > I
Definition: I.h:8
std::array< void const *, sizeof...(Args)> m_values
Definition: RowView.h:59
RowView(std::array< void const *, sizeof...(Args)> const &iValues)
Definition: RowView.h:62
std::tuple< Args... > Layout
Definition: RowView.h:79
HLT enums.
void copyValueFromImpl(O const &iObj)
Definition: RowView.h:122
static uInt32 F(BLOWFISH_CTX *ctx, uInt32 x)
Definition: blowfish.cc:281
static void copyValuesUsingFiller(F &iFiller, E const &iItem, std::array< void *, sizeof...(Args)> &oValues)
Definition: RowView.h:133