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 Several fillView function templates, to provide View support for
7 Standard Library containers.
8 
9 ----------------------------------------------------------------------*/
10 
11 #include <string>
12 #include <vector>
13 #include <list>
14 #include <deque>
15 #include <set>
19 
20 namespace edm {
21  template<typename C, typename T, typename F> class RefVector;
22  template<typename C, typename T, typename F> class Ref;
23  namespace detail {
24 
25  // Function template reallyFillView<C> can fill views for
26  // standard-library collections of appropriate types (vector, list,
27  // deque, set).
28 
29  template<typename C, typename T, typename F>
31  typedef Ref<C, T, F> type;
32  };
33 
34  template<typename C, typename T, typename F, typename T1, typename F1>
35  struct FillViewRefTypeTrait<RefVector<C, T, F>, T1, F1> {
37  };
38  }
39 }
40 
43 
44 namespace edm {
45  namespace detail {
46 
47  template <class COLLECTION>
48  void
49  reallyFillView(COLLECTION const& coll,
50  ProductID const& id,
51  std::vector<void const*>& ptrs,
52  helper_vector& helpers)
53  {
54  typedef COLLECTION product_type;
55  typedef typename GetProduct<product_type>::element_type element_type;
56  typedef typename product_type::const_iterator iter;
57  typedef typename product_type::size_type size_type;
58  typedef typename FillViewRefTypeTrait<product_type,
60  typename refhelper::FindTrait<product_type,
61  typename refhelper::ValueTrait<product_type>::value>::value>::type ref_type;
62  typedef reftobase::RefHolder<ref_type> holder_type;
63 
64  ptrs.reserve(ptrs.size() + coll.size());
65  helpers.reserve(helpers.size() + coll.size());
66  size_type key = 0;
67  for (iter i = coll.begin(), e = coll.end(); i!=e; ++i, ++key) {
68  element_type const* address = GetProduct<product_type>::address(i);
69  ptrs.push_back(address);
70  ref_type ref(id, address, key, GetProduct<product_type>::product(coll) );
71  holder_type h(ref);
72  helpers.push_back(&h);
73  }
74  }
75  }
76 
77  template <class T, class A>
78  void
79  fillView(std::vector<T,A> const& obj,
80  ProductID const& id,
81  std::vector<void const*>& ptrs,
82  helper_vector& helpers)
83  {
84  detail::reallyFillView(obj, id, ptrs, helpers);
85  }
86 
87  template <class T, class A>
88  void
89  fillView(std::list<T,A> const& obj,
90  ProductID const& id,
91  std::vector<void const*>& ptrs,
92  helper_vector& helpers)
93  {
94  detail::reallyFillView(obj, id, ptrs, helpers);
95  }
96 
97  template <class T, class A>
98  void
99  fillView(std::deque<T,A> const& obj,
100  ProductID const& id,
101  std::vector<void const*>& ptrs,
102  helper_vector& helpers)
103  {
104  detail::reallyFillView(obj, id, ptrs, helpers);
105  }
106 
107  template <class T, class A, class Comp>
108  void
109  fillView(std::set<T,A,Comp> const& obj,
110  ProductID const& id,
111  std::vector<void const*>& ptrs,
112  helper_vector& helpers)
113  {
114  detail::reallyFillView(obj, id, ptrs, helpers);
115  }
116 
117 }
118 
119 #endif
type
Definition: HCALResponse.h:21
int i
Definition: DBlmapReader.cc:9
void fillView(AssociationVector< KeyRefProd, CVal, KeyRef, SizeType, KeyReferenceHelper > const &obj, ProductID const &id, std::vector< void const * > &pointers, helper_vector &helpers)
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, helper_vector &helpers)
Definition: FillView.h:49
uint16_t size_type
virtual size_type size() const =0
COLLECTION::value_type element_type
Definition: GetProduct.h:31
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
refhelper::RefVectorTrait< C, T, F >::ref_type type
Definition: FillView.h:36
JetCorrectorParametersCollection coll
Definition: classes.h:10
virtual void reserve(size_type n)=0
list key
Definition: combine.py:13
virtual void push_back(RefHolderBase const *r)=0
static uInt32 F(BLOWFISH_CTX *ctx, uInt32 x)
Definition: blowfish.cc:281
long double T
edm::RefVector< Container > RefVector