CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros 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  */
14 #include <memory>
15 #include "boost/static_assert.hpp"
16 #include "boost/type_traits.hpp"
17 
18 namespace helper {
19 
20  template<typename Collection>
21  struct IteratorToObjectConverter {
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::auto_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>
39  struct IteratorToObjectConverter<edm::RefVector<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>
48  struct IteratorToObjectConverter<edm::RefToBaseVector<T> > {
50  template<typename I>
51  static value_type convert( const I & i ) {
52  return value_type( * i );
53  }
54  };
55 
56 
57  template<typename T>
58  struct IteratorToObjectConverter<edm::PtrVector<T> > {
60  template<typename I>
61  static value_type convert( const I & i ) {
62  return value_type( * i );
63  }
64  };
65 
66  /*
67  template<typename OutputCollection, typename InputCollection>
68  struct OutputCollectionCreator {
69  static std::auto_ptr<OutputCollection> createNewCollection( const edm::Handle<InputCollection> & ) {
70  return std::auto_ptr<OutputCollection>( new OutputCollection );
71  }
72  };
73 
74  template<typename T, typename InputCollection>
75  struct OutputCollectionCreator<edm::RefToBaseVector<T>, InputCollection> {
76  static std::auto_ptr<edm::RefToBaseVector<T> > createNewCollection( const edm::Handle<InputCollection> & h ) {
77  return std::auto_ptr<edm::RefToBaseVector<T> >( new edm::RefToBaseVector<T>(h) );
78  }
79  };
80  */
81 
82  /*
83  template<typename T1, typename T2>
84  struct OutputCollectionCreator<RefToBaseVector<T1>, RefToBaseVector<T2> > {
85  static RefToBaseVector<T1> * createNewCollection( const edm::Handle<RefToBaseVector<T2> > & h ) {
86  return new RefToBaseVector<T1>(h);
87  }
88  };
89  */
90 
91  template<typename OutputCollection,
92  typename ClonePolicy = IteratorToObjectConverter<OutputCollection> >
93  struct CollectionStoreManager {
94  typedef OutputCollection collection;
95  template<typename C>
97  selected_( new OutputCollection ) {
98  // selected_ = OutputCollectionCreator<OutputCollection, C>::createNewCollection(h);
99  }
100  template<typename I>
101  void cloneAndStore( const I & begin, const I & end, edm::Event & ) {
102  using namespace std;
103  for( I i = begin; i != end; ++ i ) {
105  selected_->push_back( v );
106  }
107  }
109  return evt.put( selected_ );
110  }
111  size_t size() const { return selected_->size(); }
112  private:
113  std::auto_ptr<collection> selected_;
114  };
115 
116  template<typename OutputCollection>
117  struct ObjectSelectorBase : public edm::EDFilter {
119  produces<OutputCollection>();
120  }
121  };
122 
123  template<typename OutputCollection>
124  struct StoreManagerTrait {
127  };
128 
129 }
130 
131 #endif
int i
Definition: DBlmapReader.cc:9
tuple cfg
Definition: looper.py:293
static value_type convert(const I &i)
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)
ObjectSelectorBase(const edm::ParameterSet &cfg)
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:120
ObjectSelectorBase< OutputCollection > base
const std::complex< double > I
Definition: I.h:8
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
#define end
Definition: vmac.h:37
Container::value_type value_type
std::auto_ptr< collection > selected_
#define begin
Definition: vmac.h:30
CollectionStoreManager< OutputCollection > type
edm::RefVector< Container > RefVector