Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:50:11

0001 #ifndef CommonTools_UtilAlgos_FwdPtrConversionFactory_h
0002 #define CommonTools_UtilAlgos_FwdPtrConversionFactory_h
0003 
0004 /**
0005   \class    "CommonTools/UtilAlgos/interface/FwdPtrConversionFactory.h"
0006   \brief    Converts back and forth from FwdPtr to instances. 
0007 
0008 
0009   \author   Salvatore Rappoccio
0010 */
0011 
0012 #include "DataFormats/Common/interface/FwdPtr.h"
0013 #include "DataFormats/Common/interface/RefToBaseVector.h"
0014 
0015 namespace edm {
0016   /// Factory class template for how to produce products
0017   /// from a FwdPtr. This particular example is for copy
0018   /// construction, but the same signature can be used elsewhere.
0019   template <class T>
0020   struct ProductFromFwdPtrFactory {
0021     T operator()(edm::FwdPtr<T> const &r) const { return T(*r); }
0022   };
0023 
0024   /// Factory class template for how to produce FwdPtrs
0025   /// from a View.
0026   template <class T>
0027   struct FwdPtrFromProductFactory {
0028     edm::FwdPtr<T> operator()(edm::View<T> const &view, unsigned int i) const {
0029       return edm::FwdPtr<T>(view.ptrAt(i), view.ptrAt(i));
0030     }
0031   };
0032 
0033 }  // namespace edm
0034 
0035 #endif