CMS 3D CMS Logo

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         throw edm::Exception(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       }
00023     };
00024     
00025     template<typename REF>
00026     struct RefKeyTrait {
00027       typedef RefKey type;
00028     };
00029 
00030     template<typename C>
00031     struct RefKeyTrait<RefProd<C> > {
00032       typedef RefProdKey type;
00033     };
00034   }
00035 }
00036 
00037 #endif

Generated on Tue Jun 9 17:29:56 2009 for CMSSW by  doxygen 1.5.4