LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
FileCatalogMetadataPlugin.h
Go to the documentation of this file.
1 #ifndef art_Framework_Core_FileCatalogMetadataPlugin_h
2 #define art_Framework_Core_FileCatalogMetadataPlugin_h
3 
5 // FileCatalogMetadataPlugin
6 //
7 // The base class for user-defined plugins to produce SAM metadata
8 // specific to a particular output stream. Configure with:
9 //
10 // FCMDPlugins: [ { plugin_type: <pluginClassName> ... }, ... ]
11 //
12 // Entry points are called as indicated by their names, with the
13 // following extra notes:
14 //
15 // * doCollectMetadata(...) is called only when an event is selected for
16 // output by the output module for which the current plugin is
17 // configured.
18 //
19 // * doProduceMetadata() is called immediately before a file is closed
20 // by the output module for which the current plugin is configured.
21 //
22 // General notes.
23 //
24 // * Subclasses implementing this interface *must* implement
25 // produceMetadata(). Other entry points are optional.
26 //
27 // * Subclasses should not provide a header file: any communication with
28 // the plugin is accomplished solely via the base class interface.
29 //
30 // * Use the macro DEFINE_FILECATALOGMETADATA_PLUGIN(<classname>) (see
31 // below) at the bottom of your implementation file to declare your
32 // plugin to the art system.
33 //
35 
38 #include "cetlib/PluginTypeDeducer.h"
39 #include "cetlib/ProvideFilePathMacro.h"
40 #include "fhiclcpp/ParameterSet.h"
42 
43 #define DEFINE_ART_FILECATALOGMETADATA_PLUGIN(klass) \
44  CET_PROVIDE_FILE_PATH() \
45  FHICL_PROVIDE_ALLOWED_CONFIGURATION(klass) \
46  DEFINE_BASIC_PLUGIN(klass, art::FileCatalogMetadataPlugin)
47 
48 namespace art {
49  class FileCatalogMetadataPlugin;
50 
51  // Forward declarations.
52  class Event;
53  class Run;
54  class SubRun;
55 }
56 
57 namespace cet {
58  template <>
59  struct PluginTypeDeducer<art::FileCatalogMetadataPlugin> {
60  static std::string const value;
61  };
62 }
63 
65 public:
67 
69 
70  void doBeginJob();
71  void doEndJob();
72  void doCollectMetadata(Event const& e);
73  void doBeginRun(Run const& r);
74  void doEndRun(Run const& r);
75  void doBeginSubRun(SubRun const& sr);
76  void doEndSubRun(SubRun const& sr);
77  collection_type doProduceMetadata();
78 
79  virtual ~FileCatalogMetadataPlugin() = default;
80 
81 private:
82  virtual void beginJob(){};
83  virtual void endJob(){};
84  virtual void collectMetadata(Event const&){};
85  virtual void beginRun(Run const&){};
86  virtual void endRun(Run const&){};
87  virtual void beginSubRun(SubRun const&){};
88  virtual void endSubRun(SubRun const&){};
89  virtual collection_type produceMetadata() = 0;
90 };
91 #endif /* art_Framework_Core_FileCatalogMetadataPlugin_h */
92 
93 inline void
95 {
96  beginJob();
97 }
98 
99 inline void
101 {
102  endJob();
103 }
104 
105 inline void
107 {
108  collectMetadata(e);
109 }
110 
111 inline void
113 {
114  beginRun(r);
115 }
116 
117 inline void
119 {
120  endRun(r);
121 }
122 
123 inline void
125 {
126  beginSubRun(r);
127 }
128 
129 inline void
131 {
132  endSubRun(r);
133 }
134 
135 inline auto
137 {
138  return produceMetadata();
139 }
140 
141 // Local Variables:
142 // mode: c++
143 // End:
std::vector< std::pair< std::string, std::string >> collection_type
Definition: Run.h:30
virtual void beginSubRun(SubRun const &)
void beginJob()
Definition: Breakpoints.cc:14
virtual void endSubRun(SubRun const &)
art::FileCatalogMetadata::collection_type collection_type
HLT enums.
Float_t e
Definition: plot.C:34
virtual void collectMetadata(Event const &)