00001 #ifndef DataFormats_Common_RefItem_h 00002 #define DataFormats_Common_RefItem_h 00003 00004 #error "this file should not be included anymore" 00005 00006 /*---------------------------------------------------------------------- 00007 00008 RefItem: Index and pointer to a referenced item. 00009 00010 $Id: RefItem.h,v 1.12 2011/02/24 20:20:48 wmtan Exp $ 00011 00012 ----------------------------------------------------------------------*/ 00013 #include "DataFormats/Common/interface/traits.h" 00014 #include "DataFormats/Common/interface/ConstPtrCache.h" 00015 00016 namespace edm { 00017 00018 template<typename KEY> 00019 class RefItem { 00020 public: 00021 typedef KEY key_type; 00022 00023 RefItem() : index_(key_traits<key_type>::value), cache_(0) {} 00024 00025 RefItem(key_type inx, void const* p) : index_(inx), cache_(p) {} 00026 00027 ~RefItem() {} 00028 00029 key_type key() const {return index_;} 00030 void const *ptr() const {return cache_.ptr_;} 00031 void const *setPtr(void const* p) const {return(cache_.ptr_ = p);} 00032 00033 bool isValid() const { return index_!=edm::key_traits<key_type>::value; } 00034 bool isNonnull() const { return isValid(); } 00035 bool isNull() const { return !isValid(); } 00036 00037 private: 00038 key_type index_; 00039 mutable ConstPtrCache cache_; //Type handles the transient 00040 }; 00041 00042 template<typename KEY> 00043 inline 00044 bool 00045 operator==(RefItem<KEY> const& lhs, RefItem<KEY> const& rhs) { 00046 return lhs.key() == rhs.key(); 00047 } 00048 00049 template<typename KEY> 00050 inline 00051 bool 00052 operator!=(RefItem<KEY> const& lhs, RefItem<KEY> const& rhs) { 00053 return !(lhs == rhs); 00054 } 00055 00056 template<typename KEY> 00057 inline 00058 bool 00059 operator<(RefItem<KEY> const& lhs, RefItem<KEY> const& rhs) { 00060 return lhs.key() < rhs.key(); 00061 } 00062 } 00063 00064 #endif