00001 #ifndef DataFormats_Common_RefBase_h
00002 #define DataFormats_Common_RefBase_h
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #include "DataFormats/Common/interface/EDProductfwd.h"
00013 #include "DataFormats/Common/interface/RefCore.h"
00014
00015 namespace edm {
00016
00017 template<typename KEY>
00018 class RefBase {
00019 public:
00020 typedef KEY key_type;
00021
00023 RefBase() : product_(), item_() {}
00024
00026 RefBase(ProductID const& productID, void const* prodPtr, key_type itemKey,
00027 void const* itemPtr, EDProductGetter const* prodGetter, bool transient):
00028 product_(productID, prodPtr, prodGetter, transient), item_(itemKey, itemPtr) {}
00029
00031 RefBase(RefCore const& prod, RefItem<KEY> const& itm) :
00032 product_(prod), item_(itm) {}
00033
00036
00038 RefCore const& refCore() const { return product_;}
00039
00041 RefItem<KEY> const& item() const {return item_;}
00042
00043
00044
00045
00046
00048 bool isValid() const { return item_.isValid(); }
00049 bool isNull() const { return item_.isNull(); }
00050 bool isNonnull() const { return item_.isNonnull(); }
00051
00052 private:
00053 RefCore product_;
00054 RefItem<KEY> item_;
00055 };
00056
00057 template <typename KEY>
00058 bool
00059 operator==(RefBase<KEY> const& lhs, RefBase<KEY> const& rhs) {
00060 return lhs.refCore() == rhs.refCore() && lhs.item() == rhs.item();
00061 }
00062
00063 template <typename KEY>
00064 bool
00065 operator!=(RefBase<KEY> const& lhs, RefBase<KEY> const& rhs) {
00066 return !(lhs == rhs);
00067 }
00068
00069 template <typename KEY>
00070 bool
00071 operator<(RefBase<KEY> const& lhs, RefBase<KEY> const& rhs) {
00072 return (lhs.refCore() == rhs.refCore() ? lhs.item() < rhs.item() : lhs.refCore() < rhs.refCore());
00073 }
00074 }
00075
00076 #endif