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(std::string const& iProcessName,
79  std::string const& iModuleLabel,
80  bool iPrint,
81  std::vector<char const*>& oModuleLabels) const;
82 
83  void modulesWhoseProductsAreConsumed(std::vector<ModuleDescription const*>& modules,
84  ProductRegistry const& preg,
85  std::map<std::string, ModuleDescription const*> const& labelsToDesc,
86  std::string const& processName) const;
87 
88  std::vector<ConsumesInfo> consumesInfo() const;
89 
90  protected:
91  friend class ConsumesCollector;
92  template<typename T> friend class WillGetIfMatch;
95 
96  template <typename ProductType, BranchType B=InEvent>
98  TypeToGet tid=TypeToGet::make<ProductType>();
99  return EDGetTokenT<ProductType>{recordConsumes(B,tid, checkIfEmpty(tag),true)};
100  }
101 
103  return EDGetToken{recordConsumes(InEvent, id, checkIfEmpty(tag), true)};
104  }
105 
106  template <BranchType B>
108  return EDGetToken{recordConsumes(B, id, checkIfEmpty(tag), true)};
109  }
110 
111  template <typename ProductType, BranchType B=InEvent>
113  TypeToGet tid=TypeToGet::make<ProductType>();
114  return EDGetTokenT<ProductType>{recordConsumes(B, tid, checkIfEmpty(tag), false)};
115  }
116 
118  return mayConsume<InEvent>(id,tag);
119  }
120 
121  template <BranchType B>
123  return EDGetToken{recordConsumes(B,id,checkIfEmpty(tag),false)};
124  }
125 
126  template <typename ProductType, BranchType B=InEvent>
127  void consumesMany() {
128  TypeToGet tid=TypeToGet::make<ProductType>();
129  consumesMany<B>(tid);
130  }
131 
132  void consumesMany(const TypeToGet& id) {
133  consumesMany<InEvent>(id);
134  }
135 
136  template <BranchType B>
137  void consumesMany(const TypeToGet& id) {
138  recordConsumes(B,id,edm::InputTag{},true);
139  }
140 
141  private:
142  EDConsumerBase(const EDConsumerBase&) = delete;
143 
144  const EDConsumerBase& operator=(const EDConsumerBase&) = delete;
145 
146  unsigned int recordConsumes(BranchType iBranch, TypeToGet const& iType, edm::InputTag const& iTag, bool iAlwaysGets);
147 
148  void throwTypeMismatch(edm::TypeID const&, EDGetToken) const;
150  void throwBadToken(edm::TypeID const& iType, EDGetToken iToken) const;
151  void throwConsumesCallAfterFrozen(TypeToGet const&, InputTag const&) const;
152 
154  // ---------- member data --------------------------------
155 
158  ProductHolderIndex iIndex,
159  bool skipCurrentProcess,
160  BranchType iBranch):
161  m_type(iID),m_index(iIndex, skipCurrentProcess), m_branchType(iBranch){}
165  };
166 
167  struct LabelPlacement {
168  LabelPlacement(unsigned int iStartOfModuleLabel,
169  unsigned short iDeltaToProductInstance,
170  unsigned short iDeltaToProcessName):
171  m_startOfModuleLabel(iStartOfModuleLabel),
172  m_deltaToProductInstance(iDeltaToProductInstance),
173  m_deltaToProcessName(iDeltaToProcessName) {}
174  unsigned int m_startOfModuleLabel;
175  unsigned short m_deltaToProductInstance;
176  unsigned short m_deltaToProcessName;
177  };
178 
179  //define the purpose of each 'column' in m_tokenInfo
182 
183  //m_tokenStartOfLabels holds the entries into this container
184  // for each of the 3 labels needed to id the data
185  std::vector<char> m_tokenLabels;
186 
187  std::vector<ProductHolderIndexAndSkipBit> itemsToGetFromEvent_;
188 
189  bool frozen_;
190  };
191 }
192 
193 #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
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
void modulesDependentUpon(std::string const &iProcessName, std::string const &iModuleLabel, bool iPrint, std::vector< char const * > &oModuleLabels) const
std::vector< ProductHolderIndexAndSkipBit > itemsToGetFromEvent_
volatile std::atomic< bool > shutdown_flag false
preg
Definition: Schedule.cc:374
EDGetTokenT< ProductType > mayConsume(edm::InputTag const &tag)
EDGetToken consumes(const TypeToGet &id, edm::InputTag const &tag)