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

StopMuFinderFactory.cxx

Go to the documentation of this file.
00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 #include "Validity/VldContext.h"
00010 #include "MessageService/MsgService.h"
00011 
00012 #include "StopMuFinder.h"
00013 #include "StopMuFinderFactory.h"
00014 
00015 using std::map;
00016 using std::string;
00017 
00018 CVSID("$Id: StopMuFinderFactory.cxx,v 1.3 2007/11/11 07:29:53 rhatcher Exp $");
00019 
00021 StopMuFinderFactory* StopMuFinderFactory::fInstance = 0;
00022 
00023 
00026 StopMuFinderFactory& StopMuFinderFactory::Instance()
00027 {
00028     MSG("StopMuFilter",Msg::kDebug) 
00029         << "StopMuFinderFactory::Instance()" << endl;
00030     
00031     if ( !fInstance ) fInstance = new StopMuFinderFactory;
00032     return *fInstance;
00033 } // StopMuFinderFactory& StopMuFinderFactory::Instance()
00034 
00035 
00036 
00039 bool StopMuFinderFactory::RegisterStopMuFinder(
00040                                     string smfname, 
00041                                     SMFCreator creator) 
00042 { 
00043     MSG("StopMuFilter",Msg::kDebug) 
00044         << "StopMuFinderFactory::RegisterStopMuFinder(string, SMFCreator)" 
00045         << endl;
00046         
00047     // map<>::insert(value_type) returns pair<iterator, bool>  
00048     return fCallbacks.insert(CallbackMap::value_type(smfname, creator)).second; 
00049 } // bool StopMuFinderFactory::RegisterStopMuFinder(string, SMFCreator)
00050 
00051 
00052 
00055 bool StopMuFinderFactory::UnregisterStopMuFinder(string smfname) 
00056 { 
00057     MSG("StopMuFilter",Msg::kDebug) 
00058         << "StopMuFinderFactory::UnregisterStopMuFinder(string)" 
00059         << endl;
00060         
00061     return fCallbacks.erase(smfname) == 1; 
00062 } // bool StopMuFinderFactory::UnregisterStopMuFinder(string)
00063 
00064 
00065 
00068 StopMuFinder* StopMuFinderFactory::CreateStopMuFinder(string smfname) 
00069 {
00070     MSG("StopMuFilter",Msg::kDebug) 
00071         << "StopMuFinderFactory::CreateStopMuFinder(string)" 
00072         << endl;
00073         
00074     CallbackMap::const_iterator i = fCallbacks.find(smfname); 
00075     
00076     // handle unknown histogram block request
00077     if (i == fCallbacks.end()) {
00078         MSG("StopMuFilter",Msg::kError) 
00079             << "Dont know anything about " << smfname << endl;
00080         return 0;
00081     }
00082     
00083     // Invoke creator function 
00084     return (i->second)();
00085 } // StopMuFinder* StopMuFinderFactory::CreateStopMuFinder(string)
00086 
00087 
00088 
00091 StopMuFinder* StopMuFinderFactory::CreateStopMuFinder(const VldContext& vldc) 
00092 {
00093     MSG("StopMuFilter",Msg::kDebug) 
00094         << "StopMuFinderFactory::CreatStopMuFinder(VldContext)" 
00095         << endl;
00096         
00097     string smfname;
00098     if ( vldc.GetDetector() == Detector::kFar ) {
00099         smfname = string("StopMuFinderFar");
00100         StopMuFinder* smf = CreateStopMuFinder(smfname);
00101         return smf;        
00102     } else {   
00103         MSG("StopMuFilter",Msg::kError) 
00104             << "Can not create StopMuFinder for " 
00105             << vldc.GetDetector() << " detctor." << endl;
00106         return 0;
00107     }
00108         
00109 } // StopMuFinder* StopMuFinderFactory::CreateStopMuFinder(string)
00110 
00111 
00112 
00113 // ctor and copy-ctor are private 
00114 StopMuFinderFactory::StopMuFinderFactory(){}
00115 StopMuFinderFactory::StopMuFinderFactory(const StopMuFinderFactory&){}

Generated on Mon Feb 15 11:07:40 2010 for loon by  doxygen 1.3.9.1