CMS 3D CMS Logo

WorkerRegistry.cc

Go to the documentation of this file.
00001 
00010 static const char CVSId[] = "$Id: WorkerRegistry.cc,v 1.19 2008/10/16 23:06:28 wmtan Exp $";
00011 
00012 
00013 #include "FWCore/Framework/src/WorkerRegistry.h"
00014 #include "FWCore/Framework/src/Worker.h"
00015 #include "FWCore/Framework/src/Factory.h"
00016 
00017 #include <sstream>
00018 
00019 namespace edm {
00020 
00021 WorkerRegistry::WorkerRegistry(boost::shared_ptr<ActivityRegistry> areg) :
00022   m_workerMap(),
00023   actReg_(areg)
00024 {
00025 }
00026 
00027 WorkerRegistry:: ~WorkerRegistry() {
00028   m_workerMap.clear();
00029 }
00030 
00031 void WorkerRegistry::clear() {
00032   m_workerMap.clear();
00033 }
00034 
00035 Worker* WorkerRegistry::getWorker(const WorkerParams& p) {
00036 
00037   std::string workerid =
00038     mangleWorkerParameters(*p.pset_, p.processName_,
00039                            p.releaseVersion_,p.passID_);
00040 
00041   WorkerMap::iterator workerIt = m_workerMap.find(workerid);
00042   
00043   // if the worker is not there, make it
00044   if (workerIt == m_workerMap.end()){
00045     
00046     std::auto_ptr<Worker> workerPtr=
00047       Factory::get()->makeWorker(p,actReg_->preModuleConstructionSignal_,
00048                                  actReg_->postModuleConstructionSignal_);
00049     
00050     workerPtr->setActivityRegistry(actReg_);
00051 
00052     // Transfer ownership of worker to the registry 
00053     m_workerMap[workerid].reset(workerPtr.release());
00054     return m_workerMap[workerid].get();
00055     
00056   } 
00057   
00058   return (workerIt->second.get());
00059 
00060 }
00061 
00062 
00063 std::string WorkerRegistry::mangleWorkerParameters(ParameterSet const& parameterSet,
00064                                               std::string const& processName,
00065                                               ReleaseVersion const& releaseVersion,
00066                                               PassID const& passID) {
00067 
00068   std::stringstream mangled_parameters;
00069   mangled_parameters<< parameterSet.toString()
00070                     << processName
00071                     << releaseVersion
00072                     << passID;
00073 
00074   return mangled_parameters.str();
00075 
00076 }
00077 
00078 }
00079 
00080 
00081 

Generated on Tue Jun 9 17:36:12 2009 for CMSSW by  doxygen 1.5.4