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 
17 namespace edm {
18  class WrapperBase : public ViewTypeChecker {
19  public:
20  WrapperBase();
21  virtual ~WrapperBase();
22  bool isPresent() const {return isPresent_();}
23 
24  // We have to use vector<void*> to keep the type information out
25  // of the WrapperBase class.
26  void fillView(ProductID const& id,
27  std::vector<void const*>& view,
29 
30  void setPtr(std::type_info const& iToType,
31  unsigned long iIndex,
32  void const*& oPtr) const;
33 
34  void fillPtrVector(std::type_info const& iToType,
35  std::vector<unsigned long> const& iIndicies,
36  std::vector<void const*>& oPtr) const;
37 
38  std::type_info const& dynamicTypeInfo() const {return dynamicTypeInfo_();}
39 
40  std::type_info const& wrappedTypeInfo() const {return wrappedTypeInfo_();}
41 
42  bool sameType(WrapperBase const& other) const {
43  return other.dynamicTypeInfo() == dynamicTypeInfo();
44  }
45 
46  bool isMergeable() const {return isMergeable_();}
47  bool mergeProduct(WrapperBase const* newProduct) {return mergeProduct_(newProduct);}
48  bool hasIsProductEqual() const {return hasIsProductEqual_();}
49  bool isProductEqual(WrapperBase const* newProduct) const {return isProductEqual_(newProduct);}
50 
51  private:
52  virtual std::type_info const& dynamicTypeInfo_() const = 0;
53 
54  virtual std::type_info const& wrappedTypeInfo_() const = 0;
55 
56  // This will never be called.
57  // For technical ROOT related reasons, we cannot
58  // declare it = 0.
59  virtual bool isPresent_() const {return true;}
60 
61  virtual bool isMergeable_() const = 0;
62  virtual bool mergeProduct_(WrapperBase const* newProduct ) = 0;
63  virtual bool hasIsProductEqual_() const = 0;
64  virtual bool isProductEqual_(WrapperBase const* newProduct) const = 0;
65 
66  virtual void do_fillView(ProductID const& id,
67  std::vector<void const*>& pointers,
68  FillViewHelperVector & helpers) const = 0;
69  virtual void do_setPtr(std::type_info const& iToType,
70  unsigned long iIndex,
71  void const*& oPtr) const = 0;
72 
73  virtual void do_fillPtrVector(std::type_info const& iToType,
74  std::vector<unsigned long> const& iIndicies,
75  std::vector<void const*>& oPtr) const = 0;
76  };
77 }
78 #endif
bool mergeProduct(WrapperBase const *newProduct)
Definition: WrapperBase.h:47
virtual void do_fillView(ProductID const &id, std::vector< void const * > &pointers, FillViewHelperVector &helpers) const =0
std::type_info const & dynamicTypeInfo() const
Definition: WrapperBase.h:38
void setPtr(std::type_info const &iToType, unsigned long iIndex, void const *&oPtr) const
Definition: WrapperBase.cc:27
virtual void do_setPtr(std::type_info const &iToType, unsigned long iIndex, void const *&oPtr) const =0
virtual bool hasIsProductEqual_() const =0
virtual bool mergeProduct_(WrapperBase const *newProduct)=0
virtual bool isPresent_() const
Definition: WrapperBase.h:59
virtual ~WrapperBase()
Definition: WrapperBase.cc:12
void fillView(ProductID const &id, std::vector< void const * > &view, FillViewHelperVector &helpers) const
Definition: WrapperBase.cc:14
bool isPresent() const
Definition: WrapperBase.h:22
virtual bool isMergeable_() const =0
bool sameType(WrapperBase const &other) const
Definition: WrapperBase.h:42
virtual bool isProductEqual_(WrapperBase const *newProduct) const =0
virtual std::type_info const & dynamicTypeInfo_() const =0
virtual std::type_info const & wrappedTypeInfo_() const =0
void fillPtrVector(std::type_info const &iToType, std::vector< unsigned long > const &iIndicies, std::vector< void const * > &oPtr) const
Definition: WrapperBase.cc:34
std::type_info const & wrappedTypeInfo() const
Definition: WrapperBase.h:40
virtual void do_fillPtrVector(std::type_info const &iToType, std::vector< unsigned long > const &iIndicies, std::vector< void const * > &oPtr) const =0
HLT enums.
bool isMergeable() const
Definition: WrapperBase.h:46
bool hasIsProductEqual() const
Definition: WrapperBase.h:48
std::vector< std::pair< edm::ProductID, unsigned long > > FillViewHelperVector
bool isProductEqual(WrapperBase const *newProduct) const
Definition: WrapperBase.h:49