CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
RefItem.h
Go to the documentation of this file.
1 #ifndef DataFormats_Common_RefItem_h
2 #define DataFormats_Common_RefItem_h
3 
4 /*----------------------------------------------------------------------
5 
6 RefItem: Index and pointer to a referenced item.
7 
8 $Id: RefItem.h,v 1.10 2007/06/14 04:56:29 wmtan Exp $
9 
10 ----------------------------------------------------------------------*/
13 
14 namespace edm {
15 
16  template<typename KEY>
17  class RefItem {
18  public:
19  typedef KEY key_type;
20 
22 
23  RefItem(key_type inx, void const* p) : index_(inx), cache_(p) {}
24 
25  ~RefItem() {}
26 
27  key_type key() const {return index_;}
28  void const *ptr() const {return cache_.ptr_;}
29  void const *setPtr(void const* p) const {return(cache_.ptr_ = p);}
30 
32  bool isNonnull() const { return isValid(); }
33  bool isNull() const { return !isValid(); }
34 
35 private:
37  mutable ConstPtrCache cache_; //Type handles the transient
38  };
39 
40  template<typename KEY>
41  inline
42  bool
43  operator==(RefItem<KEY> const& lhs, RefItem<KEY> const& rhs) {
44  return lhs.key() == rhs.key();
45  }
46 
47  template<typename KEY>
48  inline
49  bool
50  operator!=(RefItem<KEY> const& lhs, RefItem<KEY> const& rhs) {
51  return !(lhs == rhs);
52  }
53 
54  template<typename KEY>
55  inline
56  bool
57  operator<(RefItem<KEY> const& lhs, RefItem<KEY> const& rhs) {
58  return lhs.key() < rhs.key();
59  }
60 }
61 
62 #endif
RefItem(key_type inx, void const *p)
Definition: RefItem.h:23
bool isNull() const
Definition: RefItem.h:33
bool operator!=(debugging_allocator< X > const &, debugging_allocator< Y > const &)
KEY key_type
Definition: RefItem.h:19
bool operator==(debugging_allocator< X > const &, debugging_allocator< Y > const &)
bool isNonnull() const
Definition: RefItem.h:32
ConstPtrCache cache_
Definition: RefItem.h:37
const void * ptr_
Definition: ConstPtrCache.h:36
void const * setPtr(void const *p) const
Definition: RefItem.h:29
key_type index_
Definition: RefItem.h:36
key_type key() const
Definition: RefItem.h:27
void const * ptr() const
Definition: RefItem.h:28
bool isValid() const
Definition: RefItem.h:31