Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:03:52

0001 #ifdef DataFormats_Common_HolderToVectorTrait_h
0002 #ifdef DataFormats_Common_Ref_h
0003 
0004 #ifndef DataFormats_Common_HolderToVectorTrait_Ref_specialization_h
0005 #define DataFormats_Common_HolderToVectorTrait_Ref_specialization_h
0006 // -*- C++ -*-
0007 //
0008 // Package:     DataFormats/Common
0009 //
0010 /**
0011 
0012  Description: Specialization of HolderToVectorTrait for edm::Ref
0013 
0014  Usage:
0015     Only if both DataFormats/Common/interface/HolderToVectorTrait.h and
0016  DataFormats/Common/interface/Ref.h are include in a file will this code
0017  be seen.
0018 
0019 */
0020 //
0021 // Original Author:  Chris Jones
0022 //         Created:  Thu, 20 Nov 2014 21:44:59 GMT
0023 //
0024 #include <memory>
0025 
0026 #include "DataFormats/Common/interface/VectorHolder.h"
0027 #include "DataFormats/Common/interface/RefVector.h"
0028 #include "DataFormats/Common/interface/RefVectorHolder.h"
0029 
0030 namespace edm {
0031   namespace reftobase {
0032 
0033     template <typename T, typename REF>
0034     struct RefHolderToVector {
0035       static std::unique_ptr<BaseVectorHolder<T> > makeVectorHolder() {
0036         typedef RefVector<typename REF::product_type, typename REF::value_type, typename REF::finder_type> REFV;
0037         return std::unique_ptr<BaseVectorHolder<T> >(new VectorHolder<T, REFV>);
0038       }
0039     };
0040 
0041     template <typename T1, typename C, typename T, typename F>
0042     struct HolderToVectorTrait<T1, Ref<C, T, F> > {
0043       typedef RefHolderToVector<T1, Ref<C, T, F> > type;
0044     };
0045 
0046     template <typename REF>
0047     struct RefRefHolderToRefVector {
0048       static std::unique_ptr<RefVectorHolderBase> makeVectorHolder() {
0049         typedef RefVector<typename REF::product_type, typename REF::value_type, typename REF::finder_type> REFV;
0050         return std::unique_ptr<RefVectorHolderBase>(new RefVectorHolder<REFV>);
0051       }
0052     };
0053 
0054     template <typename C, typename T, typename F>
0055     struct RefHolderToRefVectorTrait<Ref<C, T, F> > {
0056       typedef RefRefHolderToRefVector<Ref<C, T, F> > type;
0057     };
0058   }  // namespace reftobase
0059 }  // namespace edm
0060 
0061 #endif
0062 #endif
0063 #endif