CMS 3D CMS Logo

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

Go to the documentation of this file.
00001 #ifndef DataFormats_Common_WrapperHolder_h
00002 #define DataFormats_Common_WrapperHolder_h
00003 
00004 /*----------------------------------------------------------------------
00005 
00006 ----------------------------------------------------------------------*/
00007 
00008 #include "DataFormats/Common/interface/EDProductfwd.h"
00009 #include "DataFormats/Provenance/interface/WrapperInterfaceBase.h"
00010 
00011 #include <typeinfo>
00012 #include <vector>
00013 
00014 namespace edm {
00015   class WrapperHolder {
00016   public:
00017     struct EDProductDeleter {
00018       explicit EDProductDeleter(WrapperInterfaceBase const* interface);
00019       void operator()(void const* wrapper) const;
00020       WrapperInterfaceBase const* interface_;
00021     };
00022 
00023     WrapperHolder();
00024 
00025     WrapperHolder(void const* wrapper, WrapperInterfaceBase const* interface);
00026 
00027     bool isValid() const {
00028       return wrapper_ != 0 && interface_ != 0;
00029     }
00030 
00031     void fillView(ProductID const& id,
00032                   std::vector<void const*>& view,
00033                   helper_vector_ptr& helpers) const {
00034       interface_->fillView(wrapper(), id, view, helpers);
00035     }
00036 
00037     void setPtr(std::type_info const& iToType,
00038                 unsigned long iIndex,
00039                 void const*& oPtr) const {
00040       interface_->setPtr(wrapper(), iToType, iIndex, oPtr);
00041     }
00042 
00043     void fillPtrVector(std::type_info const& iToType,
00044                        std::vector<unsigned long> const& iIndicies,
00045                        std::vector<void const*>& oPtr) const {
00046       interface_->fillPtrVector(wrapper(), iToType, iIndicies, oPtr);
00047     }
00048 
00049     bool isMergeable() const {
00050       return interface_->isMergeable(wrapper());
00051     }
00052 
00053     bool hasIsProductEqual() const {
00054       return interface_->hasIsProductEqual(wrapper());
00055     }
00056 
00057     bool mergeProduct(void const* newProduct) {
00058       return interface_->mergeProduct(const_cast<void *>(wrapper()), newProduct);}
00059 
00060     bool isProductEqual(void const* newProduct) const {
00061       return interface_->isProductEqual(wrapper(), newProduct);
00062     }
00063 
00064     bool isPresent() const {
00065       return interface_->isPresent(wrapper());
00066     }
00067 
00068     std::type_info const& dynamicTypeInfo() const {
00069       return interface_->dynamicTypeInfo();
00070     }
00071 
00072     std::type_info const& wrappedTypeInfo() const {
00073       return interface_->wrappedTypeInfo();
00074     }
00075 
00076     void const* wrapper() const {
00077       return wrapper_;
00078     }
00079 
00080     WrapperInterfaceBase const* interface() const {
00081       return interface_;
00082     }
00083 
00084     void reset() {
00085       interface_ = 0;
00086       wrapper_ = 0;
00087     }
00088 
00089   private:  
00090     void const* wrapper_;
00091     WrapperInterfaceBase const* interface_;
00092   };
00093 
00094 }
00095 #endif