CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_7/src/DataFormats/Common/interface/WrapperInterface.h

Go to the documentation of this file.
00001 #ifndef DataFormats_Common_WrapperInterface_h
00002 #define DataFormats_Common_WrapperInterface_h
00003 
00004 /*----------------------------------------------------------------------
00005 
00006 WrapperInterface: 
00007 
00008 ----------------------------------------------------------------------*/
00009 
00010 #include "DataFormats/Provenance/interface/WrapperInterfaceBase.h"
00011 #include "DataFormats/Common/interface/Wrapper.h"
00012 
00013 #include "boost/utility.hpp"
00014 #include <vector>
00015 
00016 namespace edm {
00017 
00018   template <typename T>
00019   class WrapperInterface : public WrapperInterfaceBase, private boost::noncopyable {
00020   public:
00021     typedef T value_type;
00022     typedef T wrapped_type;
00023 
00024     WrapperInterface() : WrapperInterfaceBase() {}
00025     virtual ~WrapperInterface() {}
00026 
00027     //these are used by FWLite
00028     static std::type_info const& productTypeInfo() {return typeid(T);}
00029     static std::type_info const& typeInfo() {return typeid(Wrapper<T>);}
00030 
00031   private:
00032     static Wrapper<T> const* typeCast(void const* me) {
00033       return static_cast<Wrapper<T> const*>(me);
00034     }
00035 
00036     static Wrapper<T>* typeCast(void* me) {
00037       return static_cast<Wrapper<T>*>(me);
00038     }
00039 
00040     virtual void deleteProduct_(void const* me) const {
00041       delete typeCast(me);
00042     }
00043 
00044     virtual void do_fillView(void const* me,
00045                              ProductID const& id,
00046                              std::vector<void const*>& pointers,
00047                              helper_vector_ptr& helpers) const {
00048       
00049       typeCast(me)->fillView(id, pointers, helpers);
00050     }
00051     virtual void do_setPtr(void const* me,
00052                            std::type_info const& iToType,
00053                            unsigned long iIndex,
00054                            void const*& oPtr) const {
00055       typeCast(me)->setPtr(iToType, iIndex, oPtr);
00056     }
00057 
00058     virtual void do_fillPtrVector(void const* me,
00059                                   std::type_info const& iToType,
00060                                   std::vector<unsigned long> const& iIndicies,
00061                                   std::vector<void const*>& oPtr) const {
00062       typeCast(me)->fillPtrVector(iToType, iIndicies, oPtr);
00063     }
00064 
00065     virtual bool isMergeable_(void const* me) const {
00066       return typeCast(me)->isMergeable();
00067     }
00068 
00069     virtual bool hasIsProductEqual_(void const* me) const {
00070       return typeCast(me)->hasIsProductEqual();
00071     }
00072 
00073     virtual bool mergeProduct_(void* me, void const* newProduct) const {
00074       return typeCast(me)->mergeProduct(typeCast(newProduct));
00075     }
00076 
00077     virtual bool isProductEqual_(void const* me, void const* newProduct) const {
00078       return typeCast(me)->isProductEqual(typeCast(newProduct));
00079     }
00080 
00081     virtual std::type_info const& dynamicTypeInfo_() const {
00082       return typeid(T);
00083     }
00084 
00085     virtual std::type_info const& wrappedTypeInfo_() const {
00086       return typeid(Wrapper<T>);
00087     }
00088 
00089     virtual bool isPresent_(void const* me) const {
00090       return typeCast(me)->isPresent();
00091     }
00092   };
00093 } //namespace edm
00094 
00095 #endif