CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_4/src/DataFormats/Common/interface/RefKeyTrait.h

Go to the documentation of this file.
00001 #ifndef DataFormats_Common_RefKeyTrait_h
00002 #define DataFormats_Common_RefKeyTrait_h
00003 #include "FWCore/Utilities/interface/EDMException.h"
00004 
00005 namespace edm {
00006   template <typename C> class RefProd;
00007   namespace reftobase {
00008 
00009     struct RefKey {
00010       template<typename REF>
00011       static size_t key( const REF & r ) {
00012         return r.key();
00013       }
00014     };
00015     
00016     struct RefProdKey {
00017       template<typename REF>
00018       static size_t key( const REF & r ) {
00019         Exception::throwThis(errors::InvalidReference,
00020           "attempting get key from a RefToBase containing a RefProd.\n"
00021           "You can use key only with RefToBase containing a Ref.");
00022         return 0;
00023       }
00024     };
00025     
00026     template<typename REF>
00027     struct RefKeyTrait {
00028       typedef RefKey type;
00029     };
00030 
00031     template<typename C>
00032     struct RefKeyTrait<RefProd<C> > {
00033       typedef RefProdKey type;
00034     };
00035   }
00036 }
00037 
00038 #endif