Back to home page

Project CMSSW displayed by LXR

 
 

    


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

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 #include <cstdint>
0021 
0022 namespace edm {
0023 
0024   namespace eventsetup {
0025     struct ComponentDescription;
0026   }
0027   class ModuleCallingContext;
0028   class ESModuleCallingContext {
0029   public:
0030     using Type = ESParentContext::Type;
0031 
0032     enum class State {
0033       kPrefetching,  // prefetching products before starting to run
0034       kRunning,      // module actually running
0035       kInvalid
0036     };
0037 
0038     ESModuleCallingContext(edm::eventsetup::ComponentDescription const* moduleDescription, std::uintptr_t id);
0039 
0040     ESModuleCallingContext(edm::eventsetup::ComponentDescription const* moduleDescription,
0041                            std::uintptr_t id,
0042                            State state,
0043                            ESParentContext const& parent);
0044 
0045     void setContext(State state, ESParentContext const& parent);
0046 
0047     void setState(State state) { state_ = state; }
0048 
0049     edm::eventsetup::ComponentDescription const* componentDescription() const { return componentDescription_; }
0050     State state() const { return state_; }
0051     Type type() const { return parent_.type(); }
0052     /** Returns a unique id for this module to differentiate possibly concurrent calls to the module.
0053         The value returned may be large so not appropriate for an index lookup.
0054     */
0055     std::uintptr_t callID() const { return id_; }
0056     ESParentContext const& parent() const { return parent_; }
0057     ModuleCallingContext const* moduleCallingContext() const { return parent_.moduleCallingContext(); }
0058     ESModuleCallingContext const* esmoduleCallingContext() const { return parent_.esmoduleCallingContext(); }
0059 
0060     // This function will iterate up a series of linked context objects to
0061     // find the highest level ModuleCallingContext.
0062     ModuleCallingContext const* getTopModuleCallingContext() const;
0063 
0064     // Returns the number of ESModuleCallingContexts above this ESModuleCallingContext
0065     // in the series of linked context objects.
0066     unsigned depth() const;
0067 
0068   private:
0069     edm::eventsetup::ComponentDescription const* componentDescription_;
0070     ESParentContext parent_;
0071     std::uintptr_t id_;
0072     State state_;
0073   };
0074 }  // namespace edm
0075 #endif