Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2025-06-20 01:53:17

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   class ExceptionToActionTable;
0028   namespace maker {
0029     class ModuleHolder;
0030   }
0031 
0032   /**
0033      \class WorkerRegistry WorkerRegistry.h "edm/WorkerRegistry.h"
0034 
0035      \brief The Registry of all workers that were requested
0036      Holds all instances of workers. In this implementation, Workers 
0037      are owned.
0038   */
0039 
0040   class WorkerRegistry {
0041   public:
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     //Creates worker if needed
0060     Worker* getWorkerFromExistingModule(std::string const& moduleLabel, ExceptionToActionTable const* actions);
0061 
0062     /// Deletes the module of the Worker, but the Worker continues to exist.
0063     void deleteModule(std::string const& moduleLabel);
0064 
0065     void clear();
0066 
0067   private:
0068     /// the container of workers
0069     typedef std::map<std::string, edm::propagate_const<std::shared_ptr<Worker>>> WorkerMap;
0070 
0071     edm::propagate_const<std::shared_ptr<ModuleRegistry>> modRegistry_;
0072 
0073     /// internal map of registered workers (owned).
0074     WorkerMap m_workerMap;
0075     std::shared_ptr<ActivityRegistry> actReg_;  // We do not use propagate_const because the registry itself is mutable.
0076 
0077   };  // WorkerRegistry
0078 
0079 }  // namespace edm
0080 
0081 #endif