Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:15:09

0001 #include "CaloOnlineTools/HcalOnlineDb/interface/PluginManager.hh"
0002 
0003 namespace hcal {
0004 
0005   std::map<std::string, std::map<std::string, AbstractPluginFactory*> >& PluginManager::factories() {
0006     static std::map<std::string, std::map<std::string, AbstractPluginFactory*> > factories;
0007     return factories;
0008   }
0009 
0010   void PluginManager::registerFactory(const char* baseClass, const char* derivedClass, AbstractPluginFactory* factory) {
0011     factories()[baseClass][derivedClass] = factory;
0012   }
0013 
0014   void PluginManager::getFactories(const char* baseClass, std::vector<AbstractPluginFactory*>& result) {
0015     result.clear();
0016     std::map<std::string, std::map<std::string, AbstractPluginFactory*> >::const_iterator j =
0017         factories().find(baseClass);
0018     if (j == factories().end())
0019       return;
0020     std::map<std::string, AbstractPluginFactory*>::const_iterator i;
0021     for (i = j->second.begin(); i != j->second.end(); i++)
0022       result.push_back(i->second);
0023   }
0024 
0025   AbstractPluginFactory* PluginManager::getFactory(const char* baseClass, const char* derivedClass) {
0026     std::map<std::string, std::map<std::string, AbstractPluginFactory*> >::const_iterator j =
0027         factories().find(baseClass);
0028     if (j == factories().end())
0029       return nullptr;
0030     std::map<std::string, AbstractPluginFactory*>::const_iterator i = j->second.find(derivedClass);
0031     if (i == j->second.end())
0032       return nullptr;
0033     return i->second;
0034   }
0035 
0036 }  // namespace hcal