Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #ifndef DataFormats_Common_getRef_h
0002 #define DataFormats_Common_getRef_h
0003 /* \function edm::getRef(...)
0004  *
0005  * \author Luca Lista, INFN
0006  *
0007  */
0008 #include "DataFormats/Common/interface/Ref.h"
0009 #include "DataFormats/Common/interface/View.h"
0010 #include "DataFormats/Common/interface/Handle.h"
0011 
0012 namespace edm {
0013   namespace helper {
0014     template <typename C>
0015     struct MatcherGetRef {
0016       typedef Ref<C> ref_type;
0017       static ref_type getRef(const Handle<C>& c, size_t k) { return ref_type(c, k); }
0018     };
0019 
0020     template <typename T>
0021     struct MatcherGetRef<View<T> > {
0022       typedef RefToBase<T> ref_type;
0023       static ref_type getRef(const Handle<View<T> >& v, size_t k) { return v->refAt(k); }
0024     };
0025   }  // namespace helper
0026 
0027   template <typename C>
0028   typename helper::MatcherGetRef<C>::ref_type getRef(const Handle<C>& c, size_t k) {
0029     return helper::MatcherGetRef<C>::getRef(c, k);
0030   }
0031 }  // namespace edm
0032 
0033 #endif