aegir
Phlex-based simulation framework for the SHiP experiment.
Loading...
Searching...
No Matches
provider_helpers.hpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2026 CERN for the benefit of the SHiP Collaboration
2//
3// SPDX-License-Identifier: LGPL-3.0-or-later
4
5// provider_helpers.hpp — shared registration for constant data-product
6// providers (geometry, field). These sources are constant across all events,
7// so the provider hands out the same shared instance for every data cell.
8
9#pragma once
10
11#include <memory>
12#include <utility>
13
14#include "phlex/concurrency.hpp"
15#include "phlex/model/data_cell_index.hpp"
16
17namespace aegir {
18
19// Register a provider that returns a single shared instance for every data
20// cell. Templated on the registrar and source type so it serves both the
21// geometry (SHiP::IGeometrySource) and field (ship::IFieldSource) providers.
22//
23// The published product type is std::shared_ptr<Source>, so `source` must be
24// typed as the interface consumers request (not the concrete class returned
25// by make_shared) — otherwise the product lookup fails at runtime.
26template <typename Registrar, typename Source>
27void provide_constant(Registrar& s, char const* algorithm,
28 std::shared_ptr<Source> source, char const* creator,
29 char const* suffix, char const* layer) {
30 s.provide(
31 algorithm,
32 [source = std::move(source)](phlex::data_cell_index const&)
33 -> std::shared_ptr<Source> { return source; },
34 phlex::concurrency::unlimited)
35 .output_product(creator, suffix, layer);
36}
37
38} // namespace aegir
Definition math_utils.hpp:12
void provide_constant(Registrar &s, char const *algorithm, std::shared_ptr< Source > source, char const *creator, char const *suffix, char const *layer)
Definition provider_helpers.hpp:27