File indexing completed on 2024-04-06 12:03:55
0001 #ifndef DataFormats_Common_WrapperBase_h
0002 #define DataFormats_Common_WrapperBase_h
0003
0004
0005
0006
0007
0008
0009
0010 #include "DataFormats/Common/interface/EDProductfwd.h"
0011 #include "DataFormats/Common/interface/FillViewHelperVector.h"
0012 #include "DataFormats/Provenance/interface/ViewTypeChecker.h"
0013
0014 #include <typeinfo>
0015 #include <vector>
0016 #include <memory>
0017
0018 namespace edm {
0019 namespace soa {
0020 class TableExaminerBase;
0021 }
0022
0023 class WrapperBase : public ViewTypeChecker {
0024 public:
0025
0026 struct Emplace {};
0027
0028 WrapperBase();
0029 ~WrapperBase() override;
0030 bool isPresent() const { return isPresent_(); }
0031
0032
0033
0034 void fillView(ProductID const& id, std::vector<void const*>& view, FillViewHelperVector& helpers) const;
0035
0036 void setPtr(std::type_info const& iToType, unsigned long iIndex, void const*& oPtr) const;
0037
0038 void fillPtrVector(std::type_info const& iToType,
0039 std::vector<unsigned long> const& iIndicies,
0040 std::vector<void const*>& oPtr) const;
0041
0042 std::type_info const& dynamicTypeInfo() const { return dynamicTypeInfo_(); }
0043
0044 std::type_info const& wrappedTypeInfo() const { return wrappedTypeInfo_(); }
0045
0046 bool sameType(WrapperBase const& other) const { return other.dynamicTypeInfo() == dynamicTypeInfo(); }
0047
0048 bool isMergeable() const { return isMergeable_(); }
0049 bool mergeProduct(WrapperBase const* newProduct) { return mergeProduct_(newProduct); }
0050 bool hasIsProductEqual() const { return hasIsProductEqual_(); }
0051 bool isProductEqual(WrapperBase const* newProduct) const { return isProductEqual_(newProduct); }
0052 bool hasSwap() const { return hasSwap_(); }
0053 void swapProduct(WrapperBase* newProduct) { swapProduct_(newProduct); }
0054
0055 std::shared_ptr<soa::TableExaminerBase> tableExaminer() const { return tableExaminer_(); }
0056
0057 private:
0058 virtual std::type_info const& dynamicTypeInfo_() const = 0;
0059
0060 virtual std::type_info const& wrappedTypeInfo_() const = 0;
0061
0062
0063
0064
0065 virtual bool isPresent_() const { return true; }
0066
0067 virtual bool isMergeable_() const = 0;
0068 virtual bool mergeProduct_(WrapperBase const* newProduct) = 0;
0069 virtual bool hasIsProductEqual_() const = 0;
0070 virtual bool isProductEqual_(WrapperBase const* newProduct) const = 0;
0071 virtual bool hasSwap_() const = 0;
0072 virtual void swapProduct_(WrapperBase* newProduct) = 0;
0073
0074 virtual void do_fillView(ProductID const& id,
0075 std::vector<void const*>& pointers,
0076 FillViewHelperVector& helpers) const = 0;
0077 virtual void do_setPtr(std::type_info const& iToType, unsigned long iIndex, void const*& oPtr) const = 0;
0078
0079 virtual void do_fillPtrVector(std::type_info const& iToType,
0080 std::vector<unsigned long> const& iIndicies,
0081 std::vector<void const*>& oPtr) const = 0;
0082
0083 virtual std::shared_ptr<soa::TableExaminerBase> tableExaminer_() const = 0;
0084 };
0085 }
0086 #endif