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,
35  std::vector<void const*>& view,
37 
38  void setPtr(std::type_info const& iToType,
39  unsigned long iIndex,
40  void const*& oPtr) const;
41 
42  void fillPtrVector(std::type_info const& iToType,
43  std::vector<unsigned long> const& iIndicies,
44  std::vector<void const*>& oPtr) const;
45 
46  std::type_info const& dynamicTypeInfo() const {return dynamicTypeInfo_();}
47 
48  std::type_info const& wrappedTypeInfo() const {return wrappedTypeInfo_();}
49 
50  bool sameType(WrapperBase const& other) const {
51  return other.dynamicTypeInfo() == dynamicTypeInfo();
52  }
53 
54  bool isMergeable() const {return isMergeable_();}
55  bool mergeProduct(WrapperBase const* newProduct) {return mergeProduct_(newProduct);}
56  bool hasIsProductEqual() const {return hasIsProductEqual_();}
57  bool isProductEqual(WrapperBase const* newProduct) const {return isProductEqual_(newProduct);}
58  bool hasSwap() const {return hasSwap_();}
59  void swapProduct(WrapperBase* newProduct) {swapProduct_(newProduct);}
60 
61  std::shared_ptr<soa::TableExaminerBase> tableExaminer() const {
62  return tableExaminer_();
63  }
64  private:
65  virtual std::type_info const& dynamicTypeInfo_() const = 0;
66 
67  virtual std::type_info const& wrappedTypeInfo_() const = 0;
68 
69  // This will never be called.
70  // For technical ROOT related reasons, we cannot
71  // declare it = 0.
72  virtual bool isPresent_() const {return true;}
73 
74  virtual bool isMergeable_() const = 0;
75  virtual bool mergeProduct_(WrapperBase const* newProduct ) = 0;
76  virtual bool hasIsProductEqual_() const = 0;
77  virtual bool isProductEqual_(WrapperBase const* newProduct) const = 0;
78  virtual bool hasSwap_() const = 0;
79  virtual void swapProduct_(WrapperBase* newProduct) = 0;
80 
81  virtual void do_fillView(ProductID const& id,
82  std::vector<void const*>& pointers,
83  FillViewHelperVector & helpers) const = 0;
84  virtual void do_setPtr(std::type_info const& iToType,
85  unsigned long iIndex,
86  void const*& oPtr) const = 0;
87 
88  virtual void do_fillPtrVector(std::type_info const& iToType,
89  std::vector<unsigned long> const& iIndicies,
90  std::vector<void const*>& oPtr) const = 0;
91 
92  virtual std::shared_ptr<soa::TableExaminerBase> tableExaminer_() const = 0;
93 
94  };
95 }
96 #endif
bool mergeProduct(WrapperBase const *newProduct)
Definition: WrapperBase.h:55
std::type_info const & dynamicTypeInfo() const
Definition: WrapperBase.h:46
void fillPtrVector(std::vector< T, A > const &obj, std::type_info const &iToType, std::vector< unsigned long > const &iIndicies, std::vector< void const * > &oPtr)
Definition: fillPtrVector.h:85
std::shared_ptr< soa::TableExaminerBase > tableExaminer() const
Definition: WrapperBase.h:61
virtual bool isPresent_() const
Definition: WrapperBase.h:72
bool isPresent() const
Definition: WrapperBase.h:30
void setPtr(std::vector< T, A > const &obj, std::type_info const &iToType, unsigned long iIndex, void const *&oPtr)
Definition: setPtr.h:72
bool sameType(WrapperBase const &other) const
Definition: WrapperBase.h:50
void fillView(AssociationVector< KeyRefProd, CVal, KeyRef, SizeType, KeyReferenceHelper > const &obj, ProductID const &id, std::vector< void const * > &pointers, FillViewHelperVector &helpers)
bool hasSwap() const
Definition: WrapperBase.h:58
void swapProduct(WrapperBase *newProduct)
Definition: WrapperBase.h:59
std::type_info const & wrappedTypeInfo() const
Definition: WrapperBase.h:48
HLT enums.
bool isMergeable() const
Definition: WrapperBase.h:54
bool hasIsProductEqual() const
Definition: WrapperBase.h:56
std::vector< std::pair< edm::ProductID, unsigned long > > FillViewHelperVector
bool isProductEqual(WrapperBase const *newProduct) const
Definition: WrapperBase.h:57