CMS 3D CMS Logo

WrapperBase.h
Go to the documentation of this file.
1 #ifndef DataFormats_Common_WrapperBase_h
2 #define DataFormats_Common_WrapperBase_h
3 
4 /*----------------------------------------------------------------------
5 
6 WrapperBase: The base class of all things that will be inserted into the Event.
7 
8 ----------------------------------------------------------------------*/
9 
13 
14 #include <typeinfo>
15 #include <vector>
16 #include <memory>
17 
18 namespace edm {
19  namespace soa {
20  class TableExaminerBase;
21  }
22 
23  class WrapperBase : public ViewTypeChecker {
24  public:
25  //used by inheriting classes to force construction via emplace
26  struct Emplace {};
27 
28  WrapperBase();
29  ~WrapperBase() override;
30  bool isPresent() const { return isPresent_(); }
31 
32  // We have to use vector<void*> to keep the type information out
33  // of the WrapperBase class.
34  void fillView(ProductID const& id, std::vector<void const*>& view, FillViewHelperVector& helpers) const;
35 
36  void setPtr(std::type_info const& iToType, unsigned long iIndex, void const*& oPtr) const;
37 
38  void fillPtrVector(std::type_info const& iToType,
39  std::vector<unsigned long> const& iIndicies,
40  std::vector<void const*>& oPtr) const;
41 
42  std::type_info const& dynamicTypeInfo() const { return dynamicTypeInfo_(); }
43 
44  std::type_info const& wrappedTypeInfo() const { return wrappedTypeInfo_(); }
45 
46  bool sameType(WrapperBase const& other) const { return other.dynamicTypeInfo() == dynamicTypeInfo(); }
47 
48  bool isMergeable() const { return isMergeable_(); }
49  bool mergeProduct(WrapperBase const* newProduct) { return mergeProduct_(newProduct); }
50  bool hasIsProductEqual() const { return hasIsProductEqual_(); }
51  bool isProductEqual(WrapperBase const* newProduct) const { return isProductEqual_(newProduct); }
52  bool hasSwap() const { return hasSwap_(); }
53  void swapProduct(WrapperBase* newProduct) { swapProduct_(newProduct); }
54 
55  std::shared_ptr<soa::TableExaminerBase> tableExaminer() const { return tableExaminer_(); }
56 
57  private:
58  virtual std::type_info const& dynamicTypeInfo_() const = 0;
59 
60  virtual std::type_info const& wrappedTypeInfo_() const = 0;
61 
62  // This will never be called.
63  // For technical ROOT related reasons, we cannot
64  // declare it = 0.
65  virtual bool isPresent_() const { return true; }
66 
67  virtual bool isMergeable_() const = 0;
68  virtual bool mergeProduct_(WrapperBase const* newProduct) = 0;
69  virtual bool hasIsProductEqual_() const = 0;
70  virtual bool isProductEqual_(WrapperBase const* newProduct) const = 0;
71  virtual bool hasSwap_() const = 0;
72  virtual void swapProduct_(WrapperBase* newProduct) = 0;
73 
74  virtual void do_fillView(ProductID const& id,
75  std::vector<void const*>& pointers,
76  FillViewHelperVector& helpers) const = 0;
77  virtual void do_setPtr(std::type_info const& iToType, unsigned long iIndex, void const*& oPtr) const = 0;
78 
79  virtual void do_fillPtrVector(std::type_info const& iToType,
80  std::vector<unsigned long> const& iIndicies,
81  std::vector<void const*>& oPtr) const = 0;
82 
83  virtual std::shared_ptr<soa::TableExaminerBase> tableExaminer_() const = 0;
84  };
85 } // namespace edm
86 #endif
edm::FillViewHelperVector
std::vector< std::pair< edm::ProductID, unsigned long > > FillViewHelperVector
Definition: FillViewHelperVector.h:30
edm::WrapperBase::isMergeable
bool isMergeable() const
Definition: WrapperBase.h:48
edm::WrapperBase::do_setPtr
virtual void do_setPtr(std::type_info const &iToType, unsigned long iIndex, void const *&oPtr) const =0
edm::WrapperBase::hasIsProductEqual
bool hasIsProductEqual() const
Definition: WrapperBase.h:50
edm
HLT enums.
Definition: AlignableModifier.h:19
edm::WrapperBase::hasSwap_
virtual bool hasSwap_() const =0
edm::ViewTypeChecker
Definition: ViewTypeChecker.h:13
edm::WrapperBase::fillPtrVector
void fillPtrVector(std::type_info const &iToType, std::vector< unsigned long > const &iIndicies, std::vector< void const * > &oPtr) const
Definition: WrapperBase.cc:31
edm::WrapperBase::do_fillPtrVector
virtual void do_fillPtrVector(std::type_info const &iToType, std::vector< unsigned long > const &iIndicies, std::vector< void const * > &oPtr) const =0
edm::WrapperBase::isMergeable_
virtual bool isMergeable_() const =0
edm::WrapperBase::tableExaminer_
virtual std::shared_ptr< soa::TableExaminerBase > tableExaminer_() const =0
FillViewHelperVector.h
ViewTypeChecker.h
edm::WrapperBase::isProductEqual
bool isProductEqual(WrapperBase const *newProduct) const
Definition: WrapperBase.h:51
edm::WrapperBase::wrappedTypeInfo_
virtual std::type_info const & wrappedTypeInfo_() const =0
trackingPlots.other
other
Definition: trackingPlots.py:1467
edm::WrapperBase::tableExaminer
std::shared_ptr< soa::TableExaminerBase > tableExaminer() const
Definition: WrapperBase.h:55
edm::WrapperBase::hasIsProductEqual_
virtual bool hasIsProductEqual_() const =0
edm::WrapperBase::hasSwap
bool hasSwap() const
Definition: WrapperBase.h:52
edm::WrapperBase::setPtr
void setPtr(std::type_info const &iToType, unsigned long iIndex, void const *&oPtr) const
Definition: WrapperBase.cc:27
edm::WrapperBase::dynamicTypeInfo
std::type_info const & dynamicTypeInfo() const
Definition: WrapperBase.h:42
helpers
Definition: makeCompositeCandidate.h:8
TableExaminerBase
edm::WrapperBase::sameType
bool sameType(WrapperBase const &other) const
Definition: WrapperBase.h:46
edm::WrapperBase
Definition: WrapperBase.h:23
edm::WrapperBase::mergeProduct_
virtual bool mergeProduct_(WrapperBase const *newProduct)=0
edm::WrapperBase::WrapperBase
WrapperBase()
Definition: WrapperBase.cc:10
edm::WrapperBase::isPresent
bool isPresent() const
Definition: WrapperBase.h:30
edm::WrapperBase::swapProduct
void swapProduct(WrapperBase *newProduct)
Definition: WrapperBase.h:53
edm::WrapperBase::~WrapperBase
~WrapperBase() override
Definition: WrapperBase.cc:12
edm::WrapperBase::swapProduct_
virtual void swapProduct_(WrapperBase *newProduct)=0
edm::WrapperBase::isProductEqual_
virtual bool isProductEqual_(WrapperBase const *newProduct) const =0
edm::WrapperBase::mergeProduct
bool mergeProduct(WrapperBase const *newProduct)
Definition: WrapperBase.h:49
edm::WrapperBase::do_fillView
virtual void do_fillView(ProductID const &id, std::vector< void const * > &pointers, FillViewHelperVector &helpers) const =0
edm::WrapperBase::isPresent_
virtual bool isPresent_() const
Definition: WrapperBase.h:65
EDProductfwd.h
edm::ProductID
Definition: ProductID.h:27
edm::WrapperBase::dynamicTypeInfo_
virtual std::type_info const & dynamicTypeInfo_() const =0
edm::WrapperBase::wrappedTypeInfo
std::type_info const & wrappedTypeInfo() const
Definition: WrapperBase.h:44
edm::WrapperBase::fillView
void fillView(ProductID const &id, std::vector< void const * > &view, FillViewHelperVector &helpers) const
Definition: WrapperBase.cc:14
edm::WrapperBase::Emplace
Definition: WrapperBase.h:26