LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
InputFileCatalog.h
Go to the documentation of this file.
1 #ifndef art_Framework_IO_Catalog_InputFileCatalog_h
2 #define art_Framework_IO_Catalog_InputFileCatalog_h
3 
4 // ======================================================================
5 //
6 // Class InputFileCatalog. Services to manage InputFile catalog
7 //
8 // ======================================================================
9 
18 
19 #include <string>
20 #include <vector>
21 
22 // ----------------------------------------------------------------------
23 
24 namespace art {
25 
26  enum class FileCatalogStatus {
27  SUCCESS,
31  };
32 
33  class InputFileCatalog : public FileCatalog {
34  public:
35  struct Config {
36  fhicl::Sequence<std::string> namesParameter{fhicl::Name("fileNames")};
37  };
38 
39  explicit InputFileCatalog(fhicl::TableFragment<Config> const& config);
40  virtual ~InputFileCatalog() = default;
41  std::vector<FileCatalogItem> const&
43  {
44  return fileCatalogItems_;
45  }
46  FileCatalogItem const& currentFile() const;
47  size_t currentIndex() const;
48  bool getNextFile(int attempts = 5);
49  bool hasNextFile(int attempts = 5);
50  void rewind();
51  void rewindTo(size_t index);
52  bool
54  {
55  return searchable_;
56  }
57  bool
58  empty() const
59  {
60  return fileCatalogItems_.empty();
61  }
62  void finish(); // Dispose of the current file.
63  std::vector<std::string> const&
64  fileSources() const
65  {
66  return fileSources_;
67  }
68 
69  static constexpr size_t indexEnd{std::numeric_limits<size_t>::max()};
70 
71  private:
72  bool retrieveNextFile(FileCatalogItem& item,
73  int attempts,
74  bool transferOnly = false);
75  FileCatalogStatus retrieveNextFileFromCacheOrService(FileCatalogItem& item);
76  FileCatalogStatus transferNextFile(FileCatalogItem& item);
77 
78  std::vector<std::string> fileSources_;
79  std::vector<FileCatalogItem> fileCatalogItems_{{}}; // seed with one item
80  FileCatalogItem nextItem_{};
81  size_t fileIdx_{indexEnd};
82  size_t maxIdx_{};
83  bool searchable_{false}; // update value after the service gets configured
84  bool nextFileProbed_{false};
85  bool hasNextFile_{false};
86 
89  }; // InputFileCatalog
90 
91 } // art
92 
93  // ======================================================================
94 
95 #endif /* art_Framework_IO_Catalog_InputFileCatalog_h */
96 
97 // Local Variables:
98 // mode: c++
99 // End:
std::vector< std::string > fileSources_
ServiceHandle< FileTransfer > ft_
std::vector< FileCatalogItem > const & fileCatalogItems() const
ServiceHandle< CatalogInterface > ci_
FileCatalogStatus
Int_t max
Definition: plot.C:27
HLT enums.
std::vector< std::string > const & fileSources() const