LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
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::detail {
10 
11  template <bool wantFileServices>
13 
14  // Handle files when we want to use the official services.
15  template <>
16  class FileNamesHandler<true> {
17  public:
18  explicit FileNamesHandler(std::vector<std::string>&& fileNames,
19  size_t attempts = 5,
20  double waitBetweenAttempts = 5.0);
21 
22  std::string next();
23  void finish();
24 
25  private:
27  };
28 
29  // Handle files when we don't.
30  template <>
31  class FileNamesHandler<false> {
32  public:
33  explicit FileNamesHandler(std::vector<std::string>&& fileNames, size_t = 0);
34 
35  std::string next();
36  void finish();
37 
38  private:
39  std::vector<std::string> fileNames_;
42  };
43 } // namespace art::detail
44 
46  std::vector<std::string>&& fileNames,
47  size_t attempts,
48  double waitBetweenAttempts)
49  : fp_(std::move(fileNames), attempts, waitBetweenAttempts)
50 {}
51 
52 inline std::string
54 {
55  return fp_.next();
56 }
57 
58 inline void
60 {
61  fp_.finish();
62 }
63 
65  std::vector<std::string>&& fileNames,
66  size_t)
67  : fileNames_(std::move(fileNames))
68  , currentFile_(fileNames_.begin())
69  , end_(fileNames_.end())
70 {}
71 
72 inline std::string
74 {
75  return (currentFile_ == end_) ? std::string() : *(currentFile_++);
76 }
77 
78 inline void
80 {
81  currentFile_ = end_;
82 }
83 #endif /* art_Framework_IO_Sources_detail_FileNamesHandler_h */
84 
85 // Local Variables:
86 // mode: c++
87 // End:
std::vector< std::string > fileNames_
STL namespace.
intermediate_table::const_iterator const_iterator
decltype(auto) constexpr end(T &&obj)
ADL-aware version of std::end.
Definition: StdUtils.h:77
std::vector< std::string >::const_iterator end_
decltype(auto) constexpr begin(T &&obj)
ADL-aware version of std::begin.
Definition: StdUtils.h:69
std::vector< std::string >::const_iterator currentFile_