CMS 3D CMS Logo

RefToPtr.h

Go to the documentation of this file.
00001 #ifndef DataFormats_Common_RefToPtr_h
00002 #define DataFormats_Common_RefToPtr_h
00003 
00004 /*----------------------------------------------------------------------
00005   
00006 Ref: A function template for conversion from Ref to Ptr
00007 
00008 ----------------------------------------------------------------------*/
00009 /*
00010     ----------------------------------------------------------------------*/ 
00011 
00012 #include "DataFormats/Common/interface/Ref.h"
00013 #include "DataFormats/Common/interface/RefTraits.h"
00014 #include "DataFormats/Common/interface/Ptr.h"
00015 
00016 namespace edm {
00017   template <typename C>
00018   Ptr<typename C::value_type> refToPtr(
00019     Ref<C, typename C::value_type, refhelper::FindUsingAdvance<C, typename C::value_type> > const& ref) {
00020     typedef typename C::value_type T;
00021     if (ref.isTransient()) {
00022       return Ptr<T>(ref.product(), ref.key());
00023     } else if (ref.get() == 0 && ref.productGetter() != 0) {
00024       return Ptr<T>(ref.id(), ref.key(), ref.productGetter());
00025     }
00026     return Ptr<T>(ref.id(), ref.get(), ref.key());
00027   }
00028 }
00029 #endif

Generated on Tue Jun 9 17:29:58 2009 for CMSSW by  doxygen 1.5.4