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 
11 
12 #include <typeinfo>
13 #include <vector>
14 
15 namespace edm {
16  class WrapperBase {
17  public:
18  WrapperBase();
19  virtual ~WrapperBase();
20  bool isPresent() const {return isPresent_();}
21 
22  // We have to use vector<void*> to keep the type information out
23  // of the WrapperBase class.
24  void fillView(ProductID const& id,
25  std::vector<void const*>& view,
26  helper_vector_ptr& helpers) const;
27 
28  void setPtr(std::type_info const& iToType,
29  unsigned long iIndex,
30  void const*& oPtr) const;
31 
32  void fillPtrVector(std::type_info const& iToType,
33  std::vector<unsigned long> const& iIndicies,
34  std::vector<void const*>& oPtr) const;
35 
36  std::type_info const& dynamicTypeInfo() const {return dynamicTypeInfo_();}
37 
38  std::type_info const& wrappedTypeInfo() const {return wrappedTypeInfo_();}
39 
40  bool sameType(WrapperBase const& other) const {
41  return other.dynamicTypeInfo() == dynamicTypeInfo();
42  }
43 
44 #ifndef __GCCXML__
45  bool isMergeable() const {return isMergeable_();}
46  bool mergeProduct(WrapperBase const* newProduct) {return mergeProduct_(newProduct);}
47  bool hasIsProductEqual() const {return hasIsProductEqual_();}
48  bool isProductEqual(WrapperBase const* newProduct) const {return isProductEqual_(newProduct);}
49 #endif
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 #ifndef __GCCXML__
62  virtual bool isMergeable_() const { return true; }
63  virtual bool mergeProduct_(WrapperBase const* newProduct) { return true; }
64  virtual bool hasIsProductEqual_() const { return true; }
65  virtual bool isProductEqual_(WrapperBase const* newProduct) const { return true; }
66 #endif
67 
68  virtual void do_fillView(ProductID const& id,
69  std::vector<void const*>& pointers,
70  helper_vector_ptr & helpers) const = 0;
71  virtual void do_setPtr(std::type_info const& iToType,
72  unsigned long iIndex,
73  void const*& oPtr) const = 0;
74 
75  virtual void do_fillPtrVector(std::type_info const& iToType,
76  std::vector<unsigned long> const& iIndicies,
77  std::vector<void const*>& oPtr) const = 0;
78  };
79 }
80 #endif
virtual bool isMergeable_() const
Definition: WrapperBase.h:62
bool mergeProduct(WrapperBase const *newProduct)
Definition: WrapperBase.h:46
std::type_info const & dynamicTypeInfo() const
Definition: WrapperBase.h:36
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 void do_setPtr(std::type_info const &iToType, unsigned long iIndex, void const *&oPtr) const =0
virtual bool isPresent_() const
Definition: WrapperBase.h:59
virtual ~WrapperBase()
Definition: WrapperBase.cc:12
bool isPresent() const
Definition: WrapperBase.h:20
bool sameType(WrapperBase const &other) const
Definition: WrapperBase.h:40
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::shared_ptr< reftobase::RefVectorHolderBase > helper_vector_ptr
Definition: EDProductfwd.h:47
virtual bool isProductEqual_(WrapperBase const *newProduct) const
Definition: WrapperBase.h:65
virtual void do_fillView(ProductID const &id, std::vector< void const * > &pointers, helper_vector_ptr &helpers) const =0
std::type_info const & wrappedTypeInfo() const
Definition: WrapperBase.h:38
virtual bool mergeProduct_(WrapperBase const *newProduct)
Definition: WrapperBase.h:63
void fillView(ProductID const &id, std::vector< void const * > &view, helper_vector_ptr &helpers) const
Definition: WrapperBase.cc:14
virtual bool hasIsProductEqual_() const
Definition: WrapperBase.h:64
virtual std::type_info const & dynamicTypeInfo_() const =0
bool isMergeable() const
Definition: WrapperBase.h:45
bool hasIsProductEqual() const
Definition: WrapperBase.h:47
bool isProductEqual(WrapperBase const *newProduct) const
Definition: WrapperBase.h:48