LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
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 //
6 // SourceHelper provides the means for creation of EventPrincipals,
7 // SubRunPrincipals, and RunPrincipals.
8 //
9 // -----------------------------------------------------------------
10 
22 #include "cetlib/exempt_ptr.h"
23 
24 #include <memory>
25 
26 namespace art {
27  template <typename T>
28  class Source;
29 
30  class ProductTables;
31  class RunAuxiliary;
32  class SubRunAuxiliary;
33  class Timestamp;
34  class SourceHelper;
35 }
36 
38 public:
39  explicit SourceHelper(ModuleDescription const& md);
40 
41  // Copying/moving is disallowed--the helper object that art creates
42  // is intended to be passed to the user by reference for their use.
43  // If the detail class uses a copy of the SourceHelper object
44  // instead of a reference to the art-provided object, then the
45  // 'setPresentProducts' function will not be called on the detail
46  // class's object. This will induce an exception throw when calling
47  // 'make*Principal'.
48  SourceHelper(SourceHelper const&) = delete;
49  SourceHelper(SourceHelper&&) = delete;
50  SourceHelper& operator=(SourceHelper const&) = delete;
51  SourceHelper& operator=(SourceHelper&&) = delete;
52 
53  template <typename T>
54  Ptr<T> makePtr(TypeLabel const& t,
55  Principal const& p,
56  typename Ptr<T>::key_type key) const;
57 
58  RunPrincipal* makeRunPrincipal(RunAuxiliary const& runAux) const;
59 
60  RunPrincipal* makeRunPrincipal(RunID r, Timestamp const& startTime) const;
61 
63  Timestamp const& startTime) const;
64 
65  SubRunPrincipal* makeSubRunPrincipal(SubRunAuxiliary const& subRunAux) const;
66 
68  Timestamp const& startTime) const;
69 
71  SubRunNumber_t sr,
72  Timestamp const& startTime) const;
73 
75  std::shared_ptr<History>&& history) const;
76 
78  EventID const& e,
79  Timestamp const& startTime,
80  bool isRealData = true,
82 
84  RunNumber_t r,
85  SubRunNumber_t sr,
86  EventNumber_t e,
87  Timestamp const& startTime,
88  bool isRealData = true,
90 
91 private:
92  template <typename T>
93  friend class Source;
94  void throwIfProductsNotRegistered_() const;
95  void setPresentProducts(cet::exempt_ptr<ProductTables const> presentProducts);
96  cet::exempt_ptr<ProductTables const> presentProducts_{nullptr};
98 };
99 
100 template <typename T>
103  Principal const& p,
104  typename Ptr<T>::key_type key) const
105 {
106  BranchDescription const pd{p.branchType(), tl, md_};
107  ProductID const pid{pd.productID()};
108  return Ptr<T>{pid, key, p.productGetter(pid)};
109 }
110 
111 #endif /* art_Framework_IO_Sources_SourceHelper_h */
112 
113 // Local Variables:
114 // mode: c++
115 // End:
Ptr< T > makePtr(TypeLabel const &t, Principal const &p, typename Ptr< T >::key_type key) const
cet::exempt_ptr< ProductTables const > presentProducts_
Definition: SourceHelper.h:96
void setPresentProducts(cet::exempt_ptr< ProductTables const > presentProducts)
Definition: SourceHelper.cc:29
SubRunPrincipal * makeSubRunPrincipal(SubRunAuxiliary const &subRunAux) const
Definition: SourceHelper.cc:59
RunPrincipal * makeRunPrincipal(RunAuxiliary const &runAux) const
Definition: SourceHelper.cc:36
SourceHelper(ModuleDescription const &md)
Definition: SourceHelper.cc:10
SourceHelper & operator=(SourceHelper const &)=delete
IDNumber_t< Level::SubRun > SubRunNumber_t
Definition: IDNumber.h:118
void throwIfProductsNotRegistered_() const
Definition: SourceHelper.cc:13
EDProductGetter const * productGetter(ProductID const pid) const
Definition: Principal.cc:532
IDNumber_t< Level::Event > EventNumber_t
Definition: IDNumber.h:117
ModuleDescription md_
Definition: SourceHelper.h:97
std::size_t key_type
Definition: Ptr.h:102
HLT enums.
virtual BranchType branchType() const =0
Float_t e
Definition: plot.C:34
EventPrincipal * makeEventPrincipal(EventAuxiliary const &eventAux, std::shared_ptr< History > &&history) const
Definition: SourceHelper.cc:83
Definition: fwd.h:25
IDNumber_t< Level::Run > RunNumber_t
Definition: IDNumber.h:119