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 //
20 
21 // system include files
22 #include <map>
23 #include <string>
24 #include <vector>
25 
26 // user include files
38 
39 
40 // forward declarations
41 
42 namespace edm {
43  class ModuleDescription;
44  class ProductHolderIndexHelper;
45  class ProductRegistry;
46  class ConsumesCollector;
47  template<typename T> class WillGetIfMatch;
48 
50  {
51 
52  public:
54  virtual ~EDConsumerBase();
55 
56  // ---------- const member functions ---------------------
58 
59  void itemsToGet(BranchType, std::vector<ProductHolderIndexAndSkipBit>&) const;
60  void itemsMayGet(BranchType, std::vector<ProductHolderIndexAndSkipBit>&) const;
61 
62  std::vector<ProductHolderIndexAndSkipBit> const& itemsToGetFromEvent() const { return itemsToGetFromEvent_; }
63 
66 
68  bool registeredToConsumeMany(TypeID const&, BranchType) const;
69  // ---------- static member functions --------------------
70 
71  // ---------- member functions ---------------------------
72  void updateLookup(BranchType iBranchType,
74 
76  void labelsForToken(EDGetToken iToken, Labels& oLabels) const;
77 
78  void modulesDependentUpon(const std::string& iProcessName,
79  std::vector<const char*>& oModuleLabels) const;
80 
81  void modulesWhoseProductsAreConsumed(std::vector<ModuleDescription const*>& modules,
82  ProductRegistry const& preg,
83  std::map<std::string, ModuleDescription const*> const& labelsToDesc,
84  std::string const& processName) const;
85 
86  std::vector<ConsumesInfo> consumesInfo() const;
87 
88  protected:
89  friend class ConsumesCollector;
90  template<typename T> friend class WillGetIfMatch;
93 
94  template <typename ProductType, BranchType B=InEvent>
96  TypeToGet tid=TypeToGet::make<ProductType>();
97  return EDGetTokenT<ProductType>{recordConsumes(B,tid, checkIfEmpty(tag),true)};
98  }
99 
101  return EDGetToken{recordConsumes(InEvent, id, checkIfEmpty(tag), true)};
102  }
103 
104  template <BranchType B>
106  return EDGetToken{recordConsumes(B, id, checkIfEmpty(tag), true)};
107  }
108 
109  template <typename ProductType, BranchType B=InEvent>
111  TypeToGet tid=TypeToGet::make<ProductType>();
112  return EDGetTokenT<ProductType>{recordConsumes(B, tid, checkIfEmpty(tag), false)};
113  }
114 
116  return mayConsume<InEvent>(id,tag);
117  }
118 
119  template <BranchType B>
121  return EDGetToken{recordConsumes(B,id,checkIfEmpty(tag),false)};
122  }
123 
124  template <typename ProductType, BranchType B=InEvent>
125  void consumesMany() {
126  TypeToGet tid=TypeToGet::make<ProductType>();
127  consumesMany<B>(tid);
128  }
129 
130  void consumesMany(const TypeToGet& id) {
131  consumesMany<InEvent>(id);
132  }
133 
134  template <BranchType B>
135  void consumesMany(const TypeToGet& id) {
136  recordConsumes(B,id,edm::InputTag{},true);
137  }
138 
139  private:
140  EDConsumerBase(const EDConsumerBase&) = delete;
141 
142  const EDConsumerBase& operator=(const EDConsumerBase&) = delete;
143 
144  unsigned int recordConsumes(BranchType iBranch, TypeToGet const& iType, edm::InputTag const& iTag, bool iAlwaysGets);
145 
146  void throwTypeMismatch(edm::TypeID const&, EDGetToken) const;
148  void throwBadToken(edm::TypeID const& iType, EDGetToken iToken) const;
149  void throwConsumesCallAfterFrozen(TypeToGet const&, InputTag const&) const;
150 
152  // ---------- member data --------------------------------
153 
156  ProductHolderIndex iIndex,
157  bool skipCurrentProcess,
158  BranchType iBranch):
159  m_type(iID),m_index(iIndex, skipCurrentProcess), m_branchType(iBranch){}
163  };
164 
165  struct LabelPlacement {
166  LabelPlacement(unsigned int iStartOfModuleLabel,
167  unsigned short iDeltaToProductInstance,
168  unsigned short iDeltaToProcessName):
169  m_startOfModuleLabel(iStartOfModuleLabel),
170  m_deltaToProductInstance(iDeltaToProductInstance),
171  m_deltaToProcessName(iDeltaToProcessName) {}
172  unsigned int m_startOfModuleLabel;
173  unsigned short m_deltaToProductInstance;
174  unsigned short m_deltaToProcessName;
175  };
176 
177  //define the purpose of each 'column' in m_tokenInfo
180 
181  //m_tokenStartOfLabels holds the entries into this container
182  // for each of the 3 labels needed to id the data
183  std::vector<char> m_tokenLabels;
184 
185  std::vector<ProductHolderIndexAndSkipBit> itemsToGetFromEvent_;
186 
187  bool frozen_;
188  };
189 }
190 
191 #endif
std::vector< ConsumesInfo > consumesInfo() const
ProductHolderIndexAndSkipBit m_index
const EDConsumerBase & operator=(const EDConsumerBase &)=delete
void updateLookup(BranchType iBranchType, ProductHolderIndexHelper const &)
void itemsToGet(BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
void itemsMayGet(BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
void consumesMany(const TypeToGet &id)
void throwTypeMismatch(edm::TypeID const &, EDGetToken) const
LabelPlacement(unsigned int iStartOfModuleLabel, unsigned short iDeltaToProductInstance, unsigned short iDeltaToProcessName)
void throwBadToken(edm::TypeID const &iType, EDGetToken iToken) const
std::vector< ProductHolderIndexAndSkipBit > const & itemsToGetFromEvent() const
ProductHolderIndexAndSkipBit indexFrom(EDGetToken, BranchType, TypeID const &) const
unsigned int ProductHolderIndex
void throwConsumesCallAfterFrozen(TypeToGet const &, InputTag const &) const
edm::SoATuple< TokenLookupInfo, bool, LabelPlacement, edm::KindOfType > m_tokenInfo
void modulesWhoseProductsAreConsumed(std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
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
void modulesDependentUpon(const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
edm::InputTag const & checkIfEmpty(edm::InputTag const &tag)
ProductLabels Labels
EDGetToken consumes(TypeToGet const &id, edm::InputTag const &tag)
bool registeredToConsumeMany(TypeID const &, BranchType) const
void labelsForToken(EDGetToken iToken, Labels &oLabels) const
TokenLookupInfo(edm::TypeID const &iID, ProductHolderIndex iIndex, bool skipCurrentProcess, BranchType iBranch)
bool registeredToConsume(ProductHolderIndex, bool, BranchType) const
std::vector< ProductHolderIndexAndSkipBit > itemsToGetFromEvent_
volatile std::atomic< bool > shutdown_flag false
preg
Definition: Schedule.cc:369
EDGetTokenT< ProductType > mayConsume(edm::InputTag const &tag)
EDGetToken consumes(const TypeToGet &id, edm::InputTag const &tag)