Go to the documentation of this file.00001 #ifndef DataFormats_Common_HolderToVectorTrait_h
00002 #define DataFormats_Common_HolderToVectorTrait_h
00003 #include "FWCore/Utilities/interface/EDMException.h"
00004 #include <memory>
00005
00006
00007 namespace edm {
00008 namespace reftobase {
00009 class RefVectorHolderBase;
00010 template <typename T> class BaseVectorHolder;
00011
00012 template <typename T, typename REF>
00013 struct InvalidHolderToVector {
00014 static std::auto_ptr<BaseVectorHolder<T> > makeVectorHolder() {
00015 Exception::throwThis(errors::InvalidReference,
00016 "InvalidHolderToVector: trying to use RefToBase built with "
00017 "an internal type. RefToBase should be built passing an "
00018 "object of type edm::Ref<C>. This exception should never "
00019 "be thrown if a RefToBase was built from a RefProd<C>.");
00020 return std::auto_ptr<BaseVectorHolder<T> >();
00021 }
00022 static std::auto_ptr<RefVectorHolderBase> makeVectorBaseHolder() {
00023 Exception::throwThis(errors::InvalidReference,
00024 "InvalidHolderToVector: trying to use RefToBase built with "
00025 "an internal type. RefToBase should be built passing an "
00026 "object of type edm::Ref<C>. This exception should never "
00027 "be thrown if a RefToBase was built from a RefProd<C>.");
00028 return std::auto_ptr<RefVectorHolderBase>();
00029 }
00030 };
00031
00032 template<typename T, typename REF>
00033 struct HolderToVectorTrait {
00034
00035 typedef InvalidHolderToVector<T, REF> type;
00036 };
00037
00038 template <typename REF>
00039 struct InvalidRefHolderToRefVector {
00040 static std::auto_ptr<RefVectorHolderBase> makeVectorHolder() {
00041 Exception::throwThis(errors::InvalidReference,
00042 "InvalidRefHolderToRefVector: trying to use RefToBaseVector built with "
00043 "an internal type. RefToBase should be built passing an "
00044 "object of type edm::RefVector<C>");
00045 return std::auto_ptr<RefVectorHolderBase>();
00046 }
00047 static std::auto_ptr<RefVectorHolderBase> makeVectorBaseHolder() {
00048 Exception::throwThis(errors::InvalidReference,
00049 "InvalidRefHolderToRefVector: trying to use RefToBaseVector built with "
00050 "an internal type. RefToBase should be built passing an "
00051 "object of type edm::RefVector<C>");
00052 return std::auto_ptr<RefVectorHolderBase>();
00053 }
00054 };
00055
00056 template<typename REF>
00057 struct RefHolderToRefVectorTrait {
00058
00059 typedef InvalidRefHolderToRefVector<REF> type;
00060 };
00061
00062 }
00063 }
00064
00065 #endif