Go to the documentation of this file.00001 #ifndef FWCore_Framework_WorkerMaker_h
00002 #define FWCore_Framework_WorkerMaker_h
00003
00004 #include "FWCore/Framework/src/WorkerT.h"
00005 #include "FWCore/Framework/src/WorkerParams.h"
00006
00007 #include <memory>
00008 #include <string>
00009 #include "sigc++/signal.h"
00010
00011
00012 namespace edm {
00013 class ConfigurationDescriptions;
00014 class ModuleDescription;
00015 class ParameterSet;
00016
00017 class Maker {
00018 public:
00019 virtual ~Maker();
00020 std::auto_ptr<Worker> makeWorker(WorkerParams const&,
00021 sigc::signal<void, ModuleDescription const&>& iPre,
00022 sigc::signal<void, ModuleDescription const&>& iPost) const;
00023 void swapModule(Worker*, ParameterSet const&);
00024 protected:
00025 ModuleDescription createModuleDescription(WorkerParams const& p) const;
00026
00027 void throwConfigurationException(ModuleDescription const& md,
00028 sigc::signal<void, ModuleDescription const&>& post,
00029 cms::Exception & iException) const;
00030
00031 void throwValidationException(WorkerParams const& p,
00032 cms::Exception & iException) const;
00033
00034 void validateEDMType(std::string const& edmType, WorkerParams const& p) const;
00035
00036 private:
00037 virtual void fillDescriptions(ConfigurationDescriptions& iDesc) const = 0;
00038 virtual std::auto_ptr<Worker> makeWorker(WorkerParams const& p,
00039 ModuleDescription const& md) const = 0;
00040 virtual const std::string& baseType() const =0;
00041 virtual void implSwapModule(Worker*, ParameterSet const&)=0;
00042 };
00043
00044 template <class T>
00045 class WorkerMaker : public Maker {
00046 public:
00047
00048 explicit WorkerMaker();
00049 private:
00050 virtual void fillDescriptions(ConfigurationDescriptions& iDesc) const;
00051 virtual std::auto_ptr<Worker> makeWorker(WorkerParams const& p, ModuleDescription const& md) const;
00052 virtual const std::string& baseType() const;
00053 virtual void implSwapModule(Worker*, ParameterSet const&);
00054 };
00055
00056 template <class T>
00057 WorkerMaker<T>::WorkerMaker() {
00058 }
00059
00060 template <class T>
00061 void WorkerMaker<T>::fillDescriptions(ConfigurationDescriptions& iDesc) const {
00062 T::fillDescriptions(iDesc);
00063 T::prevalidate(iDesc);
00064 }
00065
00066 template <class T>
00067 std::auto_ptr<Worker> WorkerMaker<T>::makeWorker(WorkerParams const& p, ModuleDescription const& md) const {
00068 typedef T UserType;
00069 typedef typename UserType::ModuleType ModuleType;
00070 typedef typename UserType::WorkerType WorkerType;
00071
00072 std::auto_ptr<ModuleType> module(WorkerType::template makeModule<UserType>(md, *p.pset_));
00073 return std::auto_ptr<Worker>(new WorkerType(module, md, p));
00074 }
00075
00076
00077 template <class T>
00078 void WorkerMaker<T>::implSwapModule(Worker* w, ParameterSet const& p) {
00079 typedef T UserType;
00080 typedef typename UserType::ModuleType ModuleType;
00081 typedef typename UserType::WorkerType WorkerType;
00082
00083 WorkerType* wt = dynamic_cast<WorkerType*>(w);
00084 assert(0!=wt);
00085
00086 std::auto_ptr<ModuleType> module(WorkerType::template makeModule<UserType>(w->description(), p));
00087
00088 wt->setModule(module);
00089 }
00090
00091 template<class T>
00092 const std::string& WorkerMaker<T>::baseType() const {
00093 return T::baseType();
00094 }
00095
00096 }
00097
00098 #endif