10 #ifndef DAQ_DPM_SOURCERESOLVER_HPP
11 #define DAQ_DPM_SOURCERESOLVER_HPP
16 #include <nlohmann/json.hpp>
21 using std::invalid_argument::invalid_argument;
40 return lhs.source_name == rhs.source_name && lhs.location == rhs.location;
43 return lhs.source_name < rhs.source_name ||
44 (lhs.source_name == rhs.source_name && lhs.location < rhs.location);
48 using Mapping = std::map<SourceFile, std::string>;
62 std::filesystem::path
const& path);
72 -> std::filesystem::path;
Provides location of fits source file.
void SetMapping(Mapping mapping) noexcept
void Add(SourceFile const &source, std::filesystem::path const &path)
Adds path so it is resolved using source_name and location.
auto GetMapping() const noexcept -> Mapping const &
Get native representation of source mapping for serialization.
SourceResolver()=default
Initialize resolver with no content.
std::map< SourceFile, std::string > Mapping
auto Resolve(SourceFile const &source) const -> std::filesystem::path
Resolves local file that was previously added with Add().
void from_json(nlohmann::json const &j, SourceResolver::Mapping &p)
void to_json(nlohmann::json &j, SourceResolver::Mapping const &p)
friend bool operator==(SourceFile const &lhs, SourceFile const &rhs) noexcept
friend std::ostream & operator<<(std::ostream &os, SourceFile const &source)
friend bool operator<(SourceFile const &lhs, SourceFile const &rhs) noexcept
std::string location
[user@]host:/path/
std::string source_name
Named by user.