All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ServicePack.h
Go to the documentation of this file.
1 /**
2  * @file ServicePack.h
3  * @brief Utilities to manage ProviderPack objects with art
4  * @author Gianluca Petrillo (petrillo@fnal.gov)
5  * @date November 22, 2015
6  * @see ProviderPack.h
7  */
8 
9 #ifndef DETECTORINFOSERVICE_SERVICEPACK_H
10 #define DETECTORINFOSERVICE_SERVICEPACK_H 1
11 
12 // LArSoft libraries
14 #include "larcore/CoreUtils/ServiceUtil.h" // lar::providerFrom()
15 
16 
17 namespace lar {
18  /*
19  namespace details {
20 
21  } // namespace details
22  */
23 
24  /// Type of provider pack with providers from all specified Services
25  template <typename... Services>
27  = lar::ProviderPack<typename Services::provider_type...>;
28 
29  /**
30  * @brief Returns a provider pack with providers from specified services
31  * @tparam Services the services to extract the providers from
32  * @return a ProviderPack containing the current service providers
33  *
34  * This convenience function automatically extracts all the service providers
35  * from a list of services.
36  * This is convenient if an algorithm or service accepts a provider pack
37  * for setup:
38  *
39  * algo->Setup(extractProviders<
40  * detinfo::DetectorPropertiesService, detinfo::LArPropertiesService
41  * >());
42  *
43  * Also note that the provider packs can rearrange their elements, so the call
44  * above should work just the same as:
45  *
46  * algo->Setup(extractProviders<
47  * detinfo::LArPropertiesService, detinfo::DetectorPropertiesService
48  * >());
49  *
50  * If a provider is needed in the setup argument that is not provided by any
51  * of the specified services, a compilation error will occur.
52  */
53  template <typename... Services>
55  { return { lar::providerFrom<Services>()... }; }
56 
57 } // namespace lar
58 
59 //==============================================================================
60 //=== template implementation
61 //===
62 /*
63 namespace lar {
64  namespace details {
65  //--------------------------------------------------------------------------
66 
67  //--------------------------------------------------------------------------
68  } // namespace details
69 } // namespace lar
70 */
71 
72 #endif // DETECTORINFOSERVICE_SERVICEPACK_H
73 
ProviderPackFromServices< Services...> extractProviders()
Returns a provider pack with providers from specified services.
Definition: ServicePack.h:54
Utilities related to art service access.
Container for a list of pointers to providers.
Definition: ProviderPack.h:114
Data structure containing constant pointers to classes.
lar::ProviderPack< typename Services::provider_type...> ProviderPackFromServices
Type of provider pack with providers from all specified Services.
Definition: ServicePack.h:27