CMS 3D CMS Logo

FillView.h
Go to the documentation of this file.
1 #ifndef DataFormats_Common_FillView_h
2 #define DataFormats_Common_FillView_h
3 
4 
5 /*----------------------------------------------------------------------
6 
7 Several fillView function templates, to provide View support for
8 Standard Library containers.
9 
10 ----------------------------------------------------------------------*/
11 
12 #include <vector>
13 #include <list>
14 #include <deque>
15 #include <set>
18 
19 namespace edm {
20 
21  class ProductID;
22 
23  namespace detail {
24 
25  template <class COLLECTION>
26  void
27  reallyFillView(COLLECTION const& coll,
28  ProductID const& id,
29  std::vector<void const*>& ptrs,
31  {
32  typedef COLLECTION product_type;
33  typedef typename GetProduct<product_type>::element_type element_type;
34  typedef typename product_type::const_iterator iter;
35  typedef typename product_type::size_type size_type;
36 
37  ptrs.reserve(ptrs.size() + coll.size());
38  helpers.reserve(ptrs.size() + coll.size());
39  size_type key = 0;
40  for (iter i = coll.begin(), e = coll.end(); i!=e; ++i, ++key) {
41  element_type const* address = GetProduct<product_type>::address(i);
42  ptrs.push_back(address);
43  helpers.emplace_back(id,key);
44  }
45  }
46  }
47  template <class T, class A>
48  void
49  fillView(std::vector<T,A> const& obj,
50  ProductID const& id,
51  std::vector<void const*>& ptrs,
53  {
54  detail::reallyFillView(obj, id, ptrs, helpers);
55  }
56 
57  template <class T, class A>
58  void
59  fillView(std::list<T,A> const& obj,
60  ProductID const& id,
61  std::vector<void const*>& ptrs,
63  {
64  detail::reallyFillView(obj, id, ptrs, helpers);
65  }
66 
67  template <class T, class A>
68  void
69  fillView(std::deque<T,A> const& obj,
70  ProductID const& id,
71  std::vector<void const*>& ptrs,
73  {
74  detail::reallyFillView(obj, id, ptrs, helpers);
75  }
76 
77  template <class T, class A, class Comp>
78  void
79  fillView(std::set<T,A,Comp> const& obj,
80  ProductID const& id,
81  std::vector<void const*>& ptrs,
83  {
84  detail::reallyFillView(obj, id, ptrs, helpers);
85  }
86 
87 }
88 
89 #endif
static const element_type * address(const iter &i)
Definition: GetProduct.h:33
void reallyFillView(COLLECTION const &coll, ProductID const &id, std::vector< void const * > &ptrs, FillViewHelperVector &helpers)
Definition: FillView.h:27
uint16_t size_type
COLLECTION::value_type element_type
Definition: GetProduct.h:31
void fillView(AssociationVector< KeyRefProd, CVal, KeyRef, SizeType, KeyReferenceHelper > const &obj, ProductID const &id, std::vector< void const * > &pointers, FillViewHelperVector &helpers)
JetCorrectorParametersCollection coll
Definition: classes.h:10
HLT enums.
std::vector< std::pair< edm::ProductID, unsigned long > > FillViewHelperVector