-
Notifications
You must be signed in to change notification settings - Fork 4.2k
/
OccurrenceForOutput.h
126 lines (98 loc) · 3.61 KB
/
OccurrenceForOutput.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
#ifndef FWCore_Framework_OccurrenceForOutput_h
#define FWCore_Framework_OccurrenceForOutput_h
// -*- C++ -*-
//
// Package: Framework
// Class : OccurrenceForOutput
//
/**\class OccurrenceForOutput OccurrenceForOutputForOutput.h FWCore/Framework/interface/OccurrenceForOutputForOutput.h
*/
/*----------------------------------------------------------------------
----------------------------------------------------------------------*/
#include "DataFormats/Common/interface/BasicHandle.h"
#include "DataFormats/Common/interface/ConvertHandle.h"
#include "DataFormats/Common/interface/Handle.h"
#include "DataFormats/Common/interface/Wrapper.h"
#include "DataFormats/Provenance/interface/BranchListIndex.h"
#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Framework/interface/PrincipalGetAdapter.h"
#include "FWCore/Utilities/interface/TypeID.h"
#include "FWCore/Utilities/interface/EDGetToken.h"
#include "FWCore/Utilities/interface/propagate_const.h"
#include <memory>
#include <string>
#include <typeinfo>
#include <vector>
class testEventGetRefBeforePut;
namespace edmtest {
class TestOutputModule;
}
namespace edm {
class BranchDescription;
class ModuleCallingContext;
class Principal;
class EDConsumerBase;
class OccurrenceForOutput {
public:
OccurrenceForOutput(Principal const& ep, ModuleDescription const& md,
ModuleCallingContext const*);
virtual ~OccurrenceForOutput();
//Used in conjunction with EDGetToken
void setConsumer(EDConsumerBase const* iConsumer);
ProcessHistoryID const& processHistoryID() const;
bool
getByToken(EDGetToken token, TypeID const& typeID, BasicHandle& result) const;
template<typename PROD>
bool
getByToken(EDGetToken token, Handle<PROD>& result) const;
template<typename PROD>
bool
getByToken(EDGetTokenT<PROD> token, Handle<PROD>& result) const;
Provenance
getProvenance(BranchID const& theID) const;
void
getAllProvenance(std::vector<Provenance const*>& provenances) const;
void
getAllStableProvenance(std::vector<StableProvenance const*>& provenances) const;
virtual ProcessHistory const&
processHistory() const;
size_t size() const;
protected:
Principal const&
principal() const;
private:
friend class edmtest::TestOutputModule; // For testing
ModuleCallingContext const* moduleCallingContext() const { return moduleCallingContext_; }
PrincipalGetAdapter provRecorder_;
ModuleCallingContext const* moduleCallingContext_;
};
template<typename PROD>
bool
OccurrenceForOutput::getByToken(EDGetToken token, Handle<PROD>& result) const {
if(!provRecorder_.checkIfComplete<PROD>()) {
principal_get_adapter_detail::throwOnPrematureRead("RunOrLumi", TypeID(typeid(PROD)), token);
}
result.clear();
BasicHandle bh = provRecorder_.getByToken_(TypeID(typeid(PROD)),PRODUCT_TYPE, token, moduleCallingContext_);
convert_handle(std::move(bh), result); // throws on conversion error
if (result.failedToGet()) {
return false;
}
return true;
}
template<typename PROD>
bool
OccurrenceForOutput::getByToken(EDGetTokenT<PROD> token, Handle<PROD>& result) const {
if(!provRecorder_.checkIfComplete<PROD>()) {
principal_get_adapter_detail::throwOnPrematureRead("RunOrLumi", TypeID(typeid(PROD)), token);
}
result.clear();
BasicHandle bh = provRecorder_.getByToken_(TypeID(typeid(PROD)),PRODUCT_TYPE, token, moduleCallingContext_);
convert_handle(std::move(bh), result); // throws on conversion error
if (result.failedToGet()) {
return false;
}
return true;
}
}
#endif