Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

ModuleFactory.h

Go to the documentation of this file.
00001 
00002 // $Id: ModuleFactory.h,v 1.2 2007/07/06 20:32:28 fmwk Exp $
00003 //
00005 //
00006 // messier@indiana.edu
00008 #ifndef JOBC_MODULEFACTORY_H
00009 #define JOBC_MODULEFACTORY_H
00010 #include <string>
00011 #include <map>
00012 #ifndef JOBC_MODULE_H
00013 #include "JobControl/Module.h"
00014 #endif
00015 
00016 namespace jobc {
00018   class ModuleFactory {
00019   public:
00020     static        ModuleFactory& Instance();
00021     void          Insert(const char* name, ModuleMaker_t mm);
00022     ModuleMaker_t LookUp(const char* name);
00023     
00024   private:
00025     typedef std::map<std::string,ModuleMaker_t> ModMakerMap_t;
00026     
00027     ModuleFactory() { }
00028     ModMakerMap_t         fMakerMap; 
00029     static ModuleFactory* fInstance; 
00030   };
00031 }
00032 
00034 // MODULE_DECL is a macro to declare the existence of a module to a
00035 // program
00036 //
00037 // Modules *MUST* provide a constructor of the form:
00038 //
00039 // MyModule::MyModule(const char* version) : jobcModule("MyModule", version) 
00040 // {
00041 // ...
00042 // }
00043 //
00044 // where "version" is the version tag of the set of configuration
00045 // parameters used to setup the module.
00046 //
00047 #ifndef __CINT__
00048 #define MODULE_DECL(NAME) \
00049 static jobc::Module* gs_Module_Maker(const char* v) { return new NAME(v); } \
00050 class _Module_MakerHelper {\
00051 public:\
00052   _Module_MakerHelper() { \
00053     jobc::ModuleFactory::Instance().Insert(#NAME, gs_Module_Maker);\
00054   }\
00055 }; \
00056 static _Module_MakerHelper gs_Module_MakerHelper;
00057 #endif
00058 //
00060 
00061 #endif
00062 

Generated on Mon Dec 1 02:35:18 2008 for NOvA Offline by  doxygen 1.3.9.1