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, std::true_type{});
114  }
115  template<typename O, typename... CArgs>
116  void copyValuesFrom(O const& iObj, ColumnFillers<CArgs...> iFiller) {
117  copyValuesUsingFiller<0>(iFiller, iObj, m_values, std::true_type{});
118  }
119 
120 private:
121  template<int I, typename O>
122  void copyValueFromImpl(O const& iObj, std::true_type) {
123  using ColumnType = typename std::tuple_element<I,Layout>::type;
124  using Type = typename ColumnType::type;
125  auto ptr = static_cast<Type*>(m_values[I]);
126  *ptr =value_for_column(iObj, static_cast<ColumnType*>(nullptr));
127  copyValueFromImpl<I+1>(iObj, std::conditional_t<I+1 == sizeof...(Args), std::false_type, std::true_type>{});
128  }
129  template<int I, typename O>
130  void copyValueFromImpl(O const& iObj, std::false_type) {
131  }
132 
133  template<int I, typename E, typename F>
134  static void copyValuesUsingFiller(F& iFiller, E const& iItem, std::array<void *, sizeof...(Args)>& oValues, std::true_type) {
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, std::conditional_t<I+1==sizeof...(Args),
141  std::false_type,
142  std::true_type>{});
143  }
144  template<int I, typename E, typename F>
145  static void copyValuesUsingFiller(F&, E const& , std::array<void *, sizeof...(Args)>& oValues, std::false_type) {}
146 
147 };
148 
149 }
150 }
151 
152 
153 #endif
void copyValueFromImpl(O const &iObj, std::false_type)
Definition: RowView.h:130
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
static void copyValuesUsingFiller(F &, E const &, std::array< void *, sizeof...(Args)> &oValues, std::false_type)
Definition: RowView.h:145
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
static void copyValuesUsingFiller(F &iFiller, E const &iItem, std::array< void *, sizeof...(Args)> &oValues, std::true_type)
Definition: RowView.h:134
std::tuple< Args... > Layout
Definition: RowView.h:79
void copyValueFromImpl(O const &iObj, std::true_type)
Definition: RowView.h:122
HLT enums.
static uInt32 F(BLOWFISH_CTX *ctx, uInt32 x)
Definition: blowfish.cc:281