FileCatalogMetadataPlugin.h
Go to the documentation of this file.
1 #ifndef art_Framework_Core_FileCatalogMetadataPlugin_h
2 #define art_Framework_Core_FileCatalogMetadataPlugin_h
3 // vim: set sw=2 expandtab :
4 
5 //
6 // The base class for user-defined plugins to produce SAM metadata
7 // specific to a particular output stream. Configure with:
8 //
9 // FCMDPlugins: [ { plugin_type: <pluginClassName> ... }, ... ]
10 //
11 // Entry points are called as indicated by their names, with the
12 // following extra notes:
13 //
14 // * doCollectMetadata(...) is called only when an event is selected for
15 // output by the output module for which the current plugin is
16 // configured.
17 //
18 // * doProduceMetadata() is called immediately before a file is closed
19 // by the output module for which the current plugin is configured.
20 //
21 // General notes.
22 //
23 // * Subclasses implementing this interface *must* implement
24 // produceMetadata(). Other entry points are optional.
25 //
26 // * Subclasses should not provide a header file: any communication with
27 // the plugin is accomplished solely via the base class interface.
28 //
29 // * Use the macro DEFINE_FILECATALOGMETADATA_PLUGIN(<classname>) (see
30 // below) at the bottom of your implementation file to declare your
31 // plugin to the art system.
32 //
33 
39 #include "fhiclcpp/ParameterSet.h"
41 
42 #define DEFINE_ART_FILECATALOGMETADATA_PLUGIN(klass) \
43  CET_PROVIDE_FILE_PATH() \
44  FHICL_PROVIDE_ALLOWED_CONFIGURATION(klass) \
45  DEFINE_BASIC_PLUGIN(klass, art::FileCatalogMetadataPlugin)
46 
47 namespace art {
48  class FileCatalogMetadataPlugin;
49 
50 } // namespace art
51 
52 namespace cet {
53 
54  template <>
55  struct PluginTypeDeducer<art::FileCatalogMetadataPlugin> {
56  static std::string const value;
57  };
58 
59 } // namespace cet
60 
61 namespace art {
62 
64  public:
66 
68  virtual ~FileCatalogMetadataPlugin() = default;
69 
70  void doBeginJob();
71  void doEndJob();
72 
73  void doBeginRun(Run const& r);
74  void doEndRun(Run const& r);
75 
76  void doBeginSubRun(SubRun const& sr);
77  void doEndSubRun(SubRun const& sr);
78 
79  void doCollectMetadata(Event const& e);
80 
81  collection_type doProduceMetadata();
82 
83  private:
84  virtual void
86  {}
87  virtual void
89  {}
90 
91  virtual void
92  beginRun(Run const&)
93  {}
94  virtual void
95  endRun(Run const&)
96  {}
97 
98  virtual void
100  {}
101  virtual void
103  {}
104 
105  virtual void
107  {}
108 
109  virtual collection_type produceMetadata() = 0;
110  };
111 
112  inline void
114  {
115  beginJob();
116  }
117 
118  inline void
120  {
121  endJob();
122  }
123 
124  inline void
126  {
127  collectMetadata(e);
128  }
129 
130  inline void
132  {
133  beginRun(r);
134  }
135 
136  inline void
138  {
139  endRun(r);
140  }
141 
142  inline void
144  {
145  beginSubRun(r);
146  }
147 
148  inline void
150  {
151  endSubRun(r);
152  }
153 
154  inline auto
156  {
157  return produceMetadata();
158  }
159 
160 } // namespace art
161 
162 #endif /* art_Framework_Core_FileCatalogMetadataPlugin_h */
163 
164 // Local Variables:
165 // mode: c++
166 // End:
std::vector< std::pair< std::string, std::string >> collection_type
std::string string
Definition: nybbler.cc:12
Definition: Run.h:17
const double e
virtual void beginSubRun(SubRun const &)
void beginJob()
Definition: Breakpoints.cc:14
FileCatalogMetadata::collection_type collection_type
virtual void endSubRun(SubRun const &)
virtual void collectMetadata(Event const &)
static constexpr double sr
Definition: Units.h:166