CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
StoreManagerTrait.h
Go to the documentation of this file.
1 #ifndef UtilAlgos_StoreManagerTrait_h
2 #define UtilAlgos_StoreManagerTrait_h
3 /* \class helper::CollectionStoreManager
4  *
5  * \author: Luca Lista, INFN
6  *
7  */
15 #include <memory>
16 #include "boost/type_traits.hpp"
17 
18 namespace helper {
19 
20  template <typename Collection>
23  template <typename I>
24  static value_type convert(const I &i) {
25  return value_type(**i);
26  }
27  };
28 
29  template <typename T>
30  struct IteratorToObjectConverter<edm::OwnVector<T> > {
31  typedef std::unique_ptr<T> value_type;
32  template <typename I>
33  static value_type convert(const I &i) {
34  return value_type((*i)->clone());
35  }
36  };
37 
38  template <typename C>
41  template <typename I>
42  static value_type convert(const I &i) {
43  return value_type(*i);
44  }
45  };
46 
47  template <typename T>
50  template <typename I>
51  static value_type convert(const I &i) {
52  return value_type(*i);
53  }
54  };
55 
56  template <typename T>
59  template <typename I>
60  static value_type convert(const I &i) {
61  return value_type(*i);
62  }
63  };
64 
65  template <typename OutputCollection, typename ClonePolicy = IteratorToObjectConverter<OutputCollection> >
67  typedef OutputCollection collection;
68  template <typename C>
69  CollectionStoreManager(const edm::Handle<C> &h) : selected_(new OutputCollection) {}
70  template <typename I>
71  void cloneAndStore(const I &begin, const I &end, edm::Event &) {
72  using namespace std;
73  for (I i = begin; i != end; ++i) {
75  selected_->push_back(std::move(v));
76  }
77  }
79  size_t size() const { return selected_->size(); }
80 
81  private:
82  std::unique_ptr<collection> selected_;
83  };
84 
85  template <typename OutputCollection, typename EdmFilter>
86  struct ObjectSelectorBase : public EdmFilter {
87  ObjectSelectorBase(const edm::ParameterSet &) { this->template produces<OutputCollection>(); }
88  };
89 
90  template <typename OutputCollection, typename EdmFilter>
94  };
95 
96 } // namespace helper
97 
98 #endif
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
std::unique_ptr< collection > selected_
static value_type convert(const I &i)
ObjectSelectorBase(const edm::ParameterSet &)
Collection::value_type value_type
edm::OrphanHandle< collection > put(edm::Event &evt)
void cloneAndStore(const I &begin, const I &end, edm::Event &)
CollectionStoreManager(const edm::Handle< C > &h)
def move
Definition: eostools.py:511
const std::complex< double > I
Definition: I.h:8
string end
Definition: dataset.py:937
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
edm::RefVector< Container > RefVector