43 using std::logic_error::logic_error;
60 return static_cast<Transports>(
static_cast<std::uint8_t
>(a) |
static_cast<std::uint8_t
>(b));
63 return (
static_cast<std::uint8_t
>(set) &
static_cast<std::uint8_t
>(t)) != 0;
71 if constexpr (
requires {
typename S::params_type; }) {
72 return [](ParamSink sink,
const ParamMap& params) {
73 typename S::params_type p{};
74 if (
auto err = p.apply(params))
throw std::invalid_argument(*err);
75 if (
auto err = validate_params(p))
throw std::invalid_argument(*err);
76 return std::make_unique<ParamPublisher>(sink, p);
86template <
class S, Transports Enabled = Transports::All>
88 static_assert(StrategyLike<S>,
89 "fastmm: register_strategy<S> needs a strategy: static name(), static schema() "
90 "and a default constructor");
92 switch (r.try_add(S::name(), &S::schema(), kind, factory, detail::publisher_factory<S>())) {
99 ") is already registered by different code; strategy names must be "
100 "unique across every registered library");
104 throw std::invalid_argument(
"strategy '" + std::string(S::name()) +
105 "' cannot be registered: empty name or no parameter schema");
124#define FASTMM_INSTANTIATE_STRATEGY(S, kind) \
125 template auto ::fastmm::kind##_factory<S>(::fastmm::TransportKind, ::fastmm::RunnerDeps&) \
126 ->std::unique_ptr<::fastmm::IEngineRunner>
Thrown by register_strategy when a name is already registered with a different schema or factory.
Definition module.hpp:43
Definition strategy.hpp:16
void(*)(StrategyRegistry &) StrategyModule
A strategy library's registration function.
Definition module.hpp:40
std::unique_ptr< IEngineRunner > replay_factory(TransportKind kind, RunnerDeps &deps)
Definition factory_replay.hpp:15
constexpr bool has(Transports set, Transports t) noexcept
Definition module.hpp:64
constexpr Transports operator|(Transports a, Transports b) noexcept
Definition module.hpp:61
Transports
Internal: the factories register_strategy adds.
Definition module.hpp:60
TransportKind
Definition registry.hpp:33
std::unique_ptr< IEngineRunner > sim_factory(TransportKind kind, RunnerDeps &deps)
Declared template <class S>, not template <StrategyLike S>: GCC and Clang mangle constrained template...
Definition factory_sim.hpp:15
constexpr std::string_view to_string(ParamType t) noexcept
Definition params.hpp:63
@ Invalid
empty name, null schema or factory, or an invalid kind
@ AlreadyPresent
the same schema and factory were registered before: nothing changed
@ Conflict
name is registered with a different schema, or (name, kind) with another factory
@ Added
the factory is now registered for (name, kind)
void register_strategy(StrategyRegistry &r)
Adds the Sim, Replay and Live factories of S (or those in Enabled).
Definition module.hpp:89
std::unique_ptr< IEngineRunner > live_factory(TransportKind kind, RunnerDeps &deps)
Definition factory_live.hpp:15
std::map< std::string, std::string > ParamMap
Definition params.hpp:119
Strategy registry (8.6, ADR-0012): name -> parameter schema + one factory per transport kind,...
Strategy concept and the StrategyBase helper (8.6).
Everything a factory needs that is backend-independent.
Definition registry.hpp:51
std::unique_ptr< IEngineRunner >(*)(TransportKind, RunnerDeps &) Factory
Definition registry.hpp:65
std::unique_ptr< ParamPublisher >(*)(ParamSink, const ParamMap &) PublisherFactory
Builds a publisher for this strategy's parameters over sink, its copy seeded with the values the sess...
Definition registry.hpp:71