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  bool const parentageEnabled,
41  bool const rangesEnabled);
42 
43  // Copying/moving is disallowed--the helper object that art creates
44  // is intended to be passed to the user by reference for their use.
45  // If the detail class uses a copy of the SourceHelper object
46  // instead of a reference to the art-provided object, then the
47  // 'setPresentProducts' function will not be called on the detail
48  // class's object. This will induce an exception throw when calling
49  // 'make*Principal'.
50  SourceHelper(SourceHelper const&) = delete;
51  SourceHelper(SourceHelper&&) = delete;
52  SourceHelper& operator=(SourceHelper const&) = delete;
53  SourceHelper& operator=(SourceHelper&&) = delete;
54 
55  template <typename T>
56  Ptr<T> makePtr(TypeLabel const& t,
57  Principal const& p,
58  typename Ptr<T>::key_type key) const;
59 
60  RunPrincipal* makeRunPrincipal(RunAuxiliary const& runAux) const;
61 
63 
65  Timestamp const& startTime) const;
66 
67  SubRunPrincipal* makeSubRunPrincipal(SubRunAuxiliary const& subRunAux) const;
68 
70  Timestamp const& startTime) const;
71 
73  SubRunNumber_t sr,
74  Timestamp const& startTime) const;
75 
77  std::shared_ptr<History>&& history) const;
78 
80  EventID const& e,
81  Timestamp const& startTime,
82  bool isRealData = true,
84 
86  RunNumber_t r,
87  SubRunNumber_t sr,
88  EventNumber_t e,
89  Timestamp const& startTime,
90  bool isRealData = true,
92 
93 private:
94  template <typename T>
95  friend class Source;
96  void throwIfProductsNotRegistered_() const;
100  bool const parentageEnabled_{true};
101  bool const rangesEnabled_{true};
102 };
103 
104 template <typename T>
107  Principal const& p,
108  typename Ptr<T>::key_type key) const
109 {
110  BranchDescription const pd{p.branchType(), tl, md_};
111  ProductID const pid{pd.productID()};
112  return Ptr<T>{pid, key, p.productGetter(pid)};
113 }
114 
115 #endif /* art_Framework_IO_Sources_SourceHelper_h */
116 
117 // Local Variables:
118 // mode: c++
119 // End:
def history()
Definition: g4zmq.py:84
Ptr< T > makePtr(TypeLabel const &t, Principal const &p, typename Ptr< T >::key_type key) const
EventPrincipal * makeEventPrincipal(EventAuxiliary const &eventAux, std::shared_ptr< History > &&history) const
cet::exempt_ptr< ProductTables const > presentProducts_
Definition: SourceHelper.h:98
const char * p
Definition: xmltok.h:285
void setPresentProducts(cet::exempt_ptr< ProductTables const > presentProducts)
bool const parentageEnabled_
Definition: SourceHelper.h:100
SourceHelper & operator=(SourceHelper const &)=delete
RunPrincipal * makeRunPrincipal(RunAuxiliary const &runAux) const
IDNumber_t< Level::SubRun > SubRunNumber_t
Definition: IDNumber.h:118
caf::StandardRecord * sr
void throwIfProductsNotRegistered_() const
bool const rangesEnabled_
Definition: SourceHelper.h:101
IDNumber_t< Level::Event > EventNumber_t
Definition: IDNumber.h:117
ModuleDescription md_
Definition: SourceHelper.h:99
TRandom3 r(0)
std::size_t key_type
Definition: Ptr.h:102
Service to store calibration data products (CDP) in the SQLite3 metadatabase of a file...
Definition: FillParentInfo.h:8
SubRunPrincipal * makeSubRunPrincipal(SubRunAuxiliary const &subRunAux) const
virtual BranchType branchType() const =0
Float_t e
Definition: plot.C:35
EDProductGetter const * productGetter(ProductID const pid) const
Definition: fwd.h:28
SourceHelper(ModuleDescription const &md, bool const parentageEnabled, bool const rangesEnabled)
IDNumber_t< Level::Run > RunNumber_t
Definition: IDNumber.h:119