Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:12:04

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   struct Transformer {
0127     static constexpr module::Abilities kAbilities = module::Abilities::kTransformer;
0128     using Type = module::Empty;
0129   };
0130 
0131   //Recursively checks VArgs template arguments looking for the ABILITY
0132   template <module::Abilities ABILITY, typename... VArgs>
0133   struct CheckAbility;
0134 
0135   template <module::Abilities ABILITY, typename T, typename... VArgs>
0136   struct CheckAbility<ABILITY, T, VArgs...> {
0137     static constexpr bool kHasIt = (T::kAbilities == ABILITY) | CheckAbility<ABILITY, VArgs...>::kHasIt;
0138   };
0139 
0140   //End of the recursion
0141   template <module::Abilities ABILITY>
0142   struct CheckAbility<ABILITY> {
0143     static constexpr bool kHasIt = false;
0144   };
0145 
0146   template <typename... VArgs>
0147   struct WantsProcessBlockTransitions {
0148     static constexpr bool value = CheckAbility<module::Abilities::kWatchProcessBlock, VArgs...>::kHasIt or
0149                                   CheckAbility<module::Abilities::kBeginProcessBlockProducer, VArgs...>::kHasIt or
0150                                   CheckAbility<module::Abilities::kEndProcessBlockProducer, VArgs...>::kHasIt;
0151   };
0152 
0153   template <typename... VArgs>
0154   struct WantsInputProcessBlockTransitions {
0155     static constexpr bool value = CheckAbility<module::Abilities::kInputProcessBlockCache, VArgs...>::kHasIt;
0156   };
0157 
0158   template <typename... VArgs>
0159   struct WantsGlobalRunTransitions {
0160     static constexpr bool value = CheckAbility<module::Abilities::kRunCache, VArgs...>::kHasIt or
0161                                   CheckAbility<module::Abilities::kRunSummaryCache, VArgs...>::kHasIt or
0162                                   CheckAbility<module::Abilities::kBeginRunProducer, VArgs...>::kHasIt or
0163                                   CheckAbility<module::Abilities::kEndRunProducer, VArgs...>::kHasIt;
0164   };
0165 
0166   template <typename... VArgs>
0167   struct WantsGlobalLuminosityBlockTransitions {
0168     static constexpr bool value = CheckAbility<module::Abilities::kLuminosityBlockCache, VArgs...>::kHasIt or
0169                                   CheckAbility<module::Abilities::kLuminosityBlockSummaryCache, VArgs...>::kHasIt or
0170                                   CheckAbility<module::Abilities::kBeginLuminosityBlockProducer, VArgs...>::kHasIt or
0171                                   CheckAbility<module::Abilities::kEndLuminosityBlockProducer, VArgs...>::kHasIt;
0172   };
0173 
0174   template <typename... VArgs>
0175   struct WantsStreamRunTransitions {
0176     static constexpr bool value = CheckAbility<module::Abilities::kStreamCache, VArgs...>::kHasIt or
0177                                   CheckAbility<module::Abilities::kRunSummaryCache, VArgs...>::kHasIt;
0178   };
0179 
0180   template <typename... VArgs>
0181   struct WantsStreamLuminosityBlockTransitions {
0182     static constexpr bool value = CheckAbility<module::Abilities::kStreamCache, VArgs...>::kHasIt or
0183                                   CheckAbility<module::Abilities::kLuminosityBlockSummaryCache, VArgs...>::kHasIt;
0184   };
0185 
0186   template <typename... VArgs>
0187   struct HasAbilityToProduceInBeginProcessBlocks {
0188     static constexpr bool value = CheckAbility<module::Abilities::kBeginProcessBlockProducer, VArgs...>::kHasIt;
0189   };
0190 
0191   template <typename... VArgs>
0192   struct HasAbilityToProduceInEndProcessBlocks {
0193     static constexpr bool value = CheckAbility<module::Abilities::kEndProcessBlockProducer, VArgs...>::kHasIt;
0194   };
0195 
0196   template <typename... VArgs>
0197   struct HasAbilityToProduceInBeginRuns {
0198     static constexpr bool value = CheckAbility<module::Abilities::kBeginRunProducer, VArgs...>::kHasIt;
0199   };
0200 
0201   template <typename... VArgs>
0202   struct HasAbilityToProduceInEndRuns {
0203     static constexpr bool value = CheckAbility<module::Abilities::kEndRunProducer, VArgs...>::kHasIt;
0204   };
0205 
0206   template <typename... VArgs>
0207   struct HasAbilityToProduceInBeginLumis {
0208     static constexpr bool value = CheckAbility<module::Abilities::kBeginLuminosityBlockProducer, VArgs...>::kHasIt;
0209   };
0210 
0211   template <typename... VArgs>
0212   struct HasAbilityToProduceInEndLumis {
0213     static constexpr bool value = CheckAbility<module::Abilities::kEndLuminosityBlockProducer, VArgs...>::kHasIt;
0214   };
0215 
0216 }  // namespace edm
0217 
0218 #endif