Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-08-13 23:27:04

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 ParameterSet;
0026   namespace maker {
0027     class ModuleHolder;
0028   }
0029 
0030   /**
0031      \class WorkerRegistry WorkerRegistry.h "edm/WorkerRegistry.h"
0032 
0033      \brief The Registry of all workers that where requested
0034      Holds all instances of workers. In this implementation, Workers 
0035      are owned.
0036   */
0037 
0038   class WorkerRegistry {
0039   public:
0040     explicit WorkerRegistry(std::shared_ptr<ActivityRegistry> areg);
0041     WorkerRegistry(std::shared_ptr<ActivityRegistry> areg, std::shared_ptr<ModuleRegistry> iModReg);
0042     ~WorkerRegistry();
0043 
0044     WorkerRegistry(WorkerRegistry&&) = default;
0045     WorkerRegistry(WorkerRegistry const&) = delete;             // Disallow copying and moving
0046     WorkerRegistry& operator=(WorkerRegistry const&) = delete;  // Disallow copying and moving
0047 
0048     /// Retrieve the particular instance of the worker
0049     /** If the worker with that set of parameters does not exist,
0050         create it
0051         @note Workers are owned by this class, do not delete them*/
0052     Worker* getWorker(WorkerParams const& p, std::string const& moduleLabel);
0053 
0054     /// Retrieve particular instance of the worker without creating it
0055     /// If one doesn't exist, returns nullptr
0056     Worker const* get(std::string const& moduleLabel) const;
0057 
0058     /// Deletes the module of the Worker, but the Worker continues to exist.
0059     void deleteModule(std::string const& moduleLabel);
0060 
0061     void clear();
0062 
0063   private:
0064     /// the container of workers
0065     typedef std::map<std::string, edm::propagate_const<std::shared_ptr<Worker>>> WorkerMap;
0066 
0067     edm::propagate_const<std::shared_ptr<ModuleRegistry>> modRegistry_;
0068 
0069     /// internal map of registered workers (owned).
0070     WorkerMap m_workerMap;
0071     std::shared_ptr<ActivityRegistry> actReg_;  // We do not use propagate_const because the registry itself is mutable.
0072 
0073   };  // WorkerRegistry
0074 
0075 }  // namespace edm
0076 
0077 #endif