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

ModuleFactory.cxx

Go to the documentation of this file.
00001 
00002 // $Id: ModuleFactory.cxx,v 1.1 2007/02/09 04:44:14 fmwk Exp $
00003 //
00005 //
00006 // messier@indiana.edu
00008 #include "JobControl/ModuleFactory.h"
00009 #include <iostream>
00010 using namespace jobc;
00011 
00012 ModuleFactory* ModuleFactory::fInstance = 0;
00013 
00014 //......................................................................
00015 
00016 ModuleFactory& ModuleFactory::Instance() 
00017 {
00018   if (fInstance == 0) fInstance = new ModuleFactory();
00019   return *fInstance;
00020 }
00021 
00022 //......................................................................
00023 
00024 void ModuleFactory::Insert(const char* name, ModuleMaker_t p)
00025 {
00026 //======================================================================
00027 // Insert a module maker into the table
00028 //======================================================================
00029   std::string n(name);
00030   ModMakerMap_t::iterator itr = fMakerMap.find(n);
00031   if (itr == fMakerMap.end()) {
00032     fMakerMap[n] = p;
00033     return;
00034   }
00035   std::cerr << "JobCModuleFactory" << __LINE__ 
00036             << " Proxy '" << name <<"' already in table." 
00037             << std::endl;
00038 }
00039 
00040 //......................................................................
00041 
00042 ModuleMaker_t ModuleFactory::LookUp(const char* name) 
00043 {
00044 //======================================================================
00045 // Find a module maker in the table
00046 //======================================================================
00047   std::string n(name);
00048 
00049   ModMakerMap_t::iterator itr = fMakerMap.find(n);
00050   if (itr != fMakerMap.end()) return *(itr->second);
00051   
00052   std::cerr << "JobCModuleFactory:" << __LINE__ 
00053             << " Proxy '" << name <<"' is not in table." 
00054             << std::endl;
00055   std::cerr << "*== Proxies in list are:" << std::endl;
00056   itr = fMakerMap.begin();
00057   ModMakerMap_t::iterator itrEnd(fMakerMap.end());
00058   for (; itr!=itrEnd; ++itr) {
00059     std::cerr <<" "<< itr->first << std::endl;
00060   }
00061   std::cerr << "*==" << std::endl;
00062   abort();
00063 }
00064 

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