|
|
Go to the documentation of this file. 1 #ifndef FWCore_SOA_Table_h
2 #define FWCore_SOA_Table_h
136 template <
typename... Args>
139 static constexpr
const unsigned int kNColumns =
sizeof...(Args);
144 template <
typename T,
typename... CArgs>
146 if constexpr (
sizeof...(CArgs) == 0) {
153 template <
typename T,
typename... CArgs>
155 m_size = iContainer.size();
194 template <
typename U>
196 return *(static_cast<typename U::type const*>(columnAddress<U>()) + iRow);
198 template <
typename U>
200 return *(static_cast<typename U::type*>(columnAddress<U>()) + iRow);
203 template <
typename U>
207 template <
typename U>
217 for (
size_t i = 0;
i <
t.size(); ++
i) {
224 for (
size_t i = 0;
i <
t.size(); ++
i) {
233 template <
typename U>
235 return columnAddress<U>();
245 template <
typename U>
250 template <
typename U>
258 if constexpr (
I <
sizeof...(Args)) {
260 delete[] static_cast<Type*>(iArray[
I]);
267 template <
typename T,
typename...
U>
268 static size_t fill(
std::array<
void*,
sizeof...(Args)>& oValues,
T const& iContainer,
U... iArgs) {
269 static_assert(
sizeof...(Args) ==
sizeof...(
U) + 1,
"Wrong number of arguments passed to Table constructor");
270 ctrFiller<0>(oValues, iContainer.size(), iContainer, std::forward<U>(iArgs)...);
271 return iContainer.size();
275 template <
int I,
typename T,
typename...
U>
277 assert(iContainer.size() == iSize);
280 unsigned int index = 0;
281 for (
auto const&
v : iContainer) {
287 ctrFiller<I + 1>(oValues, iSize, std::forward<U>(iU)...);
296 template <
typename T>
297 static size_t fill(
std::array<
void*,
sizeof...(Args)>& oValues,
T const& iContainer) {
298 presize<0>(oValues, iContainer.size());
300 for (
auto&&
item : iContainer) {
304 return iContainer.size();
307 template <
typename T,
typename F>
309 presize<0>(oValues, iContainer.size());
311 for (
auto&&
item : iContainer) {
312 fillElementUsingFiller<0>(iFiller,
item,
index, oValues);
315 return iContainer.size();
321 if constexpr (
I <
sizeof...(Args)) {
322 using Layout = std::tuple<Args...>;
324 oValues[
I] =
new Type[iSize];
325 presize<I + 1>(oValues, iSize);
329 template <
int I,
typename E>
331 if constexpr (
I <
sizeof...(Args)) {
332 using Layout = std::tuple<Args...>;
335 Type* pElement = static_cast<Type*>(oValues[
I]) + iIndex;
337 fillElement<I + 1>(iItem, iIndex, oValues);
341 template <
int I,
typename E,
typename F>
345 std::array<
void*,
sizeof...(Args)>& oValues) {
346 if constexpr (
I <
sizeof...(Args)) {
347 using Layout = std::tuple<Args...>;
350 Type* pElement = static_cast<Type*>(oValues[
I]) + iIndex;
351 *pElement = iFiller.value(iItem, static_cast<ColumnType*>(
nullptr));
352 fillElementUsingFiller<I + 1>(iFiller, iItem, iIndex, oValues);
357 template <
size_t...
I>
359 std::array<
void*,
sizeof...(Args)>
const& iFrom,
361 std::index_sequence<I...>) {
362 (copyFromToWithResize<I>(iNElements, iFrom, oTo), ...);
367 std::array<
void*,
sizeof...(Args)>
const& iFrom,
369 using Layout = std::tuple<Args...>;
371 Type* oldPtr = static_cast<Type*>(oTo[
I]);
374 std::copy(static_cast<Type const*>(iFrom[
I]), static_cast<Type const*>(iFrom[
I]) + iNElements, ptr);
380 if constexpr (
I <
sizeof...(Args)) {
381 using Layout = std::tuple<Args...>;
383 Type* oldPtr = static_cast<Type*>(ioArray[
I]);
384 auto ptr =
new Type[iNewSize];
385 auto nToCopy =
std::min(iOldSize, iNewSize);
386 std::copy(static_cast<Type const*>(ioArray[
I]), static_cast<Type const*>(ioArray[
I]) + nToCopy, ptr);
387 resizeFromTo<I + 1>(iOldSize, iNewSize, ioArray);
396 if constexpr (
I <
sizeof...(Args)) {
397 using Layout = std::tuple<Args...>;
399 auto ptr = static_cast<Type*>(ioArray[
I]);
402 resetStartingAt<I + 1>(iStartIndex, iEndIndex, ioArray);
408 template <
typename T1,
typename T2>
410 template <
typename... T1,
typename... T2>
415 template <
typename T1,
typename T2>
419 template <
typename LHS,
typename E,
typename RHS>
421 template <
typename LHS,
typename E,
typename T,
typename...
U>
423 using type =
typename std::conditional<
429 template <
typename LHS,
typename E>
435 template <
typename TABLE,
typename E>
440 template <
typename TABLE,
typename E>
444 template <
typename T>
447 template <
typename... Args>
Table< Args... > & operator=(Table< Args... > const &iOther)
MutableRowView< Args... > row(size_t iRow)
void const * columnAddressByIndex(unsigned int iIndex) const
U::type const & get(size_t iRow) const
static void ctrFiller(std::array< void *, sizeof...(Args)> &oValues, size_t iSize, T const &iContainer, U... iU)
ColumnValues< typename U::type > column() const
RowView< Args... > row(size_t iRow) const
void resize(unsigned int iNewSize)
static void resizeFromTo(size_t iOldSize, size_t iNewSize, std::array< void *, sizeof...(Args)> &ioArray)
void const * columnAddress() const
keep ROOT from trying to store this
Table(Table< Args... > const &iOther)
Table(T const &iContainer, CArgs... iArgs)
static uInt32 F(BLOWFISH_CTX *ctx, uInt32 x)
static void copyFromToWithResize(size_t iNElements, std::array< void *, sizeof...(Args)> const &iFrom, std::array< void *, sizeof...(Args)> &oTo)
static void fillElement(E const &iItem, size_t iIndex, std::array< void *, sizeof...(Args)> &oValues)
const std::complex< double > I
static void ctrFiller(std::array< void *, sizeof...(Args)> &, size_t)
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
Table(Table< Args... > &&iOther)
unsigned int size() const
Table< Args... > & operator=(Table< Args... > &&iOther)
col::Eta ::type value_for_column(Object const &x, col::Eta *)
static size_t fillUsingFiller(F &iFiller, std::array< void *, sizeof...(Args)> &oValues, T const &iContainer)
std::array< void *, sizeof...(Args)> m_values
static void copyFromToWithResizeAll(size_t iNElements, std::array< void *, sizeof...(Args)> const &iFrom, std::array< void *, sizeof...(Args)> &oTo, std::index_sequence< I... >)
static constexpr const unsigned int kNColumns
const_iterator end() const
static size_t fill(std::array< void *, sizeof...(Args)> &oValues, T const &iContainer)
Table(T const &iContainer, ColumnFillers< CArgs... > iFiller)
static void presize(std::array< void *, sizeof...(Args)> &oValues, size_t iSize)
U::type & get(size_t iRow)
std::tuple< Args... > Layout
static std::unique_ptr< TableExaminerBase > make(const Table< Args... > *iTable)
MutableColumnValues< typename U::type > column()
typename RemoveColumn< TABLE, E >::type RemoveColumn_t
void const * columnAddressWorkaround(U const *) const
static void resetStartingAt(size_t iStartIndex, size_t iEndIndex, std::array< void *, sizeof...(Args)> &ioArray)
static size_t fill(std::array< void *, sizeof...(Args)> &oValues, T const &iContainer, U... iArgs)
typename AddColumns< T1, T2 >::type AddColumns_t
def cp(fromDir, toDir, listOfFiles, overwrite=False, smallList=False)
static void dtr(std::array< void *, sizeof...(Args)> &iArray)
static void fillElementUsingFiller(F &iFiller, E const &iItem, size_t iIndex, std::array< void *, sizeof...(Args)> &oValues)
const_iterator begin() const
typename impl::RemoveColumnCheck< Table<>, E, typename TABLE::Layout >::type type
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