CbmRoot
Loading...
Searching...
No Matches
VtSource.cxx
Go to the documentation of this file.
1/* Copyright (C) 2025 Jagiellonian University, Krakow
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Bartosz Sobol [committer] */
4
5#include "VtSource.h"
6
7#include "RraSource.h"
8#include "SimSource.h"
9
10#include <Utility.hpp>
11#include <regex>
12
13#include <fmt/format.h>
14
15VtSource::VtSource(const std::string& locator)
16{
17 UriComponents uri{locator};
18
19 if (uri.scheme == "file") {
20 std::regex ext_regex{R"(\.([^.\\/]+)$)"};
21 std::smatch ext_match;
22 std::regex_search(uri.path, ext_match, ext_regex);
23 const auto filetype = ext_match[1].str();
24
25 if (filetype == "rra") {
26 L_(debug) << fmt::format("[VtSource] Adding RraSource with locator {} as underlying source", locator);
27 fActualSource = std::make_unique<RraSource>(locator);
28 }
29 else if (filetype == "root") {
30 L_(debug) << fmt::format("[VtSource] Adding SimSource with locator {} as underlying source", locator);
31 fActualSource = std::make_unique<SimSource>(locator);
32 }
33 else {
34 throw std::runtime_error(fmt::format("[VtSource] Unsupported input filetype: {}", filetype));
35 }
36 }
37 else {
38 throw std::runtime_error(fmt::format("[VtSource] Unsupported input scheme: {}", uri.scheme));
39 }
40}
41
42bool VtSource::eos() const { return fActualSource->eos(); }
43
44fles::StorableTimeslice* VtSource::do_get() { return fActualSource->get().release(); }
#define L_(level)
bool eos() const override
Definition VtSource.cxx:42
std::unique_ptr< StorableTimesliceSource > fActualSource
Definition VtSource.h:21
fles::StorableTimeslice * do_get() override
Definition VtSource.cxx:44
VtSource(const std::string &locator)
Definition VtSource.cxx:15