CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
EDConsumerBase.h
Go to the documentation of this file.
1 #ifndef FWCore_Framework_EDConsumerBase_h
2 #define FWCore_Framework_EDConsumerBase_h
3 // -*- C++ -*-
4 //
5 // Package: FWCore/Framework
6 // Class : EDConsumerBase
7 //
16 //
17 // Original Author: Chris Jones
18 // Created: Tue, 02 Apr 2013 21:35:53 GMT
19 // $Id: EDConsumerBase.h,v 1.6 2013/06/07 17:58:31 chrjones Exp $
20 //
21 
22 // system include files
23 #include <vector>
24 
25 // user include files
34 
35 
36 // forward declarations
37 
38 namespace edm {
39  class ProductHolderIndexHelper;
40  class ConsumesCollector;
41 
43  {
44 
45  public:
47  virtual ~EDConsumerBase();
48 
49  // ---------- const member functions ---------------------
51 
52  void itemsToGet(BranchType, std::vector<ProductHolderIndex>&) const;
53  void itemsMayGet(BranchType, std::vector<ProductHolderIndex>&) const;
54 
55  // ---------- static member functions --------------------
56 
57  // ---------- member functions ---------------------------
58  void updateLookup(BranchType iBranchType,
60 
61  struct Labels {
62  const char* module;
63  const char* productInstance;
64  const char* process;
65  };
66  void labelsForToken(EDGetToken iToken, Labels& oLabels) const;
67 
68  protected:
69  friend class ConsumesCollector;
72 
73  template <typename ProductType, BranchType B=InEvent>
75  TypeToGet tid=TypeToGet::make<ProductType>();
77  }
78 
80  return EDGetToken{recordConsumes(InEvent,id,tag,true), tag.willSkipCurrentProcess()};
81  }
82 
83  template <BranchType B>
85  return EDGetToken{recordConsumes(B,id,tag,true), tag.willSkipCurrentProcess()};
86  }
87 
88  template <typename ProductType, BranchType B=InEvent>
90  TypeToGet tid=TypeToGet::make<ProductType>();
91  return EDGetTokenT<ProductType>{recordConsumes(B,tid, tag,false), tag.willSkipCurrentProcess()};
92  }
93 
94 
96  return mayConsume<InEvent>(id,tag);
97  }
98 
99  template <BranchType B>
101  return EDGetToken{recordConsumes(B,id,tag,false), tag.willSkipCurrentProcess()};
102  }
103 
104  template <typename ProductType, BranchType B=InEvent>
105  void consumesMany() {
106  TypeToGet tid=TypeToGet::make<ProductType>();
107  consumesMany<B>(tid);
108  }
109 
110 
111  void consumesMany(const TypeToGet& id) {
112  consumesMany<InEvent>(id);
113  }
114 
115  template <BranchType B>
116  void consumesMany(const TypeToGet& id) {
117  recordConsumes(B,id,edm::InputTag{},true);
118  }
119 
120  private:
121  EDConsumerBase(const EDConsumerBase&) = delete;
122 
123  const EDConsumerBase& operator=(const EDConsumerBase&) = delete;
124 
125  unsigned int recordConsumes(BranchType iBranch, TypeToGet const& iType, edm::InputTag const& iTag, bool iAlwaysGets);
126 
127  void throwTypeMismatch(edm::TypeID const&, EDGetToken) const;
129  void throwBadToken(edm::TypeID const& iType, EDGetToken iToken) const;
130 
131  // ---------- member data --------------------------------
134  ProductHolderIndex iIndex,
135  BranchType iBranch):
136  m_type(iID),m_index(iIndex),m_branchType(iBranch){}
140  };
141 
142  struct LabelPlacement {
143  LabelPlacement(unsigned int iStartOfModuleLabel,
144  unsigned short iDeltaToProductInstance,
145  unsigned short iDeltaToProcessName):
146  m_startOfModuleLabel(iStartOfModuleLabel),
147  m_deltaToProductInstance(iDeltaToProductInstance),
148  m_deltaToProcessName(iDeltaToProcessName) {}
149  unsigned int m_startOfModuleLabel;
150  unsigned short m_deltaToProductInstance;
151  unsigned short m_deltaToProcessName;
152  };
153 
154  //define the purpose of each 'column' in m_tokenInfo
157 
158  //m_tokenStartOfLabels holds the entries into this container
159  // for each of the 3 labels needed to id the data
160  std::vector<char> m_tokenLabels;
161 
162  };
163 }
164 
165 
166 #endif
void itemsMayGet(BranchType, std::vector< ProductHolderIndex > &) const
const EDConsumerBase & operator=(const EDConsumerBase &)=delete
ProductHolderIndex indexFrom(EDGetToken, BranchType, TypeID const &) const
void updateLookup(BranchType iBranchType, ProductHolderIndexHelper const &)
void consumesMany(const TypeToGet &id)
void throwTypeMismatch(edm::TypeID const &, EDGetToken) const
LabelPlacement(unsigned int iStartOfModuleLabel, unsigned short iDeltaToProductInstance, unsigned short iDeltaToProcessName)
void itemsToGet(BranchType, std::vector< ProductHolderIndex > &) const
void throwBadToken(edm::TypeID const &iType, EDGetToken iToken) const
unsigned int ProductHolderIndex
edm::SoATuple< TokenLookupInfo, bool, LabelPlacement, edm::KindOfType > m_tokenInfo
BranchType
Definition: BranchType.h:11
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
unsigned int recordConsumes(BranchType iBranch, TypeToGet const &iType, edm::InputTag const &iTag, bool iAlwaysGets)
void consumesMany(const TypeToGet &id)
EDGetToken mayConsume(const TypeToGet &id, edm::InputTag const &tag)
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
void throwBranchMismatch(BranchType, EDGetToken) const
EDGetToken mayConsume(const TypeToGet &id, edm::InputTag const &tag)
std::vector< char > m_tokenLabels
EDGetToken consumes(TypeToGet const &id, edm::InputTag const &tag)
bool willSkipCurrentProcess() const
Definition: InputTag.h:48
TokenLookupInfo(edm::TypeID const &iID, ProductHolderIndex iIndex, BranchType iBranch)
void labelsForToken(EDGetToken iToken, Labels &oLabels) const
EDGetTokenT< ProductType > mayConsume(edm::InputTag const &tag)
EDGetToken consumes(const TypeToGet &id, edm::InputTag const &tag)