ServicePack.h
Go to the documentation of this file.
1 /**
2  * @file ServiceUtil.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 // GArSoft libraries
13 #include "CoreUtils/ProviderPack.h"
14 #include "CoreUtils/ServiceUtil.h" // gar::providerFrom()
15 
16 
17 namespace gar {
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>
26  using ProviderPackFromServices = gar::ProviderPack<typename Services::provider_type...>;
27 
28  /**
29  * @brief Returns a provider pack with providers from specified services
30  * @tparam Services the services to extract the providers from
31  * @return a ProviderPack containing the current service providers
32  *
33  * This convenience function automatically extracts all the service providers
34  * from a list of services.
35  * This is convenient if an algorithm or service accepts a provider pack
36  * for setup:
37  *
38  * algo->Setup(extractProviders<
39  * detinfo::DetectorPropertiesService, detinfo::GArPropertiesService
40  * >());
41  *
42  * Also note that the provider packs can rearrange their elements, so the call
43  * above should work just the same as:
44  *
45  * algo->Setup(extractProviders<
46  * detinfo::GArPropertiesService, detinfo::DetectorPropertiesService
47  * >());
48  *
49  * If a provider is needed in the setup argument that is not provided by any
50  * of the specified services, a compilation error will occur.
51  */
52  template <typename... Services>
54  { return { gar::providerFrom<Services>()... }; }
55 
56 } // namespace gar
57 
58 //==============================================================================
59 //=== template implementation
60 //===
61 /*
62 namespace lar {
63  namespace details {
64  //--------------------------------------------------------------------------
65 
66  //--------------------------------------------------------------------------
67  } // namespace details
68 } // namespace lar
69 */
70 
71 #endif // DETECTORINFOSERVICE_SERVICEPACK_H
72 
Container for a list of pointers to providers.
Definition: ProviderPack.h:90
ProviderPackFromServices< Services... > extractProviders()
Returns a provider pack with providers from specified services.
Definition: ServicePack.h:53
General GArSoft Utilities.