SourceHelper.h
Go to the documentation of this file.
1 #ifndef art_Framework_IO_Sources_SourceHelper_h
2 #define art_Framework_IO_Sources_SourceHelper_h
3 
4 // -----------------------------------------------------------------
5 // SourceHelper provides the means for creation of EventPrincipals,
6 // SubRunPrincipals, and RunPrincipals.
7 //
8 // Note that processing history can only be retained for event
9 // principles, and only if a non-null History object is provided when
10 // calling makeEventPrincipal.
11 // -----------------------------------------------------------------
12 
23 #include "cetlib/exempt_ptr.h"
24 
25 #include <memory>
26 
27 namespace art {
28  class SourceHelper;
29 } // namespace art
30 
32 public:
33  explicit SourceHelper(ModuleDescription const& md);
34 
35  // Copying/moving is disallowed--the helper object that art creates
36  // is intended to be passed to the user by reference for their use.
37  // If the detail class uses a copy of the SourceHelper object
38  // instead of a reference to the art-provided object, then the
39  // 'setPresentProducts' function will not be called on the detail
40  // class's object. This will induce an exception throw when calling
41  // 'make*Principal'.
42  SourceHelper(SourceHelper const&) = delete;
43  SourceHelper(SourceHelper&&) = delete;
44  SourceHelper& operator=(SourceHelper const&) = delete;
45  SourceHelper& operator=(SourceHelper&&) = delete;
46 
47  template <typename T>
48  Ptr<T> makePtr(TypeLabel const& t,
49  Principal const& p,
50  typename Ptr<T>::key_type key) const;
51 
52  RunPrincipal* makeRunPrincipal(RunAuxiliary const& runAux) const;
53 
54  RunPrincipal* makeRunPrincipal(RunID r, Timestamp const& startTime) const;
55 
57  Timestamp const& startTime) const;
58 
59  SubRunPrincipal* makeSubRunPrincipal(SubRunAuxiliary const& subRunAux) const;
60 
62  Timestamp const& startTime) const;
63 
65  SubRunNumber_t sr,
66  Timestamp const& startTime) const;
67 
69  std::unique_ptr<History>&& history) const;
70 
72  EventID const& e,
73  Timestamp const& startTime,
74  bool isRealData = true,
76 
78  RunNumber_t r,
79  SubRunNumber_t sr,
80  EventNumber_t e,
81  Timestamp const& startTime,
82  bool isRealData = true,
84 
85 private:
86  template <typename T>
87  friend class Source;
88  void throwIfProductsNotRegistered_() const;
90  ProcessConfiguration const&) const;
91  std::unique_ptr<History> history_(ProcessConfiguration const&,
92  std::unique_ptr<History>&&) const;
96 };
97 
98 template <typename T>
101  Principal const& p,
102  typename Ptr<T>::key_type key) const
103 {
104  BranchDescription const pd{p.branchType(),
105  tl,
106  md_.moduleLabel(),
109  ProductID const pid{pd.productID()};
110  return Ptr<T>{pid, key, p.productGetter(pid)};
111 }
112 
113 #endif /* art_Framework_IO_Sources_SourceHelper_h */
114 
115 // Local Variables:
116 // mode: c++
117 // End:
Ptr< T > makePtr(TypeLabel const &t, Principal const &p, typename Ptr< T >::key_type key) const
std::unique_ptr< History > history_(ProcessConfiguration const &, std::unique_ptr< History > &&) const
Definition: SourceHelper.cc:51
EDProductGetter const * productGetter(ProductID const &pid) const
Definition: Principal.cc:297
cet::exempt_ptr< ProductTables const > presentProducts_
Definition: SourceHelper.h:94
std::string const & moduleLabel() const
void setPresentProducts(cet::exempt_ptr< ProductTables const > presentProducts)
Definition: SourceHelper.cc:85
SubRunPrincipal * makeSubRunPrincipal(SubRunAuxiliary const &subRunAux) const
std::size_t key_type
Definition: Ptr.h:79
RunPrincipal * makeRunPrincipal(RunAuxiliary const &runAux) const
Definition: SourceHelper.cc:92
const double e
def key(type, name=None)
Definition: graph.py:13
SourceHelper(ModuleDescription const &md)
Definition: SourceHelper.cc:15
SourceHelper & operator=(SourceHelper const &)=delete
IDNumber_t< Level::SubRun > SubRunNumber_t
Definition: IDNumber.h:119
p
Definition: test.py:223
ProcessConfiguration const & processConfiguration() const
void throwIfProductsNotRegistered_() const
Definition: SourceHelper.cc:18
fhicl::ParameterSetID const & parameterSetID() const
IDNumber_t< Level::Event > EventNumber_t
Definition: IDNumber.h:118
ModuleDescription md_
Definition: SourceHelper.h:95
BranchType
Definition: BranchType.h:20
EventPrincipal * makeEventPrincipal(EventAuxiliary const &eventAux, std::unique_ptr< History > &&history) const
static constexpr double sr
Definition: Units.h:166
ProcessHistoryID processHistoryID_(BranchType, ProcessConfiguration const &) const
Definition: SourceHelper.cc:34
Definition: fwd.h:31
BranchType branchType() const
Definition: Principal.cc:1022
IDNumber_t< Level::Run > RunNumber_t
Definition: IDNumber.h:120