Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #ifndef Framework_WorkerRegistry_h
0002 #define Framework_WorkerRegistry_h
0003 
0004 /**
0005    \file
0006    Declaration of class ModuleRegistry
0007 
0008    \author Stefano ARGIRO
0009    \date 18 May 2005
0010 */
0011 
0012 #include <memory>
0013 
0014 #include <map>
0015 #include <string>
0016 
0017 #include "FWCore/Utilities/interface/propagate_const.h"
0018 
0019 namespace edm {
0020 
0021   class Worker;
0022   class ActivityRegistry;
0023   struct WorkerParams;
0024   class ModuleRegistry;
0025   class ModuleTypeResolverMaker;
0026   class ParameterSet;
0027   namespace maker {
0028     class ModuleHolder;
0029   }
0030 
0031   /**
0032      \class WorkerRegistry WorkerRegistry.h "edm/WorkerRegistry.h"
0033 
0034      \brief The Registry of all workers that where requested
0035      Holds all instances of workers. In this implementation, Workers 
0036      are owned.
0037   */
0038 
0039   class WorkerRegistry {
0040   public:
0041     explicit WorkerRegistry(std::shared_ptr<ActivityRegistry> areg, ModuleTypeResolverMaker const* resolverMaker);
0042     WorkerRegistry(std::shared_ptr<ActivityRegistry> areg, std::shared_ptr<ModuleRegistry> iModReg);
0043     ~WorkerRegistry();
0044 
0045     WorkerRegistry(WorkerRegistry&&) = default;
0046     WorkerRegistry(WorkerRegistry const&) = delete;             // Disallow copying and moving
0047     WorkerRegistry& operator=(WorkerRegistry const&) = delete;  // Disallow copying and moving
0048 
0049     /// Retrieve the particular instance of the worker
0050     /** If the worker with that set of parameters does not exist,
0051         create it
0052         @note Workers are owned by this class, do not delete them*/
0053     Worker* getWorker(WorkerParams const& p, std::string const& moduleLabel);
0054 
0055     /// Retrieve particular instance of the worker without creating it
0056     /// If one doesn't exist, returns nullptr
0057     Worker const* get(std::string const& moduleLabel) const;
0058 
0059     /// Deletes the module of the Worker, but the Worker continues to exist.
0060     void deleteModule(std::string const& moduleLabel);
0061 
0062     void clear();
0063 
0064   private:
0065     /// the container of workers
0066     typedef std::map<std::string, edm::propagate_const<std::shared_ptr<Worker>>> WorkerMap;
0067 
0068     edm::propagate_const<std::shared_ptr<ModuleRegistry>> modRegistry_;
0069 
0070     /// internal map of registered workers (owned).
0071     WorkerMap m_workerMap;
0072     std::shared_ptr<ActivityRegistry> actReg_;  // We do not use propagate_const because the registry itself is mutable.
0073 
0074   };  // WorkerRegistry
0075 
0076 }  // namespace edm
0077 
0078 #endif