File indexing completed on 2024-04-06 12:03:54
0001 #ifndef DataFormats_Common_RefToPtr_h
0002 #define DataFormats_Common_RefToPtr_h
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 #include "DataFormats/Common/interface/Ref.h"
0013 #include "DataFormats/Common/interface/RefTraits.h"
0014 #include "DataFormats/Common/interface/Ptr.h"
0015
0016 namespace edm {
0017 template <typename C>
0018 Ptr<typename C::value_type> refToPtr(
0019 Ref<C, typename C::value_type, refhelper::FindUsingAdvance<C, typename C::value_type> > const& ref) {
0020 typedef typename C::value_type T;
0021 if (ref.isNull()) {
0022 return Ptr<T>();
0023 }
0024 if (ref.isTransient()) {
0025 return Ptr<T>(ref.get(), ref.key());
0026 } else {
0027
0028 EDProductGetter const* getter = ref.productGetter();
0029 if (getter) {
0030 return Ptr<T>(ref.id(), ref.key(), getter);
0031 }
0032 }
0033 return Ptr<T>(ref.id(), ref.get(), ref.key());
0034 }
0035 }
0036 #endif