Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-07-19 01:43:41

0001 #ifndef FWCore_Framework_moduleAbilities_h
0002 #define FWCore_Framework_moduleAbilities_h
0003 // -*- C++ -*-
0004 //
0005 // Package:     FWCore/Framework
0006 // Class  :     moduleAbilities
0007 //
0008 /**\file moduleAbilities moduleAbilities.h "FWCore/Framework/interface/moduleAbilities.h"
0009 
0010  Description: Template arguments for stream::{Module}, global::{Module}, one::{Module} classes
0011 
0012  Usage:
0013     These classes are used the declare the 'abilities' a developer wants to make use of in their module.
0014 
0015 */
0016 //
0017 // Original Author:  Chris Jones
0018 //         Created:  Tue, 07 May 2013 19:19:53 GMT
0019 //
0020 
0021 // system include files
0022 #include <type_traits>
0023 
0024 // user include files
0025 #include "FWCore/Framework/interface/moduleAbilityEnums.h"
0026 
0027 // forward declarations
0028 
0029 namespace edm {
0030   namespace module {
0031     //Used in the case where ability is not available
0032     struct Empty {};
0033   }  // namespace module
0034 
0035   template <typename T>
0036   struct GlobalCache {
0037     static constexpr module::Abilities kAbilities = module::Abilities::kGlobalCache;
0038     typedef T Type;
0039   };
0040 
0041   template <typename T>
0042   struct StreamCache {
0043     static constexpr module::Abilities kAbilities = module::Abilities::kStreamCache;
0044     typedef T Type;
0045   };
0046 
0047   template <typename... CacheTypes>
0048   struct InputProcessBlockCache {
0049     static constexpr module::Abilities kAbilities = module::Abilities::kInputProcessBlockCache;
0050   };
0051 
0052   template <typename T>
0053   struct RunCache {
0054     static constexpr module::Abilities kAbilities = module::Abilities::kRunCache;
0055     typedef T Type;
0056   };
0057 
0058   template <typename T>
0059   struct LuminosityBlockCache {
0060     static constexpr module::Abilities kAbilities = module::Abilities::kLuminosityBlockCache;
0061     typedef T Type;
0062   };
0063 
0064   template <typename T>
0065   struct RunSummaryCache {
0066     static constexpr module::Abilities kAbilities = module::Abilities::kRunSummaryCache;
0067     typedef T Type;
0068   };
0069 
0070   template <typename T>
0071   struct LuminosityBlockSummaryCache {
0072     static constexpr module::Abilities kAbilities = module::Abilities::kLuminosityBlockSummaryCache;
0073     typedef T Type;
0074   };
0075 
0076   struct WatchProcessBlock {
0077     static constexpr module::Abilities kAbilities = module::Abilities::kWatchProcessBlock;
0078     typedef module::Empty Type;
0079   };
0080 
0081   struct BeginProcessBlockProducer {
0082     static constexpr module::Abilities kAbilities = module::Abilities::kBeginProcessBlockProducer;
0083     typedef module::Empty Type;
0084   };
0085 
0086   struct EndProcessBlockProducer {
0087     static constexpr module::Abilities kAbilities = module::Abilities::kEndProcessBlockProducer;
0088     typedef module::Empty Type;
0089   };
0090 
0091   struct BeginRunProducer {
0092     static constexpr module::Abilities kAbilities = module::Abilities::kBeginRunProducer;
0093     typedef module::Empty Type;
0094   };
0095 
0096   struct EndRunProducer {
0097     static constexpr module::Abilities kAbilities = module::Abilities::kEndRunProducer;
0098     typedef module::Empty Type;
0099   };
0100 
0101   struct BeginLuminosityBlockProducer {
0102     static constexpr module::Abilities kAbilities = module::Abilities::kBeginLuminosityBlockProducer;
0103     typedef module::Empty Type;
0104   };
0105 
0106   struct EndLuminosityBlockProducer {
0107     static constexpr module::Abilities kAbilities = module::Abilities::kEndLuminosityBlockProducer;
0108     typedef module::Empty Type;
0109   };
0110 
0111   struct WatchInputFiles {
0112     static constexpr module::Abilities kAbilities = module::Abilities::kWatchInputFiles;
0113     typedef module::Empty Type;
0114   };
0115 
0116   struct ExternalWork {
0117     static constexpr module::Abilities kAbilities = module::Abilities::kExternalWork;
0118     typedef module::Empty Type;
0119   };
0120 
0121   struct Accumulator {
0122     static constexpr module::Abilities kAbilities = module::Abilities::kAccumulator;
0123     typedef module::Empty Type;
0124   };
0125 
0126   //Recursively checks VArgs template arguments looking for the ABILITY
0127   template <module::Abilities ABILITY, typename... VArgs>
0128   struct CheckAbility;
0129 
0130   template <module::Abilities ABILITY, typename T, typename... VArgs>
0131   struct CheckAbility<ABILITY, T, VArgs...> {
0132     static constexpr bool kHasIt = (T::kAbilities == ABILITY) | CheckAbility<ABILITY, VArgs...>::kHasIt;
0133   };
0134 
0135   //End of the recursion
0136   template <module::Abilities ABILITY>
0137   struct CheckAbility<ABILITY> {
0138     static constexpr bool kHasIt = false;
0139   };
0140 
0141   template <typename... VArgs>
0142   struct WantsProcessBlockTransitions {
0143     static constexpr bool value = CheckAbility<module::Abilities::kWatchProcessBlock, VArgs...>::kHasIt or
0144                                   CheckAbility<module::Abilities::kBeginProcessBlockProducer, VArgs...>::kHasIt or
0145                                   CheckAbility<module::Abilities::kEndProcessBlockProducer, VArgs...>::kHasIt;
0146   };
0147 
0148   template <typename... VArgs>
0149   struct WantsInputProcessBlockTransitions {
0150     static constexpr bool value = CheckAbility<module::Abilities::kInputProcessBlockCache, VArgs...>::kHasIt;
0151   };
0152 
0153   template <typename... VArgs>
0154   struct WantsGlobalRunTransitions {
0155     static constexpr bool value = CheckAbility<module::Abilities::kRunCache, VArgs...>::kHasIt or
0156                                   CheckAbility<module::Abilities::kRunSummaryCache, VArgs...>::kHasIt or
0157                                   CheckAbility<module::Abilities::kBeginRunProducer, VArgs...>::kHasIt or
0158                                   CheckAbility<module::Abilities::kEndRunProducer, VArgs...>::kHasIt;
0159   };
0160 
0161   template <typename... VArgs>
0162   struct WantsGlobalLuminosityBlockTransitions {
0163     static constexpr bool value = CheckAbility<module::Abilities::kLuminosityBlockCache, VArgs...>::kHasIt or
0164                                   CheckAbility<module::Abilities::kLuminosityBlockSummaryCache, VArgs...>::kHasIt or
0165                                   CheckAbility<module::Abilities::kBeginLuminosityBlockProducer, VArgs...>::kHasIt or
0166                                   CheckAbility<module::Abilities::kEndLuminosityBlockProducer, VArgs...>::kHasIt;
0167   };
0168 
0169   template <typename... VArgs>
0170   struct WantsStreamRunTransitions {
0171     static constexpr bool value = CheckAbility<module::Abilities::kStreamCache, VArgs...>::kHasIt or
0172                                   CheckAbility<module::Abilities::kRunSummaryCache, VArgs...>::kHasIt;
0173   };
0174 
0175   template <typename... VArgs>
0176   struct WantsStreamLuminosityBlockTransitions {
0177     static constexpr bool value = CheckAbility<module::Abilities::kStreamCache, VArgs...>::kHasIt or
0178                                   CheckAbility<module::Abilities::kLuminosityBlockSummaryCache, VArgs...>::kHasIt;
0179   };
0180 
0181   template <typename... VArgs>
0182   struct HasAbilityToProduceInBeginProcessBlocks {
0183     static constexpr bool value = CheckAbility<module::Abilities::kBeginProcessBlockProducer, VArgs...>::kHasIt;
0184   };
0185 
0186   template <typename... VArgs>
0187   struct HasAbilityToProduceInEndProcessBlocks {
0188     static constexpr bool value = CheckAbility<module::Abilities::kEndProcessBlockProducer, VArgs...>::kHasIt;
0189   };
0190 
0191   template <typename... VArgs>
0192   struct HasAbilityToProduceInBeginRuns {
0193     static constexpr bool value = CheckAbility<module::Abilities::kBeginRunProducer, VArgs...>::kHasIt;
0194   };
0195 
0196   template <typename... VArgs>
0197   struct HasAbilityToProduceInEndRuns {
0198     static constexpr bool value = CheckAbility<module::Abilities::kEndRunProducer, VArgs...>::kHasIt;
0199   };
0200 
0201   template <typename... VArgs>
0202   struct HasAbilityToProduceInBeginLumis {
0203     static constexpr bool value = CheckAbility<module::Abilities::kBeginLuminosityBlockProducer, VArgs...>::kHasIt;
0204   };
0205 
0206   template <typename... VArgs>
0207   struct HasAbilityToProduceInEndLumis {
0208     static constexpr bool value = CheckAbility<module::Abilities::kEndLuminosityBlockProducer, VArgs...>::kHasIt;
0209   };
0210 
0211 }  // namespace edm
0212 
0213 #endif