12 #include <fmt/format.h>
13 #include <fmt/ostream.h>
18 os <<
"source name: \"" << source.
source_name <<
"\", location: \"" << source.
location <<
'"';
26 std::filesystem::path
const& path) {
27 m_mapping[source] = path.native();
31 -> std::filesystem::path {
32 auto it = m_mapping.find(source);
33 if (it == m_mapping.end()) {
35 fmt::format(
"Could not resolve local filename for source: '{}' and location: '{}'",
39 return std::filesystem::path(it->second);
47 m_mapping.swap(mapping);
54 j = nlohmann::json::array();
55 for (
auto const& s : p) {
56 j.emplace_back(nlohmann::json{
57 {
"sourceName", s.first.source_name},
58 {
"location", s.first.location},
59 {
"localPath", s.second}});
65 for (
auto const& s : j) {
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)
std::ostream & operator<<(std::ostream &os, DaqController const &daq)
void to_json(nlohmann::json &j, SourceResolver::Mapping const &p)
Declares daq::dpm::SourceResolver.
std::string location
[user@]host:/path/
std::string source_name
Named by user.