CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 #ifndef __GCCXML__
25 
26  template <class COLLECTION>
27  void
28  reallyFillView(COLLECTION const& coll,
29  ProductID const& id,
30  std::vector<void const*>& ptrs,
31  FillViewHelperVector& helpers)
32  {
33  typedef COLLECTION product_type;
34  typedef typename GetProduct<product_type>::element_type element_type;
35  typedef typename product_type::const_iterator iter;
36  typedef typename product_type::size_type size_type;
37 
38  ptrs.reserve(ptrs.size() + coll.size());
39  helpers.reserve(ptrs.size() + coll.size());
40  size_type key = 0;
41  for (iter i = coll.begin(), e = coll.end(); i!=e; ++i, ++key) {
42  element_type const* address = GetProduct<product_type>::address(i);
43  ptrs.push_back(address);
44  helpers.emplace_back(id,key);
45  }
46  }
47 #else
48  template <class COLLECTION>
49  void
50  reallyFillView(COLLECTION const& coll,
51  ProductID const& id,
52  std::vector<void const*>& ptrs,
53  FillViewHelperVector& helpers);
54 #endif
55  }
56  template <class T, class A>
57  void
58  fillView(std::vector<T,A> const& obj,
59  ProductID const& id,
60  std::vector<void const*>& ptrs,
61  FillViewHelperVector& helpers)
62  {
63  detail::reallyFillView(obj, id, ptrs, helpers);
64  }
65 
66  template <class T, class A>
67  void
68  fillView(std::list<T,A> const& obj,
69  ProductID const& id,
70  std::vector<void const*>& ptrs,
71  FillViewHelperVector& helpers)
72  {
73  detail::reallyFillView(obj, id, ptrs, helpers);
74  }
75 
76  template <class T, class A>
77  void
78  fillView(std::deque<T,A> const& obj,
79  ProductID const& id,
80  std::vector<void const*>& ptrs,
81  FillViewHelperVector& helpers)
82  {
83  detail::reallyFillView(obj, id, ptrs, helpers);
84  }
85 
86  template <class T, class A, class Comp>
87  void
88  fillView(std::set<T,A,Comp> const& obj,
89  ProductID const& id,
90  std::vector<void const*>& ptrs,
91  FillViewHelperVector& helpers)
92  {
93  detail::reallyFillView(obj, id, ptrs, helpers);
94  }
95 
96 }
97 
98 #endif
int i
Definition: DBlmapReader.cc:9
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:28
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)
string key
FastSim: produces sample of signal events, overlayed with premixed minbias events.
JetCorrectorParametersCollection coll
Definition: classes.h:10
std::vector< std::pair< edm::ProductID, unsigned long > > FillViewHelperVector