filepath_maker.h
Go to the documentation of this file.
1 #ifndef cetlib_filepath_maker_h
2 #define cetlib_filepath_maker_h
3 
4 // ======================================================================
5 //
6 // filepath_maker: A family of related policies governing the translation
7 // of a filename into a fully-qualified filepath
8 //
9 // The semantics of each of the policies are as follows:
10 //
11 // filepath_maker: No lookup at all.
12 //
13 // filepath_lookup: Only lookup permitted.
14 
15 // filepath_lookup_nonabsolute: Absolute paths are allowed, but lookup
16 // occurs for non-absolute paths.
17 //
18 // filepath_lookup_after1: No lookup for the first file, and only
19 // lookup for all subsequent files.
20 //
21 // filepath_first_absolute_or_lookup_with_dot: The first file can be
22 // an absolute path, a path relative to '.', or a path that can be
23 // looked up; all subsequent files must be looked up.
24 //
25 // ======================================================================
26 
27 #include "cetlib/search_path.h"
28 #include <memory>
29 #include <string>
30 
31 namespace cet {
32  class filepath_maker;
33  class filepath_lookup;
34  class filepath_lookup_nonabsolute;
35  class filepath_lookup_after1;
36  class filepath_first_absolute_or_lookup_with_dot;
37  class lookup_policy_selector;
38 }
39 
40 // ----------------------------------------------------------------------
41 
43 public:
45 
46  virtual ~filepath_maker() noexcept = default;
47 
48 }; // filepath_maker
49 
50 // ----------------------------------------------------------------------
51 
53 public:
55 
56  std::string operator()(std::string const& filename) override;
57 
58 private:
60 
61 }; // filepath_lookup
62 
63 // ----------------------------------------------------------------------
64 
66 public:
68 
69  std::string operator()(std::string const& filename) override;
70 
71 private:
73 
74 }; // filepath_lookup_nonabsolute
75 
76 // ----------------------------------------------------------------------
77 
79 public:
81 
82  std::string operator()(std::string const& filename) override;
83 
84  void reset();
85 
86 private:
87  bool after1{false};
89 
90 }; // filepath_lookup_after1
91 
92 // ----------------------------------------------------------------------
93 
95  : public cet::filepath_maker {
96 public:
97  // The provided string must be the *value* of the environment
98  // variable, *not* its name.
100  std::string operator()(std::string const& filename) override;
101  void reset();
102 
103 private:
104  bool first{true};
107 }; // filepath_first_absolute_or_lookup_with_dot
108 
109 // ----------------------------------------------------------------------
110 
112 public:
113  std::unique_ptr<filepath_maker> select(std::string const& spec,
114  std::string paths) const;
115  std::string help_message() const;
116 
117 private:
118  static constexpr auto
119  none() noexcept
120  {
121  return "none";
122  }
123  static constexpr auto
124  all() noexcept
125  {
126  return "all";
127  }
128  static constexpr auto
129  nonabsolute() noexcept
130  {
131  return "nonabsolute";
132  }
133  static constexpr auto
134  after1() noexcept
135  {
136  return "after1";
137  }
138  static constexpr auto
139  permissive() noexcept
140  {
141  return "permissive";
142  }
143 };
144 
145 // ======================================================================
146 
147 #endif /* cetlib_filepath_maker_h */
148 
149 // Local Variables:
150 // mode: c++
151 // End:
static constexpr auto all() noexcept
std::string string
Definition: nybbler.cc:12
cet::search_path paths
string filename
Definition: train.py:213
static constexpr auto none() noexcept
QTextStream & reset(QTextStream &s)
virtual std::string operator()(std::string const &filename)
virtual ~filepath_maker() noexcept=default
static constexpr auto nonabsolute() noexcept
auto select(T const &...t)
Definition: select.h:146
static constexpr auto permissive() noexcept
static constexpr auto after1() noexcept