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
bool mergeProduct(WrapperBase const *newProduct)
Definition: WrapperBase.h:49
virtual bool hasSwap_() const =0
bool hasSwap() const
Definition: WrapperBase.h:52
void setPtr(std::type_info const &iToType, unsigned long iIndex, void const *&oPtr) const
Definition: WrapperBase.cc:27
virtual bool isPresent_() const
Definition: WrapperBase.h:65
bool sameType(WrapperBase const &other) const
Definition: WrapperBase.h:46
bool isMergeable() const
Definition: WrapperBase.h:48
virtual bool mergeProduct_(WrapperBase const *newProduct)=0
bool hasIsProductEqual() const
Definition: WrapperBase.h:50
virtual std::shared_ptr< soa::TableExaminerBase > tableExaminer_() const =0
virtual void do_setPtr(std::type_info const &iToType, unsigned long iIndex, void const *&oPtr) const =0
void fillPtrVector(std::type_info const &iToType, std::vector< unsigned long > const &iIndicies, std::vector< void const *> &oPtr) const
Definition: WrapperBase.cc:31
void fillView(ProductID const &id, std::vector< void const *> &view, FillViewHelperVector &helpers) const
Definition: WrapperBase.cc:14
virtual void do_fillView(ProductID const &id, std::vector< void const *> &pointers, FillViewHelperVector &helpers) const =0
virtual bool isMergeable_() const =0
~WrapperBase() override
Definition: WrapperBase.cc:12
bool isProductEqual(WrapperBase const *newProduct) const
Definition: WrapperBase.h:51
std::type_info const & dynamicTypeInfo() const
Definition: WrapperBase.h:42
virtual bool isProductEqual_(WrapperBase const *newProduct) const =0
ZVertexSoA * soa
virtual std::type_info const & wrappedTypeInfo_() const =0
virtual void do_fillPtrVector(std::type_info const &iToType, std::vector< unsigned long > const &iIndicies, std::vector< void const *> &oPtr) const =0
void swapProduct(WrapperBase *newProduct)
Definition: WrapperBase.h:53
bool isPresent() const
Definition: WrapperBase.h:30
virtual void swapProduct_(WrapperBase *newProduct)=0
HLT enums.
virtual std::type_info const & dynamicTypeInfo_() const =0
std::type_info const & wrappedTypeInfo() const
Definition: WrapperBase.h:44
std::shared_ptr< soa::TableExaminerBase > tableExaminer() const
Definition: WrapperBase.h:55
virtual bool hasIsProductEqual_() const =0
std::vector< std::pair< edm::ProductID, unsigned long > > FillViewHelperVector