test
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 <vector>
23 
24 // user include files
34 
35 
36 // forward declarations
37 
38 namespace edm {
39  class ProductHolderIndexHelper;
40  class ConsumesCollector;
41  template<typename T> class WillGetIfMatch;
42 
44  {
45 
46  public:
48  virtual ~EDConsumerBase();
49 
50  // ---------- const member functions ---------------------
52 
53  void itemsToGet(BranchType, std::vector<ProductHolderIndexAndSkipBit>&) const;
54  void itemsMayGet(BranchType, std::vector<ProductHolderIndexAndSkipBit>&) const;
55 
56  std::vector<ProductHolderIndexAndSkipBit> const& itemsToGetFromEvent() const { return itemsToGetFromEvent_; }
57 
60 
62  bool registeredToConsumeMany(TypeID const&, BranchType) const;
63  // ---------- static member functions --------------------
64 
65  // ---------- member functions ---------------------------
66  void updateLookup(BranchType iBranchType,
68 
69  struct Labels {
70  const char* module;
71  const char* productInstance;
72  const char* process;
73  };
74  void labelsForToken(EDGetToken iToken, Labels& oLabels) const;
75 
76  void modulesDependentUpon(const std::string& iProcessName,
77  std::vector<const char*>& oModuleLabels) const;
78 
79  protected:
80  friend class ConsumesCollector;
81  template<typename T> friend class WillGetIfMatch;
84 
85  template <typename ProductType, BranchType B=InEvent>
87  TypeToGet tid=TypeToGet::make<ProductType>();
88  return EDGetTokenT<ProductType>{recordConsumes(B,tid, checkIfEmpty(tag),true)};
89  }
90 
92  return EDGetToken{recordConsumes(InEvent, id, checkIfEmpty(tag), true)};
93  }
94 
95  template <BranchType B>
97  return EDGetToken{recordConsumes(B, id, checkIfEmpty(tag), true)};
98  }
99 
100  template <typename ProductType, BranchType B=InEvent>
102  TypeToGet tid=TypeToGet::make<ProductType>();
103  return EDGetTokenT<ProductType>{recordConsumes(B, tid, checkIfEmpty(tag), false)};
104  }
105 
107  return mayConsume<InEvent>(id,tag);
108  }
109 
110  template <BranchType B>
112  return EDGetToken{recordConsumes(B,id,checkIfEmpty(tag),false)};
113  }
114 
115  template <typename ProductType, BranchType B=InEvent>
116  void consumesMany() {
117  TypeToGet tid=TypeToGet::make<ProductType>();
118  consumesMany<B>(tid);
119  }
120 
121  void consumesMany(const TypeToGet& id) {
122  consumesMany<InEvent>(id);
123  }
124 
125  template <BranchType B>
126  void consumesMany(const TypeToGet& id) {
127  recordConsumes(B,id,edm::InputTag{},true);
128  }
129 
130  private:
131  EDConsumerBase(const EDConsumerBase&) = delete;
132 
133  const EDConsumerBase& operator=(const EDConsumerBase&) = delete;
134 
135  unsigned int recordConsumes(BranchType iBranch, TypeToGet const& iType, edm::InputTag const& iTag, bool iAlwaysGets);
136 
137  void throwTypeMismatch(edm::TypeID const&, EDGetToken) const;
139  void throwBadToken(edm::TypeID const& iType, EDGetToken iToken) const;
140  void throwConsumesCallAfterFrozen(TypeToGet const&, InputTag const&) const;
141 
143  // ---------- member data --------------------------------
144 
147  ProductHolderIndex iIndex,
148  bool skipCurrentProcess,
149  BranchType iBranch):
150  m_type(iID),m_index(iIndex, skipCurrentProcess), m_branchType(iBranch){}
154  };
155 
156  struct LabelPlacement {
157  LabelPlacement(unsigned int iStartOfModuleLabel,
158  unsigned short iDeltaToProductInstance,
159  unsigned short iDeltaToProcessName):
160  m_startOfModuleLabel(iStartOfModuleLabel),
161  m_deltaToProductInstance(iDeltaToProductInstance),
162  m_deltaToProcessName(iDeltaToProcessName) {}
163  unsigned int m_startOfModuleLabel;
164  unsigned short m_deltaToProductInstance;
165  unsigned short m_deltaToProcessName;
166  };
167 
168  //define the purpose of each 'column' in m_tokenInfo
171 
172  //m_tokenStartOfLabels holds the entries into this container
173  // for each of the 3 labels needed to id the data
174  std::vector<char> m_tokenLabels;
175 
176  std::vector<ProductHolderIndexAndSkipBit> itemsToGetFromEvent_;
177 
178  bool frozen_;
179  };
180 }
181 
182 #endif
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
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
EDGetTokenT< ProductType > mayConsume(edm::InputTag const &tag)
EDGetToken consumes(const TypeToGet &id, edm::InputTag const &tag)