13 #ifndef NURANDOM_RANDOMUTILS_PROVIDERS_POLICYFACTORY_H 14 #define NURANDOM_RANDOMUTILS_PROVIDERS_POLICYFACTORY_H 24 #include "cetlib_except/exception.h" 37 template <
typename SEED>
40 std::unique_ptr<RandomSeedPolicyBase<SEED>>
ptr;
42 operator bool()
const {
return bool(ptr); }
62 template <
typename SEED>
64 std::string
const&
policyName = config.
get<std::string>(
"policy");
70 case Policy::autoIncrement:
71 return {
policy, std::make_unique<AutoIncrementPolicy<SEED>>(config) };
72 case Policy::linearMapping:
73 return {
policy, std::make_unique<LinearMappingPolicy<SEED>>(config) };
74 case Policy::preDefinedOffset:
75 return {
policy, std::make_unique<PredefinedOffsetPolicy<SEED>>(config) };
76 case Policy::preDefinedSeed:
77 return {
policy, std::make_unique<PredefinedSeedPolicy<SEED>>(config) };
79 return {
policy, std::make_unique<RandomPolicy<SEED>>(config) };
80 case Policy::perEvent:
81 return {
policy, std::make_unique<PerEventPolicy<SEED>>(config) };
82 case Policy::unDefined:
86 <<
"Internal error: unknown policy '" << policyName <<
"'\n";
98 #endif // NURANDOM_RANDOMUTILS_PROVIDERS_POLICYFACTORY_H PolicyStruct_t< SEED > makeRandomSeedPolicy(fhicl::ParameterSet const &config)
Constructs and returns a RandomSeedPolicyBase based on config.
Declaration of policy enumerator and names.
Forward declaration of random policy classes.
std::unique_ptr< RandomSeedPolicyBase< SEED > > ptr
Policy
Enumeration of all supported random seed policies.
std::string const & policyName(Policy policy)
Returns the name of the specified policy.
RandomSeedPolicyBase< SEED > * operator->()
RandomSeedPolicyBase< SEED > const * operator->() const
Interface for a policy implementation.
T get(std::string const &key) const
Defines an interface for random seed assignment policies.
Policy policyFromName(std::string const &policyName)
Returns the policy with the specified name.
cet::coded_exception< error, detail::translate > exception