18 #ifndef LARCORE_TESTUTILS_PROVIDERLIST_H    19 #define LARCORE_TESTUTILS_PROVIDERLIST_H 1    25 #include <unordered_map>   101          datum_t const* 
get() 
const { 
return ptr.get(); }
   107          operator bool()
 const { 
return valid(); }
   166       template <
typename T>
   173       template <
typename T>
   176       template <
typename T>
   182         { 
using std::runtime_error::runtime_error; };
   209       template <
typename T, 
typename SetupProc, 
typename... Args>
   210       bool custom_setup_instance
   214             auto it = 
data.find(
k);
   215             if (it != 
data.end()) 
return false;
   217             pointer_t ptr = std::make_unique<concrete_type_t<T>>
   218               (provSetup(std::forward<Args>(
args)...));
   224       template <
typename T, 
typename SetupProc, 
typename... Args>
   227             return custom_setup_instance<
T, SetupProc, Args...>(
   229                std::forward<SetupProc>(provSetup),
   230                std::forward<Args>(
args)...
   234       template <
typename T, 
typename... Args>
   239             auto it = 
data.find(
k);
   240             if (it != 
data.end()) 
return false;
   242             pointer_t ptr = std::make_unique<concrete_type_t<T>>
   243               (setupProvider<T>(std::forward<Args>(
args)...));
   251       template <
typename T, 
typename... Args>
   253          { 
return setup_instance<T>(
"", std::forward<Args>(
args)...); }
   267       template <
typename T>
   271             auto it = 
data.find(
k);
   272             if (it != 
data.end()) 
return false;
   275               = std::make_unique<concrete_type_t<T>>(
std::move(obj_ptr));
   289       template <
typename T>
   293             auto target_it = 
data.find(
k);
   294             if (target_it == 
data.end()) 
return false;
   297             auto const* target_ptr = target_it->second.get();
   298             auto it = 
data.begin();
   299             while (it != 
data.end()) {
   300                if (it->second.get() == target_ptr) it = 
data.erase(it);
   308       template <
typename Prov, 
typename Alias>
   312             auto alias_k = key<Alias>(alias_label); 
   313             auto alias_it = 
data.find(alias_k);
   314             if (alias_it != 
data.end()) 
return false;
   317             auto prov_elem = get_elem<Prov>(prov_label);
   338       template <
typename T>
   340          { 
return get_elem<T>(
label).ref(); }
   342       template <
typename T>
   344          { 
return get_elem<T>(
label).ref(); }
   357       template <
typename T>
   359          { 
return get_elem<T>(
label).
get(); }
   361       template <
typename T>
   363          { 
return get_elem<T>(
label).
get(); }
   367       template <
typename T>
   372       template <
typename T>
   375             auto it = find<T>(
label);
   376             return (it != 
data.end()) && 
bool(it->second);
   382       std::unordered_map<key_type, pointer_t> 
data; 
   385       template <
typename T>
   389       template <
typename T>
   394       template <
typename T>
   396         { 
return data.find(key<T>(label)); }
   398       template <
typename T>
   402       template <
typename T>
   405             auto it = find<T>(
label);
   406             if (it == data.end())
   414                  + 
" [requested: " + type_name<T>() + 
"]");
   419       template <
typename T>
   422             auto it = find<T>(
label);
   423             if (it == data.end())
   431                  + 
" [requested: " + type_name<T>() + 
"]");
   437       template <
typename T>
   440             return typeid(std::decay_t<T>).hash_code()
   441                ^ std::hash<std::string>()(label);
   451 #endif // LARCORE_TESTUTILS_PROVIDERLIST_H 
smart_pointer_t< details::MovableClassWrapperBase > pointer_t
Type of objects contained in the list. 
Container of service providers accessed by type and optional label. 
T const * getPointer(std::string label="") const 
Retrieve the object of type T stored with the specified label. 
MovableClassWrapper(MovableClassWrapper< U > const &from, share_t)
Share constructor (kind of copy) 
Helper classes to be used together with LArSoft's unit test. 
Exception thrown on a request about an unregistered type. 
concrete_type_t< T > & get_elem(std::string label="")
Exception thrown on a invalid type request. 
MovableClassWrapper(std::unique_ptr< U > &&from)
datum_t const & ref() const 
Returns a constant reference to the datum with the correct type. 
virtual ~MovableClassWrapperBase()=default
bool known(std::string label="") const 
Returns whether we have a slot for this object. 
std::unique_ptr< T > smart_pointer_t
type of smart pointer we use to store elements 
MovableClassWrapper()
Default constructor: no datum present (move one in later on) 
smart_pointer_t< concrete_type_t< T >> concrete_pointer_t
Type of smart pointer to typed list element. 
datum_t & ref()
Returns a reference to the datum with the correct type. 
bool acquire(std::unique_ptr< T > &&obj_ptr, std::string label="")
Registers and gets ownership of the specified object. 
bool erase(std::string label="")
Drops the object with the specified type and label. 
bool valid() const 
Returns whether there is a valid pointer. 
concrete_type_t< T > const & get_elem(std::string label="") const 
A base class with a virtual table. 
std::shared_ptr< datum_t > pointer_t
pointer storing datum 
bool set_alias(std::string alias_label="", std::string prov_label="")
Sets the Alias type as an alias of the Prov provider (with labels) 
T * getPointer(std::string label="")
static std::string type_name(T const *ptr)
Convert a pointer to object into a (ugly) type name. 
bool valid(std::string label="") const 
Returns whether the specified object is available. 
bool custom_setup(SetupProc &&provSetup, Args &&...args)
Construct and register an object of type T with specified arguments. 
base exception class for ProviderList 
bool setup(Args &&...args)
Construct and register an object of type T with specified arguments. 
Exception thrown on when object is not available any more. 
auto find(std::string label="")
auto find(std::string label="") const 
static key_type key(std::string label="")
Extracts and returns the key out of a type and label. 
std::unordered_map< key_type, pointer_t > data
all our singletons 
static std::string type_name()
Convert a type into a (ugly) type name. 
MovableClassWrapper(pointer_t &&from)
Constructor and assignment from a unique pointer: steal the content. 
A class containing an owned object. 
size_t key_type
type used for key in the internal registry 
cet::coded_exception< error, detail::translate > exception