Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:52:59

0001 #ifndef DataFormats_Common_HolderToVectorTrait_h
0002 #define DataFormats_Common_HolderToVectorTrait_h
0003 #include "FWCore/Utilities/interface/EDMException.h"
0004 #include <memory>
0005 
0006 namespace edm {
0007   namespace reftobase {
0008     class RefVectorHolderBase;
0009     template <typename T>
0010     class BaseVectorHolder;
0011 
0012     template <typename T, typename REF>
0013     struct InvalidHolderToVector {
0014       static std::unique_ptr<BaseVectorHolder<T> > makeVectorHolder() {
0015         Exception::throwThis(errors::InvalidReference,
0016                              "InvalidHolderToVector: trying to use RefToBase built with "
0017                              "an internal type. RefToBase should be built passing an "
0018                              "object of type edm::Ref<C>. This exception should never "
0019                              "be thrown if a RefToBase was built from a RefProd<C>.");
0020         return std::unique_ptr<BaseVectorHolder<T> >();
0021       }
0022     };
0023 
0024     template <typename T, typename REF>
0025     struct HolderToVectorTrait {
0026       //      static_assert(sizeof(REF) == 0);
0027       typedef InvalidHolderToVector<T, REF> type;
0028     };
0029 
0030     template <typename REF>
0031     struct InvalidRefHolderToRefVector {
0032       static std::unique_ptr<RefVectorHolderBase> makeVectorHolder() {
0033         Exception::throwThis(errors::InvalidReference,
0034                              "InvalidRefHolderToRefVector: trying to use RefToBaseVector built with "
0035                              "an internal type. RefToBase should be built passing an "
0036                              "object of type edm::RefVector<C>");
0037         return std::unique_ptr<RefVectorHolderBase>();
0038       }
0039     };
0040 
0041     template <typename REF>
0042     struct RefHolderToRefVectorTrait {
0043       //      static_assert(sizeof(REF) == 0);
0044       typedef InvalidRefHolderToRefVector<REF> type;
0045     };
0046 
0047   }  // namespace reftobase
0048 }  // namespace edm
0049 
0050 //Handle specialization here
0051 #include "DataFormats/Common/interface/HolderToVectorTrait_Ref_specialization.h"
0052 #include "DataFormats/Common/interface/HolderToVectorTrait_Ptr_specialization.h"
0053 #include "DataFormats/Common/interface/HolderToVectorTrait_RefProd_specialization.h"
0054 
0055 #endif