CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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,
28  FillViewHelperVector& helpers) const;
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 #ifndef __GCCXML__
47  bool isMergeable() const {return isMergeable_();}
48  bool mergeProduct(WrapperBase const* newProduct) {return mergeProduct_(newProduct);}
49  bool hasIsProductEqual() const {return hasIsProductEqual_();}
50  bool isProductEqual(WrapperBase const* newProduct) const {return isProductEqual_(newProduct);}
51 #endif
52 
53  private:
54  virtual std::type_info const& dynamicTypeInfo_() const = 0;
55 
56  virtual std::type_info const& wrappedTypeInfo_() const = 0;
57 
58  // This will never be called.
59  // For technical ROOT related reasons, we cannot
60  // declare it = 0.
61  virtual bool isPresent_() const {return true;}
62 
63 #ifndef __GCCXML__
64  virtual bool isMergeable_() const = 0;
65  virtual bool mergeProduct_(WrapperBase const* newProduct ) = 0;
66  virtual bool hasIsProductEqual_() const = 0;
67  virtual bool isProductEqual_(WrapperBase const* newProduct) const = 0;
68 #endif
69 
70  virtual void do_fillView(ProductID const& id,
71  std::vector<void const*>& pointers,
72  FillViewHelperVector & helpers) const = 0;
73  virtual void do_setPtr(std::type_info const& iToType,
74  unsigned long iIndex,
75  void const*& oPtr) const = 0;
76 
77  virtual void do_fillPtrVector(std::type_info const& iToType,
78  std::vector<unsigned long> const& iIndicies,
79  std::vector<void const*>& oPtr) const = 0;
80  };
81 }
82 #endif
bool mergeProduct(WrapperBase const *newProduct)
Definition: WrapperBase.h:48
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_fillPtrVector(std::type_info const &iToType, std::vector< unsigned long > const &iIndicies, std::vector< void const * > &oPtr) const =0
virtual bool mergeProduct_(WrapperBase const *newProduct)=0
virtual void do_setPtr(std::type_info const &iToType, unsigned long iIndex, void const *&oPtr) const =0
virtual bool isPresent_() const
Definition: WrapperBase.h:61
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 & wrappedTypeInfo_() const =0
virtual void do_fillView(ProductID const &id, std::vector< void const * > &pointers, FillViewHelperVector &helpers) 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 std::type_info const & dynamicTypeInfo_() const =0
bool isMergeable() const
Definition: WrapperBase.h:47
bool hasIsProductEqual() const
Definition: WrapperBase.h:49
std::vector< std::pair< edm::ProductID, unsigned long > > FillViewHelperVector
bool isProductEqual(WrapperBase const *newProduct) const
Definition: WrapperBase.h:50
virtual bool hasIsProductEqual_() const =0