CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
RefItemGet.h
Go to the documentation of this file.
1 #ifndef DataFormats_Common_RefItemGet_h
2 #define DataFormats_Common_RefItemGet_h
3 
4 /*----------------------------------------------------------------------
5 
6 RefItemGet: Free function to get pointer to a referenced item.
7 
8 
9 ----------------------------------------------------------------------*/
12 
13 namespace edm {
14 
15  namespace refitem {
16  template< typename C, typename T, typename F, typename KEY>
17  struct GetPtrImpl {
18  static T const* getPtr_(RefCore const& product, KEY const& key) {
19  C const* prod = edm::template getProduct<C>(product);
20  /*
21  typename C::const_iterator it = prod->begin();
22  std::advance(it, item.key());
23  T const* p = it.operator->();
24  */
25  F func;
26  T const* p = func(*prod, key);
27  return p;
28  }
29  };
30 
31  template< typename C, typename T, typename F>
32  struct GetPtrImpl<C, T, F, unsigned int> {
33  static T const* getPtr_(RefCore const& product, unsigned int key) {
34  C const* prod = edm::template tryToGetProduct<C>(product);
35  if(prod != nullptr) {
36  F func;
37  T const* p = func(*prod, key);
38  return p;
39  }
40  unsigned int thinnedKey = key;
41  prod = edm::template getThinnedProduct<C>(product, thinnedKey);
42  F func;
43  T const* p = func(*prod, thinnedKey);
44  return p;
45  }
46  };
47  }
48 
49  template <typename C, typename T, typename F, typename KEY>
50  inline
51  T const* getPtr_(RefCore const& product, KEY const& key) {
52  return refitem::GetPtrImpl<C, T, F, KEY>::getPtr_(product, key);
53  }
54 
55  template <typename C, typename T, typename F, typename KEY>
56  inline
57  T const* getPtr(RefCore const& product, KEY const& iKey) {
58  T const* p=refitem::GetPtrImpl<C, T, F, KEY>::getPtr_(product, iKey);
59  return p;
60  }
61 
62  namespace refitem {
63  template< typename C, typename KEY>
65  static bool isThinnedAvailable_(RefCore const& product, KEY const& key) {
66  return false;
67  }
68  };
69 
70  template< typename C >
71  struct IsThinnedAvailableImpl<C, unsigned int> {
72  static bool isThinnedAvailable_(RefCore const& ref, unsigned int key) {
73  if(ref.productPtr() != nullptr) {
74  return true;
75  }
76  if (ref.isTransient()) {
77  return false;
78  }
79  return ref.isThinnedAvailable(key);
80  }
81  };
82  }
83 
84  template <typename C, typename KEY>
85  inline
86  bool isThinnedAvailable(RefCore const& product, KEY const& iKey) {
88  }
89 }
90 
91 #endif
bool isThinnedAvailable(RefCore const &product, KEY const &iKey)
Definition: RefItemGet.h:86
bool isThinnedAvailable(unsigned int thinnedKey) const
Definition: RefCore.cc:117
T const * getPtr_(RefCore const &product, KEY const &key)
Definition: RefItemGet.h:51
static T const * getPtr_(RefCore const &product, KEY const &key)
Definition: RefItemGet.h:18
static bool isThinnedAvailable_(RefCore const &product, KEY const &key)
Definition: RefItemGet.h:65
static T const * getPtr_(RefCore const &product, unsigned int key)
Definition: RefItemGet.h:33
void const * productPtr() const
Definition: RefCore.h:32
T const * getPtr(RefCore const &product, KEY const &iKey)
Definition: RefItemGet.h:57
bool isTransient() const
Definition: RefCore.h:75
static uInt32 F(BLOWFISH_CTX *ctx, uInt32 x)
Definition: blowfish.cc:281
static bool isThinnedAvailable_(RefCore const &ref, unsigned int key)
Definition: RefItemGet.h:72
long double T
def template
Definition: svgfig.py:520