File indexing completed on 2024-04-06 12:13:09
0001 #ifndef FWCore_SOA_TableExaminer_h
0002 #define FWCore_SOA_TableExaminer_h
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024 #include "FWCore/SOA/interface/TableExaminerBase.h"
0025
0026
0027 namespace edm {
0028 namespace soa {
0029
0030 template <typename T>
0031 class TableExaminer : public TableExaminerBase {
0032 public:
0033 explicit TableExaminer(T const* iTable) : m_table(iTable) {}
0034
0035 TableExaminer(const TableExaminer<T>&) = default;
0036
0037 TableExaminer<T>& operator=(const TableExaminer<T>&) = default;
0038
0039 ~TableExaminer() override {}
0040
0041
0042
0043 size_t size() const final { return m_table->size(); }
0044
0045 void const* columnAddress(unsigned int iColumnIndex) const final {
0046 return m_table->columnAddressByIndex(iColumnIndex);
0047 }
0048
0049 std::vector<std::type_index> columnTypes() const final {
0050 std::vector<std::type_index> returnValue;
0051 returnValue.reserve(T::kNColumns);
0052 columnTypesImpl<0, T::kNColumns>(returnValue);
0053 return returnValue;
0054 }
0055
0056 std::vector<std::pair<char const*, std::type_index>> columnDescriptions() const final {
0057 std::vector<std::pair<char const*, std::type_index>> returnValue;
0058 returnValue.reserve(T::kNColumns);
0059 columnDescImpl<0, T::kNColumns>(returnValue);
0060 return returnValue;
0061 }
0062
0063 const std::type_info* typeID() const final { return &typeid(T); }
0064
0065 private:
0066 template <int I, int S>
0067 void columnTypesImpl(std::vector<std::type_index>& iV) const {
0068 if constexpr (I != S) {
0069 using Layout = typename T::Layout;
0070 iV.emplace_back(typeid(typename std::tuple_element<I, Layout>::type));
0071 columnTypesImpl<I + 1, S>(iV);
0072 }
0073 }
0074
0075 template <int I, int S>
0076 void columnDescImpl(std::vector<std::pair<char const*, std::type_index>>& iV) const {
0077 if constexpr (I != S) {
0078 using Layout = typename T::Layout;
0079 using ColumnType = typename std::tuple_element<I, Layout>::type;
0080 iV.emplace_back(ColumnType::label(), typeid(typename ColumnType::type));
0081 columnDescImpl<I + 1, S>(iV);
0082 }
0083 }
0084
0085
0086 T const* m_table;
0087 };
0088
0089 }
0090 }
0091
0092 #endif