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,
48  ModuleCallingContext const*);
49  virtual ~OccurrenceForOutput();
50 
51  //Used in conjunction with EDGetToken
52  void setConsumer(EDConsumerBase const* iConsumer);
53 
54  ProcessHistoryID const& processHistoryID() const;
55 
56  bool
57  getByToken(EDGetToken token, TypeID const& typeID, BasicHandle& result) const;
58 
59  template<typename PROD>
60  bool
61  getByToken(EDGetToken token, Handle<PROD>& result) const;
62 
63  template<typename PROD>
64  bool
65  getByToken(EDGetTokenT<PROD> token, Handle<PROD>& result) const;
66 
68  getProvenance(BranchID const& theID) const;
69 
70  void
71  getAllProvenance(std::vector<Provenance const*>& provenances) const;
72 
73  void
74  getAllStableProvenance(std::vector<StableProvenance const*>& provenances) const;
75 
76  virtual ProcessHistory const&
77  processHistory() const;
78 
79  size_t size() const;
80 
81  protected:
82  Principal const&
83  principal() const;
84 
85  private:
86  friend class edmtest::TestOutputModule; // For testing
87  ModuleCallingContext const* moduleCallingContext() const { return moduleCallingContext_; }
88 
90 
92  };
93 
94  template<typename PROD>
95  bool
96  OccurrenceForOutput::getByToken(EDGetToken token, Handle<PROD>& result) const {
97  if(!provRecorder_.checkIfComplete<PROD>()) {
99  }
100  result.clear();
101  BasicHandle bh = provRecorder_.getByToken_(TypeID(typeid(PROD)),PRODUCT_TYPE, token, moduleCallingContext_);
102  convert_handle(std::move(bh), result); // throws on conversion error
103  if (result.failedToGet()) {
104  return false;
105  }
106  return true;
107  }
108 
109  template<typename PROD>
110  bool
111  OccurrenceForOutput::getByToken(EDGetTokenT<PROD> token, Handle<PROD>& result) const {
112  if(!provRecorder_.checkIfComplete<PROD>()) {
113  principal_get_adapter_detail::throwOnPrematureRead("RunOrLumi", TypeID(typeid(PROD)), token);
114  }
115  result.clear();
116  BasicHandle bh = provRecorder_.getByToken_(TypeID(typeid(PROD)),PRODUCT_TYPE, token, moduleCallingContext_);
117  convert_handle(std::move(bh), result); // throws on conversion error
118  if (result.failedToGet()) {
119  return false;
120  }
121  return true;
122  }
123 
124 }
125 #endif
126 
size
Write out results.
ModuleCallingContext const * moduleCallingContext() const
def principal(options)
void convert_handle(BasicHandle &&bh, Handle< T > &result)
Definition: ConvertHandle.h:20
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:510
PrincipalGetAdapter provRecorder_