Go to the documentation of this file.00001 #ifndef DataFormats_Common_RefCoreGet_h
00002 #define DataFormats_Common_RefCoreGet_h
00003
00004
00005
00006
00007
00008
00009
00010 #include "DataFormats/Common/interface/RefCore.h"
00011 #include "DataFormats/Common/interface/EDProduct.h"
00012 #include "DataFormats/Common/interface/Wrapper.h"
00013
00014 namespace edm {
00015
00016 namespace refcore {
00017 template <typename T>
00018 inline
00019 T const*
00020 getProductPtr_(RefCore const& ref) {
00021
00022 assert (!ref.isTransient());
00023 EDProduct const* product = ref.getProductPtr(typeid(T));
00024 Wrapper<T> const* wrapper = dynamic_cast<Wrapper<T> const*>(product);
00025
00026 if (wrapper == 0) {
00027 ref.wrongTypeException(typeid(T), typeid(*product));
00028 }
00029 ref.setProductPtr(wrapper->product());
00030 return wrapper->product();
00031 }
00032 }
00033
00034 template <typename T>
00035 inline
00036 T const*
00037 getProduct(RefCore const & ref) {
00038 T const* p = static_cast<T const *>(ref.productPtr());
00039 if (p != 0) return p;
00040 if (ref.isTransient()) {
00041 ref.nullPointerForTransientException(typeid(T));
00042 }
00043 return refcore::getProductPtr_<T>(ref);
00044 }
00045 }
00046 #endif