FileNamesHandler.h
Go to the documentation of this file.
1 #ifndef art_Framework_IO_Sources_detail_FileNamesHandler_h
2 #define art_Framework_IO_Sources_detail_FileNamesHandler_h
3 
5 
6 #include <string>
7 #include <vector>
8 
9 namespace art {
10  namespace detail {
11 
12  template <bool wantFileServices>
14 
15  // Handle files when we want to use the official services.
16  template <>
17  class FileNamesHandler<true> {
18  public:
19  explicit FileNamesHandler(std::vector<std::string>&& fileNames,
20  size_t attempts = 5,
21  double waitBetweenAttempts = 5.0);
22 
23  std::string next();
24  void finish();
25 
26  private:
28  };
29 
30  // Handle files when we don't.
31  template <>
32  class FileNamesHandler<false> {
33  public:
34  explicit FileNamesHandler(std::vector<std::string>&& fileNames,
35  size_t = 0);
36 
37  std::string next();
38  void finish();
39 
40  private:
41  std::vector<std::string> fileNames_;
42  std::vector<std::string>::const_iterator currentFile_;
43  std::vector<std::string>::const_iterator end_;
44  };
45  } // detail
46 } // art
47 
49  std::vector<std::string>&& fileNames,
50  size_t attempts,
51  double waitBetweenAttempts)
52  : fp_(std::move(fileNames), attempts, waitBetweenAttempts)
53 {}
54 
55 inline std::string
57 {
58  return fp_.next();
59 }
60 
61 inline void
63 {
64  fp_.finish();
65 }
66 
68  std::vector<std::string>&& fileNames,
69  size_t)
70  : fileNames_(std::move(fileNames))
71  , currentFile_(fileNames_.begin())
72  , end_(fileNames_.end())
73 {}
74 
75 inline std::string
77 {
78  return (currentFile_ == end_) ? std::string() : *(currentFile_++);
79 }
80 
81 inline void
83 {
84  currentFile_ = end_;
85 }
86 #endif /* art_Framework_IO_Sources_detail_FileNamesHandler_h */
87 
88 // Local Variables:
89 // mode: c++
90 // End:
std::vector< std::string > fileNames_
std::vector< std::string >::const_iterator end_
Service to store calibration data products (CDP) in the SQLite3 metadatabase of a file...
Definition: FillParentInfo.h:8
std::vector< std::string >::const_iterator currentFile_
void next()
Definition: show_event.C:84
enum BeamMode string