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