1 #ifndef FWCore_SOA_Table_h 2 #define FWCore_SOA_Table_h 136 template <
typename... Args>
144 template <
typename T,
typename... CArgs>
146 using CtrChoice = std::conditional_t<
sizeof...(CArgs)==0,
152 template<
typename T,
typename... CArgs>
154 m_size = iContainer.size();
159 copyFromToWithResize<0>(
m_size,iOther.m_values,
m_values,std::true_type{});
189 if(
m_size == iNewSize) {
return;}
191 if(m_size < iNewSize) {
199 typename U::type const&
get(
size_t iRow)
const {
200 return *(
static_cast<typename
U::type const*
>(columnAddress<U>())+iRow);
204 return *(
static_cast<typename
U::type*
>(columnAddress<U>())+iRow);
217 return *(
begin()+iRow);
220 return *(
begin()+iRow);
238 return columnAddress<U>();
263 static void dtr(
std::array<
void*,
sizeof...(Args)>& iArray, std::true_type) {
265 delete []
static_cast<Type*
>(iArray[
I]);
266 dtr<I+1>(iArray,std::conditional_t<
I+1<
sizeof...(Args), std::true_type, std::false_type>{});
270 static void dtr(
std::array<
void*,
sizeof...(Args)>& iArray, std::false_type) {
275 template<
typename T,
typename...
U>
276 static size_t fill(
std::array<
void *,
sizeof...(Args)>& oValues,
T const& iContainer,
U... iArgs) {
277 static_assert(
sizeof...(Args) ==
sizeof...(
U)+1,
"Wrong number of arguments passed to Table constructor");
278 ctrFiller<0>(oValues,iContainer.size(), iContainer,std::forward<U>(iArgs)...);
279 return iContainer.size();
282 template<
int I,
typename T,
typename...
U>
283 static void ctrFiller(
std::array<
void *,
sizeof...(Args)>& oValues,
size_t iSize, T
const& iContainer,
U... iU) {
284 assert(iContainer.size() == iSize);
286 Type *
temp =
new Type [iSize];
287 unsigned int index = 0;
288 for(
auto const&
v: iContainer) {
294 ctrFiller<I+1>(oValues, iSize, std::forward<U>(iU)... );
305 static size_t fill(
std::array<
void *,
sizeof...(Args)>& oValues, T
const& iContainer) {
306 presize<0>(oValues,iContainer.size(),std::true_type{});
308 for(
auto&& item: iContainer) {
309 fillElement<0>(item,
index,oValues,std::true_type{});
312 return iContainer.size();
315 template<
typename T,
typename F>
317 presize<0>(oValues,iContainer.size(),std::true_type{});
319 for(
auto&& item: iContainer) {
320 fillElementUsingFiller<0>(iFiller, item,
index,oValues,std::true_type{});
323 return iContainer.size();
329 static void presize(
std::array<
void *,
sizeof...(Args)>& oValues,
size_t iSize, std::true_type) {
330 using Layout = std::tuple<Args...>;
332 oValues[
I] =
new Type[iSize];
333 presize<I+1>(oValues,iSize, std::conditional_t<I+1==
sizeof...(Args),
338 static void presize(
std::array<
void *,
sizeof...(Args)>& oValues,
size_t iSize, std::false_type) {}
340 template<
int I,
typename E>
341 static void fillElement(E
const& iItem,
size_t iIndex,
std::array<
void *,
sizeof...(Args)>& oValues, std::true_type) {
342 using Layout = std::tuple<Args...>;
345 Type* pElement =
static_cast<Type*
>(oValues[
I])+iIndex;
346 *pElement = value_for_column(iItem, static_cast<ColumnType*>(
nullptr));
347 fillElement<I+1>(iItem, iIndex, oValues, std::conditional_t<I+1==
sizeof...(Args),
351 template<
int I,
typename E>
352 static void fillElement(E
const& iItem,
size_t iIndex,
std::array<
void *,
sizeof...(Args)>& oValues, std::false_type) {}
355 template<
int I,
typename E,
typename F>
357 using Layout = std::tuple<Args...>;
360 Type* pElement =
static_cast<Type*
>(oValues[
I])+iIndex;
361 *pElement = iFiller.value(iItem, static_cast<ColumnType*>(
nullptr));
362 fillElementUsingFiller<I+1>(iFiller,iItem, iIndex, oValues, std::conditional_t<I+1==
sizeof...(Args),
366 template<
int I,
typename E,
typename F>
374 using Layout = std::tuple<Args...>;
376 Type* oldPtr =
static_cast<Type*
>(oTo[
I]);
379 std::copy(static_cast<Type const*>(iFrom[I]), static_cast<Type const*>(iFrom[I])+iNElements, ptr);
381 copyFromToWithResize<I+1>(iNElements, iFrom, oTo, std::conditional_t<I+1 ==
sizeof...(Args), std::false_type, std::true_type>{} );
387 static void resizeFromTo(
size_t iOldSize,
size_t iNewSize,
std::array<
void *,
sizeof...(Args)>& ioArray, std::true_type) {
388 using Layout = std::tuple<Args...>;
390 Type* oldPtr =
static_cast<Type*
>(ioArray[
I]);
391 auto ptr =
new Type[iNewSize];
392 auto nToCopy =
std::min(iOldSize,iNewSize);
393 std::copy(static_cast<Type const*>(ioArray[I]), static_cast<Type const*>(ioArray[I])+nToCopy, ptr);
394 resizeFromTo<I+1>(iOldSize, iNewSize, ioArray, std::conditional_t<I+1 ==
sizeof...(Args), std::false_type, std::true_type>{} );
404 using Layout = std::tuple<Args...>;
406 auto ptr =
static_cast<Type*
>(ioArray[
I]);
409 resetStartingAt<I+1>(iStartIndex, iEndIndex, ioArray,std::conditional_t<I+1 ==
sizeof...(Args), std::false_type, std::true_type>{} );
421 template <
typename... T1,
typename... T2>
426 template <
typename T1,
typename T2>
431 template <
typename LHS,
typename E,
typename T,
typename...
U>
438 template <
typename LHS,
typename E>
444 template <
typename TABLE,
typename E>
449 template <
typename TABLE,
typename E>
455 template<
typename... Args>
static void fillElementUsingFiller(F &, E const &, size_t, std::array< void *, sizeof...(Args)> &oValues, std::false_type)
static void fillElementUsingFiller(F &iFiller, E const &iItem, size_t iIndex, std::array< void *, sizeof...(Args)> &oValues, std::true_type)
static void presize(std::array< void *, sizeof...(Args)> &oValues, size_t iSize, std::true_type)
RowView< Args... > row(size_t iRow) const
Table(Table< Args... > const &iOther)
static void dtr(std::array< void *, sizeof...(Args)> &iArray, std::false_type)
void const * columnAddress() const
keep ROOT from trying to store this
typename std::conditional< std::is_same< E, T >::value, typename AddColumns< LHS, std::tuple< U... >>::type, typename RemoveColumnCheck< typename AddColumns< LHS, std::tuple< T >>::type, E, std::tuple< U... >>::type >::type type
static void presize(std::array< void *, sizeof...(Args)> &oValues, size_t iSize, std::false_type)
Table< Args... > & operator=(Table< Args... > &&iOther)
MutableColumnValues< typename U::type > column()
Table(T const &iContainer, CArgs...iArgs)
Table(T const &iContainer, ColumnFillers< CArgs... > iFiller)
void resize(unsigned int iNewSize)
std::tuple< Args... > Layout
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
static void copyFromToWithResize(size_t, std::array< void *, sizeof...(Args)> const &, std::array< void *, sizeof...(Args)> &, std::false_type)
static void resizeFromTo(size_t iOldSize, size_t iNewSize, std::array< void *, sizeof...(Args)> &ioArray, std::true_type)
const std::complex< double > I
static size_t fill(std::array< void *, sizeof...(Args)> &oValues, T const &iContainer, U...iArgs)
void const * columnAddressWorkaround(U const *) const
ColumnValues< typename U::type > column() const
static size_t fill(std::array< void *, sizeof...(Args)> &oValues, T const &iContainer)
std::array< void *, sizeof...(Args)> m_values
static void resizeFromTo(size_t, size_t, std::array< void *, sizeof...(Args)> &, std::false_type)
const_iterator end() const
Table< Args... > & operator=(Table< Args... > const &iOther)
typename impl::RemoveColumnCheck< Table<>, E, typename TABLE::Layout >::type type
static void fillElement(E const &iItem, size_t iIndex, std::array< void *, sizeof...(Args)> &oValues, std::false_type)
Table(Table< Args... > &&iOther)
static void ctrFiller(std::array< void *, sizeof...(Args)> &, size_t)
static size_t fillUsingFiller(F &iFiller, std::array< void *, sizeof...(Args)> &oValues, T const &iContainer)
MutableRowView< Args... > row(size_t iRow)
static void fillElement(E const &iItem, size_t iIndex, std::array< void *, sizeof...(Args)> &oValues, std::true_type)
typename RemoveColumn< TABLE, E >::type RemoveColumn_t
void const * columnAddressByIndex(unsigned int iIndex) const
static void copyFromToWithResize(size_t iNElements, std::array< void *, sizeof...(Args)> const &iFrom, std::array< void *, sizeof...(Args)> &oTo, std::true_type)
static void ctrFiller(std::array< void *, sizeof...(Args)> &oValues, size_t iSize, T const &iContainer, U...iU)
static std::unique_ptr< TableExaminerBase > make(const Table< Args... > *iTable)
typename AddColumns< T1, T2 >::type AddColumns_t
static uInt32 F(BLOWFISH_CTX *ctx, uInt32 x)
const_iterator begin() const
static constexpr const unsigned int kNColumns
unsigned int size() const
static void dtr(std::array< void *, sizeof...(Args)> &iArray, std::true_type)
static void resetStartingAt(size_t iStartIndex, size_t iEndIndex, std::array< void *, sizeof...(Args)> &ioArray, std::true_type)
static void resetStartingAt(size_t, size_t, std::array< void *, sizeof...(Args)> &, std::false_type)