CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups 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 Several fillView function templates, to provide View support for
7 Standard Library containers.
8 
9 ----------------------------------------------------------------------*/
10 
11 #include <vector>
12 #include <list>
13 #include <deque>
14 #include <set>
17 
18 namespace edm {
19 
20  class ProductID;
21 
22  namespace detail {
23 
24  template <class COLLECTION>
25  void reallyFillView(COLLECTION const& coll,
26  ProductID const& id,
27  std::vector<void const*>& ptrs,
28  FillViewHelperVector& helpers) {
29  typedef COLLECTION product_type;
30  typedef typename GetProduct<product_type>::element_type element_type;
31  typedef typename product_type::const_iterator iter;
32  typedef typename product_type::size_type size_type;
33 
34  ptrs.reserve(ptrs.size() + coll.size());
35  helpers.reserve(ptrs.size() + coll.size());
36  size_type key = 0;
37  for (iter i = coll.begin(), e = coll.end(); i != e; ++i, ++key) {
38  element_type const* address = GetProduct<product_type>::address(i);
39  ptrs.push_back(address);
40  helpers.emplace_back(id, key);
41  }
42  }
43  } // namespace detail
44  template <class T, class A>
45  void fillView(std::vector<T, A> const& obj,
46  ProductID const& id,
47  std::vector<void const*>& ptrs,
48  FillViewHelperVector& helpers) {
49  detail::reallyFillView(obj, id, ptrs, helpers);
50  }
51 
52  template <class T, class A>
53  void fillView(std::list<T, A> const& obj,
54  ProductID const& id,
55  std::vector<void const*>& ptrs,
56  FillViewHelperVector& helpers) {
57  detail::reallyFillView(obj, id, ptrs, helpers);
58  }
59 
60  template <class T, class A>
61  void fillView(std::deque<T, A> const& obj,
62  ProductID const& id,
63  std::vector<void const*>& ptrs,
64  FillViewHelperVector& helpers) {
65  detail::reallyFillView(obj, id, ptrs, helpers);
66  }
67 
68  template <class T, class A, class Comp>
69  void fillView(std::set<T, A, Comp> const& obj,
70  ProductID const& id,
71  std::vector<void const*>& ptrs,
72  FillViewHelperVector& helpers) {
73  detail::reallyFillView(obj, id, ptrs, helpers);
74  }
75 
76 } // namespace edm
77 
78 #endif
static const element_type * address(const iter &i)
Definition: GetProduct.h:36
void reallyFillView(COLLECTION const &coll, ProductID const &id, std::vector< void const * > &ptrs, FillViewHelperVector &helpers)
Definition: FillView.h:25
uint16_t size_type
COLLECTION::value_type element_type
Definition: GetProduct.h:34
void fillView(AssociationVector< KeyRefProd, CVal, KeyRef, SizeType, KeyReferenceHelper > const &obj, ProductID const &id, std::vector< void const * > &pointers, FillViewHelperVector &helpers)
tuple key
prepare the HTCondor submission files and eventually submit them
std::vector< std::pair< edm::ProductID, unsigned long > > FillViewHelperVector