CMS 3D CMS Logo

OccurrenceForOutput.h
Go to the documentation of this file.
1 #ifndef FWCore_Framework_OccurrenceForOutput_h
2 #define FWCore_Framework_OccurrenceForOutput_h
3 
4 // -*- C++ -*-
5 //
6 // Package: Framework
7 // Class : OccurrenceForOutput
8 //
12 /*----------------------------------------------------------------------
13 ----------------------------------------------------------------------*/
14 
20 
26 
27 #include <memory>
28 #include <string>
29 #include <typeinfo>
30 #include <vector>
31 
32 class testEventGetRefBeforePut;
33 
34 namespace edmtest {
35  class TestOutputModule;
36 }
37 
38 namespace edm {
39 
40  class BranchDescription;
41  class ModuleCallingContext;
42  class Principal;
43  class EDConsumerBase;
44 
46  public:
47  OccurrenceForOutput(Principal const& ep, ModuleDescription const& md, ModuleCallingContext const*, bool isAtEnd);
48  virtual ~OccurrenceForOutput();
49 
50  //Used in conjunction with EDGetToken
51  void setConsumer(EDConsumerBase const* iConsumer);
52 
53  ProcessHistoryID const& processHistoryID() const;
54 
55  BasicHandle getByToken(EDGetToken token, TypeID const& typeID) const;
56 
57  template <typename PROD>
58  bool getByToken(EDGetToken token, Handle<PROD>& result) const;
59 
60  template <typename PROD>
61  bool getByToken(EDGetTokenT<PROD> token, Handle<PROD>& result) const;
62 
63  template <typename PROD>
64  Handle<PROD> getHandle(EDGetTokenT<PROD> token) const;
65 
66  Provenance getProvenance(BranchID const& theID) const;
67 
68  void getAllProvenance(std::vector<Provenance const*>& provenances) const;
69 
70  void getAllStableProvenance(std::vector<StableProvenance const*>& provenances) const;
71 
72  virtual ProcessHistory const& processHistory() const;
73 
74  size_t size() const;
75 
76  protected:
77  Principal const& principal() const;
78 
79  private:
80  friend class edmtest::TestOutputModule; // For testing
81  ModuleCallingContext const* moduleCallingContext() const { return moduleCallingContext_; }
82 
84 
86  };
87 
88  template <typename PROD>
89  bool OccurrenceForOutput::getByToken(EDGetToken token, Handle<PROD>& result) const {
90  if (!provRecorder_.checkIfComplete<PROD>()) {
92  }
93  BasicHandle bh = provRecorder_.getByToken_(TypeID(typeid(PROD)), PRODUCT_TYPE, token, moduleCallingContext_);
94  result = convert_handle<PROD>(std::move(bh)); // throws on conversion error
95  if (result.failedToGet()) {
96  return false;
97  }
98  return true;
99  }
100 
101  template <typename PROD>
102  bool OccurrenceForOutput::getByToken(EDGetTokenT<PROD> token, Handle<PROD>& result) const {
103  if (!provRecorder_.checkIfComplete<PROD>()) {
104  principal_get_adapter_detail::throwOnPrematureRead("RunOrLumi", TypeID(typeid(PROD)), token);
105  }
106  BasicHandle bh = provRecorder_.getByToken_(TypeID(typeid(PROD)), PRODUCT_TYPE, token, moduleCallingContext_);
107  result = convert_handle<PROD>(std::move(bh)); // throws on conversion error
108  if (result.failedToGet()) {
109  return false;
110  }
111  return true;
112  }
113 
114  template <typename PROD>
115  Handle<PROD> OccurrenceForOutput::getHandle(EDGetTokenT<PROD> token) const {
116  if (!provRecorder_.checkIfComplete<PROD>()) {
117  principal_get_adapter_detail::throwOnPrematureRead("RunOrLumi", TypeID(typeid(PROD)), token);
118  }
119  BasicHandle bh = provRecorder_.getByToken_(TypeID(typeid(PROD)), PRODUCT_TYPE, token, moduleCallingContext_);
120  return convert_handle<PROD>(std::move(bh)); // throws on conversion error
121  }
122 
123 } // namespace edm
124 #endif
size
Write out results.
ModuleCallingContext const * moduleCallingContext() const
def principal(options)
ModuleCallingContext const * moduleCallingContext_
bool failedToGet() const
Definition: HandleBase.h:78
HLT enums.
#define PROD(A, B)
void throwOnPrematureRead(char const *principalType, TypeID const &productType, std::string const &moduleLabel, std::string const &productInstanceName)
def move(src, dest)
Definition: eostools.py:511
PrincipalGetAdapter provRecorder_