LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
FileCatalog.h
Go to the documentation of this file.
1 #ifndef art_Framework_IO_Catalog_FileCatalog_h
2 #define art_Framework_IO_Catalog_FileCatalog_h
3 
4 // ======================================================================
5 //
6 // Class FileCatalog. Common services to manage File catalog
7 //
8 // ======================================================================
9 
10 #include <string>
11 
12 namespace art {
13 
15  public:
16  FileCatalogItem() = default;
17 
18  FileCatalogItem(std::string const& pfn,
19  std::string const& lfn,
20  std::string const& uri)
21  : pfn_{pfn}, lfn_{lfn}, uri_{uri}
22  {}
23 
24  std::string const&
25  fileName() const noexcept
26  {
27  return pfn_;
28  }
29  std::string const&
30  logicalFileName() const noexcept
31  {
32  return lfn_;
33  }
34  std::string const&
35  uri() const noexcept
36  {
37  return uri_;
38  }
39  bool
40  skipped() const noexcept
41  {
42  return skipped_;
43  }
44  bool
45  consumed() const noexcept
46  {
47  return consumed_;
48  }
49 
50  void
51  fileName(std::string const& pfn)
52  {
53  pfn_ = pfn;
54  }
55  void
56  logicalFileName(std::string const& lfn)
57  {
58  lfn_ = lfn;
59  }
60  void
61  uri(std::string const& uri)
62  {
63  uri_ = uri;
64  }
65  void
66  skip()
67  {
68  skipped_ = true;
69  }
70  void
72  {
73  consumed_ = true;
74  }
75 
76  private:
77  std::string pfn_{};
78  std::string lfn_{};
79  std::string uri_{};
80  bool skipped_{false};
81  bool consumed_{false};
82  }; // FileCatalogItem
83 
84  // ----------------------------------------------------------------------
85 
86  class FileCatalog {
87  public:
88  virtual ~FileCatalog() = default;
89  void
91  {}
92  static bool
93  isPhysical(std::string const& name) noexcept
94  {
95  return (name.empty() || name.find(':') != std::string::npos);
96  }
97  std::string&
98  url() noexcept
99  {
100  return url_;
101  }
102  std::string const&
103  url() const noexcept
104  {
105  return url_;
106  }
107  void
108  setActive() noexcept
109  {
110  active_ = true;
111  }
112  bool
113  active() const noexcept
114  {
115  return active_;
116  }
117 
118  private:
119  std::string url_{};
120  bool active_{false};
121  }; // FileCatalog
122 
123 } // namespace art
124 
125 // ======================================================================
126 
127 #endif /* art_Framework_IO_Catalog_FileCatalog_h */
128 
129 // Local Variables:
130 // mode: c++
131 // End:
void logicalFileName(std::string const &lfn)
Definition: FileCatalog.h:56
FileCatalogItem()=default
void commitCatalog()
Definition: FileCatalog.h:90
void fileName(std::string const &pfn)
Definition: FileCatalog.h:51
bool active() const noexcept
Definition: FileCatalog.h:113
bool skipped() const noexcept
Definition: FileCatalog.h:40
std::string const & url() const noexcept
Definition: FileCatalog.h:103
void setActive() noexcept
Definition: FileCatalog.h:108
std::string const & uri() const noexcept
Definition: FileCatalog.h:35
std::string const & fileName() const noexcept
Definition: FileCatalog.h:25
std::string const & logicalFileName() const noexcept
Definition: FileCatalog.h:30
std::string & url() noexcept
Definition: FileCatalog.h:98
std::string uri_
Definition: FileCatalog.h:79
FileCatalogItem(std::string const &pfn, std::string const &lfn, std::string const &uri)
Definition: FileCatalog.h:18
Definition: MVAAlg.h:12
bool consumed() const noexcept
Definition: FileCatalog.h:45
static bool isPhysical(std::string const &name) noexcept
Definition: FileCatalog.h:93
std::string lfn_
Definition: FileCatalog.h:78
std::string pfn_
Definition: FileCatalog.h:77
void uri(std::string const &uri)
Definition: FileCatalog.h:61