Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-24 09:53:11

0001 #ifndef FWCore_ServiceRegistry_ESModuleCallingContext_h
0002 #define FWCore_ServiceRegistry_ESModuleCallingContext_h
0003 
0004 /**\class edm::ESModuleCallingContext
0005 
0006  Description: This is intended primarily to be passed to
0007 Services as an argument to their callback functions.
0008 
0009  Usage:
0010 
0011 
0012 */
0013 //
0014 // Original Author: W. David Dagenhart
0015 //         Created: 7/11/2013
0016 
0017 #include "FWCore/ServiceRegistry/interface/ESParentContext.h"
0018 
0019 #include <iosfwd>
0020 
0021 namespace edm {
0022 
0023   namespace eventsetup {
0024     struct ComponentDescription;
0025   }
0026   class ModuleCallingContext;
0027   class ESModuleCallingContext {
0028   public:
0029     using Type = ESParentContext::Type;
0030 
0031     enum class State {
0032       kPrefetching,  // prefetching products before starting to run
0033       kRunning,      // module actually running
0034       kInvalid
0035     };
0036 
0037     ESModuleCallingContext(edm::eventsetup::ComponentDescription const* moduleDescription);
0038 
0039     ESModuleCallingContext(edm::eventsetup::ComponentDescription const* moduleDescription,
0040                            State state,
0041                            ESParentContext const& parent);
0042 
0043     void setContext(State state, ESParentContext const& parent);
0044 
0045     void setState(State state) { state_ = state; }
0046 
0047     edm::eventsetup::ComponentDescription const* componentDescription() const { return componentDescription_; }
0048     State state() const { return state_; }
0049     Type type() const { return parent_.type(); }
0050     ESParentContext const& parent() const { return parent_; }
0051     ModuleCallingContext const* moduleCallingContext() const { return parent_.moduleCallingContext(); }
0052     ESModuleCallingContext const* esmoduleCallingContext() const { return parent_.esmoduleCallingContext(); }
0053 
0054     // This function will iterate up a series of linked context objects to
0055     // find the highest level ModuleCallingContext.
0056     ModuleCallingContext const* getTopModuleCallingContext() const;
0057 
0058     // Returns the number of ESModuleCallingContexts above this ESModuleCallingContext
0059     // in the series of linked context objects.
0060     unsigned depth() const;
0061 
0062   private:
0063     edm::eventsetup::ComponentDescription const* componentDescription_;
0064     ESParentContext parent_;
0065     State state_;
0066   };
0067 }  // namespace edm
0068 #endif