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
37 
38 
39 // forward declarations
40 
41 namespace edm {
42  class ModuleDescription;
43  class ProductHolderIndexHelper;
44  class ProductRegistry;
45  class ConsumesCollector;
46  template<typename T> class WillGetIfMatch;
47 
49  {
50 
51  public:
53  virtual ~EDConsumerBase();
54 
55  // ---------- const member functions ---------------------
57 
58  void itemsToGet(BranchType, std::vector<ProductHolderIndexAndSkipBit>&) const;
59  void itemsMayGet(BranchType, std::vector<ProductHolderIndexAndSkipBit>&) const;
60 
61  std::vector<ProductHolderIndexAndSkipBit> const& itemsToGetFromEvent() const { return itemsToGetFromEvent_; }
62 
65 
67  bool registeredToConsumeMany(TypeID const&, BranchType) const;
68  // ---------- static member functions --------------------
69 
70  // ---------- member functions ---------------------------
71  void updateLookup(BranchType iBranchType,
73 
74  struct Labels {
75  const char* module;
76  const char* productInstance;
77  const char* process;
78  };
79  void labelsForToken(EDGetToken iToken, Labels& oLabels) const;
80 
81  void modulesDependentUpon(const std::string& iProcessName,
82  std::vector<const char*>& oModuleLabels) const;
83 
84  void modulesWhoseProductsAreConsumed(std::vector<ModuleDescription const*>& modules,
85  ProductRegistry const& preg,
86  std::map<std::string, ModuleDescription const*> const& labelsToDesc,
87  std::string const& processName) const;
88 
89  std::vector<ConsumesInfo> consumesInfo() const;
90 
91  protected:
92  friend class ConsumesCollector;
93  template<typename T> friend class WillGetIfMatch;
96 
97  template <typename ProductType, BranchType B=InEvent>
99  TypeToGet tid=TypeToGet::make<ProductType>();
100  return EDGetTokenT<ProductType>{recordConsumes(B,tid, checkIfEmpty(tag),true)};
101  }
102 
104  return EDGetToken{recordConsumes(InEvent, id, checkIfEmpty(tag), true)};
105  }
106 
107  template <BranchType B>
109  return EDGetToken{recordConsumes(B, id, checkIfEmpty(tag), true)};
110  }
111 
112  template <typename ProductType, BranchType B=InEvent>
114  TypeToGet tid=TypeToGet::make<ProductType>();
115  return EDGetTokenT<ProductType>{recordConsumes(B, tid, checkIfEmpty(tag), false)};
116  }
117 
119  return mayConsume<InEvent>(id,tag);
120  }
121 
122  template <BranchType B>
124  return EDGetToken{recordConsumes(B,id,checkIfEmpty(tag),false)};
125  }
126 
127  template <typename ProductType, BranchType B=InEvent>
128  void consumesMany() {
129  TypeToGet tid=TypeToGet::make<ProductType>();
130  consumesMany<B>(tid);
131  }
132 
133  void consumesMany(const TypeToGet& id) {
134  consumesMany<InEvent>(id);
135  }
136 
137  template <BranchType B>
138  void consumesMany(const TypeToGet& id) {
139  recordConsumes(B,id,edm::InputTag{},true);
140  }
141 
142  private:
143  EDConsumerBase(const EDConsumerBase&) = delete;
144 
145  const EDConsumerBase& operator=(const EDConsumerBase&) = delete;
146 
147  unsigned int recordConsumes(BranchType iBranch, TypeToGet const& iType, edm::InputTag const& iTag, bool iAlwaysGets);
148 
149  void throwTypeMismatch(edm::TypeID const&, EDGetToken) const;
151  void throwBadToken(edm::TypeID const& iType, EDGetToken iToken) const;
152  void throwConsumesCallAfterFrozen(TypeToGet const&, InputTag const&) const;
153 
155  // ---------- member data --------------------------------
156 
159  ProductHolderIndex iIndex,
160  bool skipCurrentProcess,
161  BranchType iBranch):
162  m_type(iID),m_index(iIndex, skipCurrentProcess), m_branchType(iBranch){}
166  };
167 
168  struct LabelPlacement {
169  LabelPlacement(unsigned int iStartOfModuleLabel,
170  unsigned short iDeltaToProductInstance,
171  unsigned short iDeltaToProcessName):
172  m_startOfModuleLabel(iStartOfModuleLabel),
173  m_deltaToProductInstance(iDeltaToProductInstance),
174  m_deltaToProcessName(iDeltaToProcessName) {}
175  unsigned int m_startOfModuleLabel;
176  unsigned short m_deltaToProductInstance;
177  unsigned short m_deltaToProcessName;
178  };
179 
180  //define the purpose of each 'column' in m_tokenInfo
183 
184  //m_tokenStartOfLabels holds the entries into this container
185  // for each of the 3 labels needed to id the data
186  std::vector<char> m_tokenLabels;
187 
188  std::vector<ProductHolderIndexAndSkipBit> itemsToGetFromEvent_;
189 
190  bool frozen_;
191  };
192 }
193 
194 #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)
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:370
EDGetTokenT< ProductType > mayConsume(edm::InputTag const &tag)
EDGetToken consumes(const TypeToGet &id, edm::InputTag const &tag)